Spaces:
Sleeping
Sleeping
Update chatbot_rag.py
Browse files- chatbot_rag.py +2 -6
chatbot_rag.py
CHANGED
|
@@ -61,7 +61,7 @@ def build_qa():
|
|
| 61 |
model=model,
|
| 62 |
tokenizer=tokenizer,
|
| 63 |
max_new_tokens=256, # control length of response
|
| 64 |
-
temperature=0.
|
| 65 |
do_sample=False, # no randomness (deterministic answers)
|
| 66 |
top_p=0.9, # nucleus sampling
|
| 67 |
repetition_penalty=1.2, # 🚀 reduce loops/repeats
|
|
@@ -69,8 +69,6 @@ def build_qa():
|
|
| 69 |
return_full_text=False
|
| 70 |
)
|
| 71 |
|
| 72 |
-
# Wrap into LangChain LLM
|
| 73 |
-
llm = HuggingFacePipeline(pipeline=pipe)
|
| 74 |
|
| 75 |
# 🔹 Wrap in LangChain LLM
|
| 76 |
llm = HuggingFacePipeline(pipeline=pipe)
|
|
@@ -82,15 +80,13 @@ def build_qa():
|
|
| 82 |
input_variables=["context", "question"],
|
| 83 |
template="""
|
| 84 |
Use the context to answer the question in short factual sentence.
|
| 85 |
-
Answer ONLY in
|
| 86 |
Do not explain, speculate, or roleplay.
|
| 87 |
Answer from the docs - Answer in plain natural language. -
|
| 88 |
Do not include code, imports, functions, or explanations of how to implement code. -
|
| 89 |
If you don't know, just say "I don't know."
|
| 90 |
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
| 94 |
Question:
|
| 95 |
{question}
|
| 96 |
|
|
|
|
| 61 |
model=model,
|
| 62 |
tokenizer=tokenizer,
|
| 63 |
max_new_tokens=256, # control length of response
|
| 64 |
+
temperature=0.2, # more deterministic
|
| 65 |
do_sample=False, # no randomness (deterministic answers)
|
| 66 |
top_p=0.9, # nucleus sampling
|
| 67 |
repetition_penalty=1.2, # 🚀 reduce loops/repeats
|
|
|
|
| 69 |
return_full_text=False
|
| 70 |
)
|
| 71 |
|
|
|
|
|
|
|
| 72 |
|
| 73 |
# 🔹 Wrap in LangChain LLM
|
| 74 |
llm = HuggingFacePipeline(pipeline=pipe)
|
|
|
|
| 80 |
input_variables=["context", "question"],
|
| 81 |
template="""
|
| 82 |
Use the context to answer the question in short factual sentence.
|
| 83 |
+
Answer ONLY in vert particular ONE short, plain sentence.
|
| 84 |
Do not explain, speculate, or roleplay.
|
| 85 |
Answer from the docs - Answer in plain natural language. -
|
| 86 |
Do not include code, imports, functions, or explanations of how to implement code. -
|
| 87 |
If you don't know, just say "I don't know."
|
| 88 |
|
| 89 |
|
|
|
|
|
|
|
| 90 |
Question:
|
| 91 |
{question}
|
| 92 |
|