Spaces:
Runtime error
Runtime error
File size: 559 Bytes
7104f3c d2894a4 7104f3c | 1 2 3 4 5 6 7 8 9 10 11 12 | from transformers import pipeline
from retriever import get_relevant_chunks
from config import LLM_MODEL
qa_model = pipeline("text2text-generation", model=LLM_MODEL)
def get_answer(question):
context = get_relevant_chunks(question)
prompt = f"Answer the question using the following context:\n{context}\n\nQuestion: {question}"
result = qa_model(prompt, max_new_tokens=300, do_sample=True, temperature=0.3) #result = qa_model(prompt, max_new_tokens=200)
return f"📄 Context used:\n{context}\n\n🧠 Answer:\n{result[0]['generated_text']}"
|