Umer797 commited on
Commit
485fdc3
·
verified ·
1 Parent(s): a4a580c

Update llm_node.py

Browse files
Files changed (1) hide show
  1. llm_node.py +15 -17
llm_node.py CHANGED
@@ -1,32 +1,30 @@
1
  from langchain_community.llms import HuggingFaceHub
2
 
3
- def llm_node(question):
4
- # Initialize the Hugging Face model
5
  llm = HuggingFaceHub(
6
- repo_id="HuggingFaceH4/zephyr-7b-beta", # You can replace with e.g., mistralai/Mistral-7B-Instruct-v0.2
7
  model_kwargs={
8
- "temperature": 0.1, # Keep responses deterministic
9
- "max_new_tokens": 500 # Allow for longer outputs if needed
10
  }
11
  )
12
 
13
- # Craft the prompt carefully for exact-match outputs
14
  prompt = f"""You are solving a GAIA benchmark evaluation question.
15
 
16
- ⚠️ VERY IMPORTANT:
17
- - ONLY return the final answer, exactly as required.
18
- - DO NOT include explanations, prefixes, or notes.
19
- - Format the answer exactly as asked (e.g., comma-separated, plural, in requested order).
20
- - If the question asks for a list, give only the list, no intro.
21
-
22
  Here’s the question:
23
-
24
  {question}
25
 
26
- Your direct answer:"""
 
 
 
 
 
 
 
 
27
 
28
- # Run the model
29
  response = llm.invoke(prompt)
30
-
31
- # Clean up whitespace or stray characters
32
  return response.strip()
 
1
  from langchain_community.llms import HuggingFaceHub
2
 
3
+ def llm_node(question, search_result):
4
+ # Initialize Hugging Face model (free)
5
  llm = HuggingFaceHub(
6
+ repo_id="HuggingFaceH4/zephyr-7b-beta", # You can swap with mistral or mixtral if needed
7
  model_kwargs={
8
+ "temperature": 0.1,
9
+ "max_new_tokens": 500
10
  }
11
  )
12
 
13
+ # Build prompt combining search + question
14
  prompt = f"""You are solving a GAIA benchmark evaluation question.
15
 
 
 
 
 
 
 
16
  Here’s the question:
 
17
  {question}
18
 
19
+ Here’s retrieved information:
20
+ {search_result}
21
+
22
+ ⚠️ VERY IMPORTANT:
23
+ - ONLY return the final answer, exactly as required.
24
+ - Do NOT include explanations, prefixes, or notes.
25
+ - If the question asks for a list, give only the list, in the requested format.
26
+
27
+ Your answer:"""
28
 
 
29
  response = llm.invoke(prompt)
 
 
30
  return response.strip()