Umer797 commited on
Commit
8e0d99a
·
verified ·
1 Parent(s): a3cbd84

Update llm_node.py

Browse files
Files changed (1) hide show
  1. llm_node.py +17 -10
llm_node.py CHANGED
@@ -1,16 +1,14 @@
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:
@@ -26,5 +24,14 @@ Here’s retrieved information:
26
 
27
  Your answer:"""
28
 
29
- response = llm.invoke(prompt)
 
 
 
 
 
 
 
 
 
30
  return response.strip()
 
1
+ import os
2
+ from huggingface_hub import InferenceClient
3
 
4
  def llm_node(question, search_result):
5
+ # Initialize the Hugging Face Inference Client
6
+ client = InferenceClient(
7
+ repo_id="HuggingFaceH4/zephyr-7b-beta", # You can swap in another, e.g., mistralai/Mistral-7B-Instruct-v0.2
8
+ token=os.getenv("HUGGINGFACEHUB_API_TOKEN")
 
 
 
9
  )
10
 
11
+ # Craft the prompt carefully
12
  prompt = f"""You are solving a GAIA benchmark evaluation question.
13
 
14
  Here’s the question:
 
24
 
25
  Your answer:"""
26
 
27
+ # Call the model
28
+ response = client.text_generation(
29
+ prompt,
30
+ max_new_tokens=500,
31
+ temperature=0.1,
32
+ top_p=0.95,
33
+ repetition_penalty=1.1
34
+ )
35
+
36
+ # Clean up response text
37
  return response.strip()