dspy-reasoning-modules

Solid

This skill should be used when the user asks to "use DSPy RLM", "process a very long context", "use ProgramOfThought", "use CodeAct", "run DSPy modules in parallel", mentions Recursive Language Models, sandboxed Python execution, Deno, `dspy.RLM`, `dspy.ProgramOfThought`, `dspy.CodeAct`, or `dspy.Parallel`, or needs to choose a DSPy reasoning module beyond Predict, ChainOfThought, and ReAct.

AI & Automation 78 stars 10 forks Updated 1 weeks ago MIT

Install

View on GitHub

Quality Score: 90/100

Stars 20%
63
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# DSPy Reasoning Modules ## Goal Choose the appropriate DSPy reasoning module for long-context exploration, code-assisted reasoning, or parallel execution. ## Module Selection | Module | Use it for | Important constraint | |--------|------------|----------------------| | `dspy.RLM` | Exploring very large contexts with iterative REPL code and recursive sub-LM calls | Experimental; requires Deno by default | | `dspy.ProgramOfThought` | Solving tasks by generating and executing Python | Requires Deno by default | | `dspy.CodeAct` | Combining generated Python with predefined tool functions | Functions only; requires Deno | | `dspy.Parallel` | Running `(module, example)` pairs concurrently | Tune threads and error handling | ## RLM for Large Contexts `RLM` treats long inputs as external data in a sandbox rather than placing the full context in each LM prompt. ```python import dspy dspy.configure(lm=dspy.LM("openai/gpt-4o")) rlm = dspy.RLM( "document, question -> answer", max_iterations=12, max_llm_calls=30, sub_lm=dspy.LM("openai/gpt-4o-mini"), ) result = rlm( document=very_long_document, question="What were the main revenue drivers?", ) print(result.answer) ``` Use `max_iterations`, `max_llm_calls`, and `max_output_chars` as explicit cost and output bounds. ## Sandboxed Execution The default `dspy.PythonInterpreter` uses Deno and Pyodide. It denies host filesystem, environment, and network access unless explicitly enabled. ```python from path...

Details

Author
OmidZamani
Repository
OmidZamani/dspy-skills
Created
5 months ago
Last Updated
1 weeks ago
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category