Spaces:
Sleeping
Sleeping
Update llm_node.py
Browse files1234567891011121314151617181920212223242526272829303132from langchain_community.llms import HuggingFaceHubdef llm_node(question):# Initialize the Hugging Face modelllm = HuggingFaceHub(repo_id="HuggingFaceH4/zephyr-7b-beta", # You can replace with e.g., mistralai/Mistral-7B-Instruct-v0.2model_kwargs={"temperature": 0.1, # Keep responses deterministic"max_new_tokens": 500 # Allow for longer outputs if needed})# Craft the prompt carefully for exact-match outputsprompt = f"""You are solving a GAIA benchmark evaluation question.⚠️ VERY IMPORTANT:- ONLY return the final answer, exactly as required.- DO NOT include explanations, prefixes, or notes.- Format the answer exactly as asked (e.g., comma-separated, plural, in requested order).- If the question asks for a list, give only the list, no intro.Here’s the question:{question}Your direct answer:"""# Run the modelresponse = llm.invoke(prompt)# Clean up whitespace or stray charactersreturn response.strip()123456789101112131415161718192021222324252627282930from langchain_community.llms import HuggingFaceHubdef llm_node(question, search_result):# Initialize Hugging Face model (free)llm = HuggingFaceHub(repo_id="HuggingFaceH4/zephyr-7b-beta", # You can swap with mistral or mixtral if neededmodel_kwargs={"temperature": 0.1,"max_new_tokens": 500})# Build prompt combining search + questionprompt = f"""You are solving a GAIA benchmark evaluation question.Here’s the question:{question}Here’s retrieved information:{search_result}⚠️ VERY IMPORTANT:- ONLY return the final answer, exactly as required.- Do NOT include explanations, prefixes, or notes.- If the question asks for a list, give only the list, in the requested format.Your answer:"""response = llm.invoke(prompt)return response.strip()
llm_node.py+15-17