(self, question, demo_file_path, num_demo=16)
| 43 | return response |
| 44 | |
| 45 | def predict_close_book(self, question, demo_file_path, num_demo=16): |
| 46 | demo = load_json_file(demo_file_path) |
| 47 | prompt = ("Here are some examples of questions and their corresponding answer, each with a 'Question' field and an 'Answer' field. " |
| 48 | "Answer the question directly and don't output other thing. ") |
| 49 | for item in demo[:num_demo]: |
| 50 | prompt += f"Question: {item['question']} Answer: {item['short_answers'][0]}\n" |
| 51 | prompt += f"Question: {question} Answer: " |
| 52 | answer = self.predict(prompt) |
| 53 | return answer |
| 54 | |
| 55 | def predict_nq(self, context, question, titles): |
| 56 | titles = ['"' + title + '"' for title in titles] |
nothing calls this directly
no test coverage detected