dspy-rlm

Installation
SKILL.md

Iterative Self-Refinement with dspy.RLM

Guide the user through using DSPy's RLM (Recursive Language Model) module. RLM lets the LM explore data programmatically in a sandboxed Python REPL, writing code to examine inputs, querying sub-LMs for semantic analysis, and iterating until it produces a final answer.

Experimental. RLM is marked as experimental in DSPy. The API may change in future releases.

Step 1: Gather context

Before building with RLM, clarify:

  1. What data will the LM explore? Large text corpus, log files, structured data dumps, multi-document collections?
  2. What kind of answer do you need? Free-text summary, structured extraction (counts, lists), or a specific value?
  3. Does the task need external tools? If the LM needs to call APIs or databases during exploration, you can pass custom tool functions.
  4. What LM are you using? RLM works best with strong reasoning models (GPT-4o, Claude Sonnet) as the main LM; cheaper models can handle sub-queries.

What is RLM

dspy.RLM implements the Recursive Language Models approach (Zhang, Kraska, Khattab 2025). Instead of feeding the full input context into the LM's prompt, RLM:

Installs
6
GitHub Stars
11
First Seen
Mar 17, 2026
dspy-rlm — lebsral/dspy-programming-not-prompting-lms-skills