class BasicQA(dspy.Signature):
"""Answer questions with short factoid answers."""
question = dspy.InputField()
answer = dspy.OutputField(desc="often between 1 and 5 words")
これは内部でTemplateと呼ばれるものに変換されててこんな感じになる
py
(Pdb) print(template)
Template(Answer questions with short factoid answers., ['Question:', 'Answer:'])
これが__call__をもってるのでexampleを渡す
py
(Pdb) print(example)
{'demos': [], 'question': 'What is the nationality of the chef and restaurateur featured in Restaurant: Impossible?'}
(Pdb) print(template(example))
Answer questions with short factoid answers.
---
Follow the following format.
Question: ${question}
Answer: often between 1 and 5 words
---
Question: What is the nationality of the chef and restaurateur featured in Restaurant: Impossible?
Answer:
exapmle.demosに事例を追加するとこうなる
py
(Pdb) example.demos.append({"question": "SAMPLE_QUESTION", "answer": "SAMPLE_ANSWER"})
(Pdb) print(template(example))
Answer questions with short factoid answers.
---
Follow the following format.
Question: ${question}
Answer: often between 1 and 5 words
---
Question: SAMPLE_QUESTION
Answer: SAMPLE_ANSWER
---
Question: What is the nationality of the chef and restaurateur featured in Restaurant: Impossible?
Answer: