Created
January 11, 2024 18:55
-
-
Save heathermiller/27f656ef3d0aab34a0e27e7061e81bef to your computer and use it in GitHub Desktop.
DSPy 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the predictor. Notice we're just changing the class. The signature BasicQA is unchanged. | |
generate_answer_with_chain_of_thought = dspy.ChainOfThought(BasicQA) | |
# Call the predictor on the same input. | |
pred = generate_answer_with_chain_of_thought(question=dev_example.question) | |
# Print the input, the chain of thought, and the prediction. | |
print(f"Question: {dev_example.question}") | |
print(f"Thought: {pred.rationale.split('.', 1)[1].strip()}") | |
print(f"Predicted Answer: {pred.answer}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment