liveBook · Manning

ProgramOfThought module

As explained in Building LLM Applications with DSPy

ProgramOfThought is a DSPy module that prompts a language model to generate and execute Python code as part of producing a response.

ProgramOfThought is a DSPy module that prompts a language model to write Python code for a response, executes the code with retry logic, and returns its output. section 2.6

It takes a signature, such as question-to-answer, and can be swapped independently of that signature. DSPy executes modules through forward() internally; explicitly calling forward() produces a warning as of DSPy 3.0. section 2.6

prog = dspy.ProgramOfThought("question -> answer")
prediction = prog(question="What is 8383.33 times 8228.11?")

A question-to-answer ProgramOfThought call using a multiplication question. section 2.6

How Building LLM Applications with DSPy covers it

How deep it goes
Explains prompt generation, Python execution, retry logic, and returned output.
Examples
Demonstrates a question-to-answer signature with a multiplication question.
What you can do after
Apply it via DSPy to answer questions using generated and executed Python code.
How it connects
Connects DSPy signatures and modules with language-model prompting and Python execution.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building LLM Applications with DSPy. The section links point to the parts of the book it draws on.