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

Method predict_nq

utils/gpt_inference.py:55–65  ·  view source on GitHub ↗
(self, context, question, titles)

Source from the content-addressed store, hash-verified

53 return answer
54
55 def predict_nq(self, context, question, titles):
56 titles = ['"' + title + '"' for title in titles]
57 prompt = (f"Go through the following context and then extract the answer of the question from the context. "
58 f"Answer the question directly. Your answer should be very concise. "
59 f"The context is a list of Wikipedia documents, ordered by title: {titles}. "
60 f"Each Wikipedia document contains a 'title' field and a 'text' field. "
61 f"The context is: {context}. "
62 f"The question: {question}. ")
63 long_answer = self.predict(prompt)
64 short_answer = self.extract_answer(question, long_answer)
65 return long_answer, short_answer
66
67 def predict_hotpotqa(self, context, question, titles):
68 prompt = (f"Go through the following context and then answer the question "

Callers 1

eval_qa.pyFile · 0.45

Calls 2

predictMethod · 0.95
extract_answerMethod · 0.95

Tested by

no test coverage detected