Skip to content

Commit

Permalink
Merge pull request stanfordnlp#579 from SimonB97/patch-1
Browse files Browse the repository at this point in the history
Update ProgramOfThought.md: Example
  • Loading branch information
arnavsinghvi11 authored Mar 11, 2024
2 parents e4e817a + fdef4bd commit 734a345
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions docs/api/modules/ProgramOfThought.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,18 @@ Main method to execute the code generation and refinement process.

```python
#Define a simple signature for basic question answering
generate_answer_signature = dspy.Signature("question -> answer")
generate_answer_signature.attach(question=("Question:", "")).attach(answer=("Answer:", "often between 1 and 5 words"))
class GenerateAnswer(dspy.Signature):
"""Answer questions with short factoid answers."""
question = dspy.InputField()
answer = dspy.OutputField(desc="often between 1 and 5 words")

# Pass signature to ProgramOfThought Module
pot = dspy.ProgramOfThought(generate_answer_signature)
pot = dspy.ProgramOfThought(GenerateAnswer)

#Call the ProgramOfThought module on a particular input
question = 'Sarah has 5 apples. She buys 7 more apples from the store. How many apples does Sarah have now?'
result = pot(question=question)

print(f"Question: {question}")
print(f"Final Predicted Answer (after ProgramOfThought process): {result.answer}")
```
```

0 comments on commit 734a345

Please sign in to comment.