What is Extractive Question Answering in transformers?

This recipe explains what is Extractive Question Answering in transformers.

Recipe Objective - What is Extractive Question Answering in transformers?

Extractive Question Answering is a part of Natural Language Processing and Information Retrieval. A context is provided in Extractive Question Answering so that the model can refer to it and make predictions about where the answer is inside the passage. The SQuAD dataset, which is entirely task-based, is an example of a question and answer dataset. The run qa.py and run tf squad.py scripts can be used to fine-tune a model in the SQuAD job.

NLP Interview Questions to Help you Prepare for your Machine Learning Interview

For more related projects -

/projects/data-science-projects/tensorflow-projects
/projects/data-science-projects/keras-deep-learning-projects

Example of using a pipeline to question answering: extracting an answer for a given question

# Importing libraries
from transformers import pipeline

# Creating model using pipeline for question answering
Model_question_answer = pipeline("question-answering")

# Defining context for question
context = r"""... Delhi, city and national capital territory, north-central India.
... The city of Delhi actually consists of two components: Old Delhi, in the north, the historic city; and New Delhi, in the south,
... since 1947 the capital of India, built in the first part of the 20th century as the capital of British India."""

# Passing question and context to model
model_answer = Model_question_answer(question="What is the capital of india?",context=context)

# Printing answer with score
print("Answer is '{}' with score = {}".format(model_answer['answer'],round(model_answer['score'],4)))

Output -
Answer is 'Delhi' with score = 0.6087

In this way, we can perform question-answering in transformers.

What Users are saying..

profile image

Anand Kumpatla

Sr Data Scientist @ Doubleslash Software Solutions Pvt Ltd
linkedin profile url

ProjectPro is a unique platform and helps many people in the industry to solve real-life problems with a step-by-step walkthrough of projects. A platform with some fantastic resources to gain... Read More

Relevant Projects

Learn How to Build a Linear Regression Model in PyTorch
In this Machine Learning Project, you will learn how to build a simple linear regression model in PyTorch to predict the number of days subscribed.

Topic modelling using Kmeans clustering to group customer reviews
In this Kmeans clustering machine learning project, you will perform topic modelling in order to group customer reviews based on recurring patterns.

Recommender System Machine Learning Project for Beginners-4
Collaborative Filtering Recommender System Project - Comparison of different model based and memory based methods to build recommendation system using collaborative filtering.

Build an Image Segmentation Model using Amazon SageMaker
In this Machine Learning Project, you will learn to implement the UNet Architecture and build an Image Segmentation Model using Amazon SageMaker

Build Regression (Linear,Ridge,Lasso) Models in NumPy Python
In this machine learning regression project, you will learn to build NumPy Regression Models (Linear Regression, Ridge Regression, Lasso Regression) from Scratch.

Loan Default Prediction Project using Explainable AI ML Models
Loan Default Prediction Project that employs sophisticated machine learning models, such as XGBoost and Random Forest and delves deep into the realm of Explainable AI, ensuring every prediction is transparent and understandable.

Predictive Analytics Project for Working Capital Optimization
In this Predictive Analytics Project, you will build a model to accurately forecast the timing of customer and supplier payments for optimizing working capital.

Time Series Analysis with Facebook Prophet Python and Cesium
Time Series Analysis Project - Use the Facebook Prophet and Cesium Open Source Library for Time Series Forecasting in Python

Recommender System Machine Learning Project for Beginners-3
Content Based Recommender System Project - Building a Content-Based Product Recommender App with Streamlit

Build Piecewise and Spline Regression Models in Python
In this Regression Project, you will learn how to build a piecewise and spline regression model from scratch in Python to predict the points scored by a sports team.