article-summarizer / qa_utils.py
ENGRLAKSHMI's picture
Add Gradio app for article summarization
ec8e443
raw
history blame contribute delete
479 Bytes
from transformers import pipeline
import os
# Set your Hugging Face token as an environment variable
# Make sure this token is valid and has the necessary permissions
# or, pass the token directly to the pipeline function
qa_pipeline = pipeline("question-answering", model="distilbert-base-cased-distilled-squad") # Replace with your actual token
def answer_question(question, context):
result = qa_pipeline(question=question, context=context)
return result['answer']