Subha95 commited on
Commit
3569bcd
·
verified ·
1 Parent(s): ead715a

Update chatbot_rag.py

Browse files
Files changed (1) hide show
  1. chatbot_rag.py +8 -6
chatbot_rag.py CHANGED
@@ -25,21 +25,23 @@ def build_qa():
25
 
26
  # 3. Load LLM (Flan-T5 small for lightweight QA)
27
  print("🔹 Loading LLM...")
28
- model_id = "google/flan-t5-small"
29
  tokenizer = AutoTokenizer.from_pretrained(model_id)
30
  model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
31
 
32
  pipe = pipeline(
33
- "text2text-generation",
34
- model=model,
35
- tokenizer=tokenizer,
36
- max_new_tokens=256,
 
 
37
  )
38
  llm = HuggingFacePipeline(pipeline=pipe)
39
 
40
  # 4. QA Chain with retrieval
41
  print("🔹 Building RetrievalQA...")
42
- retriever = vectorstore.as_retriever(search_kwargs={"k": 3})
43
 
44
 
45
  template = """
 
25
 
26
  # 3. Load LLM (Flan-T5 small for lightweight QA)
27
  print("🔹 Loading LLM...")
28
+ model_id = "microsoft/Phi-3-mini-4k-instruct"
29
  tokenizer = AutoTokenizer.from_pretrained(model_id)
30
  model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
31
 
32
  pipe = pipeline(
33
+ "text-generation",
34
+ model=model,
35
+ tokenizer=tokenizer,
36
+ max_new_tokens=300,
37
+ do_sample=True, # Set to True to enable sampling and use temperature
38
+ temperature=0.2 # This is the temperature parameter
39
  )
40
  llm = HuggingFacePipeline(pipeline=pipe)
41
 
42
  # 4. QA Chain with retrieval
43
  print("🔹 Building RetrievalQA...")
44
+ retriever = vectorstore.as_retriever()
45
 
46
 
47
  template = """