Open source · local-first · deterministic scoring

Loopr — A Self-Improving Prompt-Optimization Loop That Runs on Local Models

Loopr is an open-source prompt-optimization loop. Give it a task prompt and a handful of eval cases; it runs the prompt, scores every output with a deterministic scorer, reflects on the failures in plain language, rewrites the prompt, and repeats until it converges on the best-scoring version. It runs locally on Ollama, with OpenAI or Anthropic as an optional fallback.

Try it live ↓View on GitHub

Watch a prompt improve itself

Pick a task and step through the loop. This panel replays runs captured on a local Ollama model; scoring and the stop decision are deterministic, so the same task always converges the same way.

Loopr · prompt-optimization loopreplay of a real local run · deterministic
TaskClassify a support message as exactly one of refund / shipping / technical / billing / other.
Scorerexact
What does this user want?
{input}

What Loopr gives you

The answer to “which prompt actually works best for this task?”, produced by a loop instead of by hand.

Scorers

  • exact — the output must equal the expected value
  • contains — the output must include the expected text
  • regex — the output must match a pattern
  • json_field — the output must parse as JSON and a named field must match
  • llm_judge — a model grades the output when no exact rule fits

Stop conditions

  • converged — the score reached the target
  • plateau — no improvement for a set number of iterations
  • budget — the iteration budget is spent
  • Safe rewrites — if a rewrite cannot be parsed or drops the {input} placeholder, Loopr keeps the current prompt

How does Loopr work? Run → score → reflect → rewrite

The model only runs the task and phrases the reflection. Scoring and stopping are plain code.

1 · Run

LLM

The candidate prompt is executed on every eval case in the task file.

2 · Score

deterministic

A scorer grades each output from 0 to 1. The best-scoring prompt so far is kept.

3 · Reflect

LLM, GEPA-lite

The failures are handed back to the model, which diagnoses what the prompt is missing and proposes a better one.

4 · Rewrite

loop

The new prompt becomes the next candidate, and the loop repeats until it converges, plateaus or runs out of budget.

What has been measured

  • 0% → 100% in one iteration — on a JSON-extraction task with local qwen2.5:14b. The seed prompt “Extract info from this bio.” produced no parseable JSON; Loopr diagnosed the missing format constraint and rewrote the prompt itself.
  • 28-case pytest suite — gates the deterministic core: scorers, stop decisions and the rewrite guard.
  • Reproducible runs — for a fixed model, because scoring and the stop decision never depend on the model.

Limits, stated plainly

  • The panel on this page replays recorded runs. To run the loop live, install Loopr and use `loopr serve` or `loopr optimize <task.yaml>`.
  • A prompt tuned on a handful of eval cases is only as good as those cases. Too few cases and the prompt can fit them without generalising.
  • The demo result is one task on one model. It is not a benchmark across tasks or models.
  • The llm_judge scorer brings model judgment back into scoring, so runs that use it are less reproducible than the four rule-based scorers.

Frequently Asked Questions

What is Loopr?

Loopr is an open-source prompt-optimization loop. Give it a task prompt and a handful of eval cases; it runs the prompt, scores every output with a deterministic scorer, reflects on the failures in plain language, rewrites the prompt, and repeats until it converges on the best-scoring version. It runs locally on Ollama, with OpenAI or Anthropic as an optional fallback.

How is Loopr different from MLflow, Opik or LangWatch?

Those are hosted evaluation platforms with accounts and dashboards. Loopr is a small local tool: a pip install, a YAML task file, and a loop that runs offline on Ollama. It does one job, evolving a prompt against eval cases, and it is not a platform you have to adopt.

Do I need an API key to run Loopr?

No. It runs on a local Ollama model by default. If you set an OpenAI or Anthropic key, it can use those as a fallback.

What does a Loopr task look like?

A YAML file with a seed prompt, a scorer, an iteration budget and a list of eval cases with inputs and expected outputs. You run it with `loopr optimize <task.yaml>` and get a trace of every iteration.

Can a bad rewrite break my prompt?

No. The best-scoring prompt is always kept, and if a rewrite cannot be parsed or loses the {input} placeholder, Loopr discards it and continues with the current prompt.