We built one program and took it the whole way: a signature, a prediction we could inspect, tests without a model, a tool, a two-stage module, a baseline, an optimizer, a saved file, and a supervised server. From here, follow the task in front of you.
Coming from DSPy
Coming from DSPy maps DSPy's names to Imp's and says where the two differ.
Keep the common calls at hand
The cheatsheet has the calls from this guide, and a few more, on one page.
Go deeper on a piece
Each page in Diving deeper takes one idea from this guide and explains why it works the way it does:
- Signatures: types, constraints, and how a signature is checked.
- Modules and composition: the built-in modules, and writing your own.
- RLM: inputs too large for a prompt, explored with code and a sub-model.
- Adapters: how a signature becomes messages, and a reply becomes fields.
- ReAct: how the agent loop runs and ends.
- Tools and MCP: tools, policies, and MCP servers.
- Retrieval: retrievers, retrieval before a prediction, and search as a tool.
- Metrics and evaluation: metrics beyond exact match, and reading an evaluation.
- Choosing an optimizer: which optimizer for which task, and what each costs.
- Saving and artifacts: saved programs, and saving only what an optimizer learned.
- Runs and supervision: runs you can observe, authorize, and cancel.
- Settings and context: defaults,
Imp.context/2, and explicitlm:.
The module documentation is the reference for every function.
Run it in production
Running Imp in production covers what the last page began: supervision, provider failures, runs you can observe and cancel, and telemetry. The deployment example is a complete application to copy from.
Try it in a notebook
The tutorials are Livebook notebooks that run the same ideas, offline or with a key: 01 the first calls, 02 the exact messages with a scripted model, 03 evaluation and optimization, 04 tools, agents and RLM, and 05 operating Imp.