Spaces:
Runtime error
Runtime error
Download qa_pipeline.py from julietarubis/internal-docs-qa: direct link, hf CLI and curl.
- Browser
- Download file 559 Bytes
-
https://huggingface.co/spaces/julietarubis/internal-docs-qa/resolve/main/qa_pipeline.py
- Command line
-
hf download hf://spaces/julietarubis/internal-docs-qa/qa_pipeline.py
-
curl -L -o qa_pipeline.py https://huggingface.co/spaces/julietarubis/internal-docs-qa/resolve/main/qa_pipeline.py
559 Bytes
| 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']}" | |