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

Jingwei Li

Graduate Research assistance at Stony Brook University
linkedin profile url

ProjectPro is an awesome platform that helps me learn much hands-on industrial experience with a step-by-step walkthrough of projects. There are two primary paths to learn: Data Science and Big Data.... Read More

Relevant Projects

Build a Graph Based Recommendation System in Python -Part 1
Python Recommender Systems Project - Learn to build a graph based recommendation system in eCommerce to recommend products.

Demand prediction of driver availability using multistep time series analysis
In this supervised learning machine learning project, you will predict the availability of a driver in a specific area by using multi step time series analysis.

LLM Project to Build and Fine Tune a Large Language Model
In this LLM project for beginners, you will learn to build a knowledge-grounded chatbot using LLM's and learn how to fine tune it.

MLOps Project to Build Search Relevancy Algorithm with SBERT
In this MLOps SBERT project you will learn to build and deploy an accurate and scalable search algorithm on AWS using SBERT and ANNOY to enhance search relevancy in news articles.

Loan Eligibility Prediction Project using Machine learning on GCP
Loan Eligibility Prediction Project - Use SQL and Python to build a predictive model on GCP to determine whether an application requesting loan is eligible or not.

NLP Project on LDA Topic Modelling Python using RACE Dataset
Use the RACE dataset to extract a dominant topic from each document and perform LDA topic modeling in python.

Predict Churn for a Telecom company using Logistic Regression
Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.

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.

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

Deploy Transformer BART Model for Text summarization on GCP
Learn to Deploy a Machine Learning Model for the Abstractive Text Summarization on Google Cloud Platform (GCP)