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']