Question Natural Language Inference
Another task under the text classification umbrella is Question Natural Language Inference, or QNLI. This checks if a premise contains enough information to answer a posed question, determining whether the answer can be found in the given text.
Performing different tasks with the text-classification
pipeline can be done by choosing different models. Each model is trained to predict specific labels and optimized for learning different context within a text.
pipeline
from the transformers
library is already loaded for you.
This exercise is part of the course
Working with Hugging Face
Exercise instructions
- Create a text classification QNLI pipeline using the model
"cross-encoder/qnli-electra-base"
and save asclassifier
. - Use this classifier to determine if the text provides enough information to answer the question.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create the pipeline
____ = ____(____=____, ____="cross-encoder/qnli-electra-base")
# Predict the output
____ = ____("Where is the capital of France?, Brittany is known for its stunning coastline.")
print(output)