ChainOfThought extends a task signature with a rationale or reasoning output, then uses a Predict module to make one language-model call. Placing that field before the task’s other outputs requests reasoning first; the generated rationale may affect later outputs. section 7.3.1
When ChainOfThought is used with an optimizer:
- The module remains ChainOfThought; optimization can add demonstrations or improve instructions without changing its input or output fields. section 5.2.3
- Training examples need not supply rationales. Demonstrations can mark the missing reasoning output as “Not supplied for this particular example.” section 5.2.3
prog = ChainOfThought( "question -> answer", rationale_field=dspy.OutputField(desc="Think hard and slowly"), rationale_field_type=dspy.OutputField) prog(question="How would you describe the work of Sartre?")
This example customizes the rationale field’s prompt description and applies ChainOfThought to a question-and-answer task. section 7.3.1
