dspy-infer-rules

Installation
SKILL.md

Extracting Decision Rules with dspy.InferRules

Guide the user through using dspy.InferRules to discover explicit, human-readable rules from labeled examples and inject them into program instructions.

What is dspy.InferRules

dspy.InferRules is a DSPy optimizer that analyzes your training examples and extracts natural-language rules describing the decision patterns it finds. These rules are then appended to the instructions of each predictor in your program. The result is a compiled program whose prompts contain explicit, interpretable decision logic -- not opaque few-shot examples.

It inherits from BootstrapFewShot, so it first bootstraps demonstrations and then goes further by inducing rules from those demonstrations.

Key properties:

  • Extracts human-readable rules -- the discovered logic is plain English, not weights or embeddings
  • Builds on BootstrapFewShot -- bootstraps demonstrations first, then induces rules from them
  • Generates multiple candidates -- creates several rule-enhanced programs and picks the best one on a validation set
  • Enhances instructions -- appends discovered rules directly to each predictor's signature instructions
  • Gracefully handles context limits -- iteratively removes examples if they exceed the LM's context window

When to use InferRules

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