MCPcopy Create free account
hub / github.com/TIGER-AI-Lab/LongRAG / predict_close_book

Method predict_close_book

utils/claude_inference.py:32–40  ·  view source on GitHub ↗
(self, question, demo_file_path, num_demo=16)

Source from the content-addressed store, hash-verified

30 return text
31
32 def predict_close_book(self, question, demo_file_path, num_demo=16):
33 demo = load_json_file(demo_file_path)
34 system_prompt = ("Here are some examples of questions and their corresponding answer, each with a 'Question' field and an 'Answer' field. "
35 "Answer the question directly and don't output other thing. The answer should be very concise")
36 for item in demo[:num_demo]:
37 system_prompt += f"Question: {item['question']} Answer: {item['answer']}\n"
38 prompt = f"Question: {question} Answer: "
39 answer = self.predict(system_prompt, prompt)
40 return answer
41
42 def predict_nq(self, context, question, titles):
43 prompt = (f"Go through the following context and then extract the answer of the question from the context. "

Callers

nothing calls this directly

Calls 2

predictMethod · 0.95
load_json_fileFunction · 0.90

Tested by

no test coverage detected