← mino.mobideepfates/imp

imp — measured

an independent evaluation · imp 0.5.0 · deepseek v4 flash · deepseek v4 pro · kimi k3

Imp is a port of DSPy to Elixir and the BEAM: you declare what a language-model call takes and returns, Imp writes the prompt and checks the reply, and an optimizer rewrites the program against examples of what good looks like. This site is one outside look at it — a series of runs across four models, every number reproducible from a committed rig, and everything that went wrong along the way.

GEPA teaches a model what it was never told

The task is Imp's own matched experiment (research/matched_instruction_optimizers_trec): route a TREC question to one of two opaque codes, K11 or K47. The program is never told what the codes mean. During optimization the metric's feedback on 20 training questions names the meanings; 40 selection questions return a score and nothing else; 80 held-out questions are scored at the end. A model that does not know the codes is at a coin flip, however strong it is — so whatever it gains is what GEPA taught it. GEPA runs the program, reads the failed runs, and has a second model (here DeepSeek V4 Pro) rewrite the instruction.

Held-out accuracy on 80 TREC questions, before and after GEPA, per model (DeepSeek from run imp-10, Kimi K3 from imp-04, Claude Sonnet from imp-14). One question is 1.25 points; these are single runs.
The same numbers as a table

A correction, and what it taught us. This page first reported DeepSeek V4 Flash going from 6.3% to 93.8%, and called most of the baseline misses format failures — replies with no route field. That was wrong. Every call then had a 2,048-token reply budget, and the DeepSeek models reason out of sight before they answer: on a question with no obvious answer the reasoning used the whole budget and nothing was left for the reply. Re-run with 8,192 tokens (run imp-10), Flash's baseline failures fell from 64 of 80 to 9 and its baseline rose to 46% — a coin flip, as it should be — and GEPA took it to 95%. The chart now shows those runs for both DeepSeek models.

The honest reading is the same for every model: a baseline at chance, and GEPA teaching it what the codes mean. Kimi K3 (50% → 94%) and DeepSeek Flash (46% → 95%) agree with the +40 Imp itself reports for gpt-5.4-mini (Imp RESULTS.md, R3). DeepSeek Pro reached 80 of 80; its baseline still lost 26 calls to time-outs and a crowded connection pool, so its starting point is understated.

Claude Sonnet 5 (47.5% → 96.3%, run imp-14) ran with no API key at all. Imp's language-model interface is one callback, so the rig gives it a model that shells out to the Claude Code CLI on the same subscription credential the build-a-bot runs on (bakeoff/imp/lib/claude_code.ex, about a hundred lines). Sonnet answered the questions and also wrote the reflections GEPA learned from.

What the optimizer wrote

The whole of what changed, per model: the instruction before, and the instruction GEPA selected. Nothing else in the program moved — no examples were added.

Tools: the part that already works

Imp.react/3 builds an agent from a signature and a list of tools. A tool is an ordinary Elixir function with a JSON schema; Imp checks the model's arguments against the schema before the function runs, and a failed check goes back to the model as an error it can correct:

Imp.tool(:refund_policy,
  "Refund window (days) and percent refunded for a product category and customer tier.",
  fn %{"category" => cat, "tier" => tier} ->
    %{"window_days" => window(cat), "percent" => percent(cat, tier)}
  end,
  schema: %{"type" => "object",
            "properties" => %{"category" => %{"type" => "string", "enum" => ~w(electronics apparel books furniture)},
                              "tier" => %{"type" => "string", "enum" => ~w(standard gold)}},
            "required" => ["category", "tier"]})

agent =
  "question -> answer: string, work: string"
  |> Imp.signature(instructions)
  |> Imp.react(tools, lm: lm, max_iters: 12)

We built two refund desks the agent can only see through such tools — customers, orders, a refund policy, dates, currency — and asked questions with exactly one right answer, computed by a reference solver from the same data the tools read. desk has six tools and 16 held-out questions; desk_hard has seven and adds the traps a real policy has: the policy version follows the order date, windows run from delivery, undelivered orders cancel for 100%, opened electronics pay a restocking fee, some questions scan every customer, and five currencies including yen.

Every model answered every question once the rules were stated (see findings for the one that wasn't). That is a result in itself — tool use over a well-specified policy is solved for these models — and the reason the optimizer test above had to find a task with something to learn. Here is one agent turn, as recorded: DeepSeek V4 Flash, asked for a customer's total refund. Steps with two calls are parallel tool calls the model made in one step.

1. find_customer({"email":"ben@example.com"})        → tier standard, country GB
2. list_orders({"customer_id":"C2"})                  → ["O-103","O-104"]
3. get_order(O-103)  ‖  get_order(O-104)              → $500 electronics · $30 books
4. days_since ×2  ‖  refund_policy ×2                 → 26 d, 7 d · 30 d / 90% · 14 d / 100%
5. convert({"amount_usd":480,"to":"GBP"})             → 379.20
6. submit({"answer":"379.20 GBP", "work":"…"})        ✓ expected 379.20 GBP

Every turn of every run:

Findings

in imp · reported upstream-ready

GEPA crashes on an improper list anywhere in a trajectory

Against real providers, GEPA died a minute in with FunctionClauseError in Enum.find_value_list/3 — twice, with and without generous timeouts. After every batch, GEPA walks all trajectories looking for an Imp.OperationalSafetyError. find_operational_safety/1 (in gepa/engine.ex and gepa/program_adapter.ex) recurses into anything is_list/1 accepts with Enum.find_value/2 — and is_list/1 is true for an improper list, which Enum.find_value/2 cannot walk. Real provider data carries one; a scripted model never does, which is why it passes offline.

It reproduces deterministically with no model at all — put an improper list in a metric's metadata:

metric = fn ex, pred -> base.(ex, pred) |> Map.put(:metadata, %{iodata: ["a" | "b"]}) end
Imp.optimize!(agent, Imp.Optimizer.GEPA.new(metric, reflection_lm: lm, max_metric_calls: 30), train, val)
#=> ** (Imp.Error) {:optimizer_failed, Imp.Optimizer.GEPA, %FunctionClauseError{module: Enum, function: :find_value_list, arity: 3}}

The fix is to walk cons cells, so an improper tail falls through to the catch-all clause:

-  defp find_operational_safety(list) when is_list(list),
-    do: Enum.find_value(list, &find_operational_safety/1)
+  defp find_operational_safety([head | tail]),
+    do: find_operational_safety(head) || find_operational_safety(tail)
+
+  defp find_operational_safety([]), do: nil

Every GEPA number on this site ran with that patch applied, and with the reproduction as a check that must pass first. Both are in the rig (bakeoff/imp/patch_imp.exs, checks/gepa_improper_list.exs). Worth knowing too: GEPA's default per-row and per-reflection time budgets are 30 seconds each, short for an agent whose run makes a dozen tool calls; we used five minutes.

in our rubric · fixed

A rule the answer key used and nobody was told

On its first run, desk_hard scored a returned order against "returned orders are not eligible" — a rule stated in desk's instructions and dropped from desk_hard's. Both models that ran lost that point. The rule now sits in the refund_policy tool's description, and the run that followed put all three models at 18/18. The lesson the bake-off already teaches: every rule the key applies must be written down where the agent can read it.

in configuration · fixed

Kimi K3 thinks, always

On the first run every Kimi call failed within seconds. Kimi K3 has thinking always on; sent temperature: 0 and a 2,048-token budget, it answered nothing. Without a temperature and with 16k tokens it scored 20/20 on routing and 18/18 on the hard desk — at roughly six times DeepSeek Flash's wall-clock time. Per-model options live in bakeoff/imp/models.json.

Runs

Each run is one commit of a sentinel file; one GitHub Actions runner per model; the evidence lands on a results branch and is imported here unedited.

How it's measured

Next

More runs of the same tasks to put error bars on single-run numbers, and other models as the bake-off adds them.