dsir
Program—don't prompt—language models in Rust.
dsir is a DSPy-shaped library for building composable LM pipelines: typed signatures, modules (Predict, ChainOfThought, ReAct, agents), evaluation, and self-improving prompts (few-shot bootstrap + instruction search). Runtime programs use DynSignature, ProgramGraph, and the self-improvement lab.
Install
[]
= "0.1.1"
= { = "1", = ["full"] }
Requires latest stable Rust (see rust-toolchain.toml).
Quickstart
use ;
/// Answer questions accurately and concisely.
async
Library surface
| Area | Types |
|---|---|
| Signatures | Signature, #[derive(Signature)], DynSignature (JSON / string DSL) |
| Modules | Predict, DynPredict, ChainOfThought, ReAct, Agent, BestOfN, Refine |
| Graphs | ProgramGraph, StrategyFactory, StructuralOptimizer |
| Optimize | LabeledFewShot, BootstrapFewShot, COPRO, MIPROv2, GEPA (+ compile_dyn) |
| Evaluate | TypedMetric, DynMetric, Evaluate, evaluate_trainset |
| Lab | Lab, local/remote registry, promote/compare |
| Persist | save_program / load_program, GraphState |
Optimizers at a glance
| Optimizer | Best for |
|---|---|
LabeledFewShot |
Fast demo assignment from labeled data |
BootstrapFewShot |
Self-improvement from successful traces |
COPRO |
Quick instruction search, limited compute |
MIPROv2 |
Best instruction quality, 15+ examples |
GEPA |
Tasks needing textual feedback |
See optimizers overview.
Examples
| Example | Command | Notes |
|---|---|---|
| Predict | cargo run -p dsir --example 01_predict |
Live LM |
| Chain of thought | cargo run -p dsir --example 02_cot |
Live LM |
| Bootstrap | cargo run -p dsir --example 04_bootstrap |
Offline |
| Lab | cargo run -p dsir --example 05_lab |
Offline |
| Program graph | cargo run -p dsir --example 06_graph |
Offline |
Companion binaries: dsir-registry (HTTP run registry), dsir-lab-ui (experiment dashboard).
Documentation
Documentation hub — user guides and architecture notes.
Quick links:
Maintainer docs: goals, architecture, roadmap.
License
Apache-2.0. See LICENSE and NOTICE. Core LM pieces adapted from DSRs; see vendor notes.