julietarubis commited on
Commit
7104f3c
·
1 Parent(s): c032e99
Files changed (3) hide show
  1. __init__.py +0 -0
  2. app.py +1 -1
  3. qa_pipeline.py +11 -0
__init__.py ADDED
File without changes
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import gradio as gr
2
- from app.qa_pipeline import answer_question
3
 
4
  def qa_interface(question):
5
  return answer_question(question)
 
1
  import gradio as gr
2
+ from qa_pipeline import answer_question
3
 
4
  def qa_interface(question):
5
  return answer_question(question)
qa_pipeline.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ from app.retriever import get_relevant_chunks
3
+ from app.config import LLM_MODEL
4
+
5
+ qa_model = pipeline("text2text-generation", model=LLM_MODEL)
6
+
7
+ def get_answer(question):
8
+ context = get_relevant_chunks(question)
9
+ prompt = f"Answer the question using the following context:\n{context}\n\nQuestion: {question}"
10
+ result = qa_model(prompt, max_new_tokens=300, do_sample=True, temperature=0.3) #result = qa_model(prompt, max_new_tokens=200)
11
+ return f"📄 Context used:\n{context}\n\n🧠 Answer:\n{result[0]['generated_text']}"