(self, question, demo_file_path, num_demo=16)
| 78 | return long_answer, short_answer |
| 79 | |
| 80 | def predict_close_book(self, question, demo_file_path, num_demo=16): |
| 81 | demo = load_json_file(demo_file_path) |
| 82 | prompt = ("Here are some examples of questions and their corresponding answer, each with a 'Question' field and an 'Answer' field. " |
| 83 | "Answer the question directly and don't output other thing. ") |
| 84 | for item in demo[:num_demo]: |
| 85 | prompt += f"Question: {item['question']} Answer: {item['short_answers'][0]}\n" |
| 86 | prompt += f"Question: {question} Answer: " |
| 87 | answer = self.predict(prompt) |
| 88 | return answer |
| 89 | |
| 90 | def generate_demo_examples(self, num_demo=4): |
| 91 | if num_demo == 0: |
nothing calls this directly
no test coverage detected