# Learned answers

> Curva learns a question from your labels and then answers it by itself, in microseconds and at no cost, only where it is as accurate as the model, and stops when new labels disagree.

Source: https://docs.tarkova.com/curva/guides/learned/

## How it works, step by step

1. **Keep the states** (learn=True, 2,000 bytes, 180 days): Curva does not keep decision states unless a request sends learn. Only those decisions can train a learned answer, so send it from the start. Questions with depends_on, and requests with images, assets or sources, always go to the model. In the example: A test sends clearly positive or negative product reviews with learn and learned on. The model is a stand-in that answers yes to everything, so it costs nothing.
2. **Collect labels** (feedback, 200 labels, Both answers): One question in one project needs at least 200 labels on kept states, with both answers among them. A reworded question starts again, and each project learns alone. In the example: 250 reviews are labelled, and the stand-in was right on half of them.
3. **Train** (Every minute, Embeddings, Inside server): Once a minute, if new labels came in, the server trains a small model of its own on embeddings of the state's text. Every fifth label of each answer is held back for the next step. In the example: Training finishes 62 seconds after the last label.
4. **Compare with model** (Held-back labels, Baseline, Must match): The learned model's accuracy on the held-back labels must reach the LLM's accuracy on the same question's labels. Below that, it never answers. In the example: The stand-in was right half the time, so the bar is low here. A more accurate model sets a higher one.
5. **Shadow** (30 decisions, Agreement, Model answers): For its next 30 decisions where it is sure enough, the learned model runs beside the LLM and how often they agree is recorded. Your app still gets the LLM's answer, and you still pay for that call. In the example: The next 30 decisions shadow, agreeing with the stand-in on 15.
6. **Switch on** (min_confidence, target_accuracy, 0.9 default): After shadowing, it answers when it is at or above the question's min_confidence, or the threshold target_accuracy has earned, or 0.9 when the question has neither. A target_accuracy with no earned threshold keeps it silent. In the example: The question sets neither, so the bar is 0.9.
7. **No model call** (answered_by, learned_us, by: learned): A sure answer comes back with answered_by: "learned" and no model call. Anything else goes to the LLM as before, so some answers to a question are learned and others come from the model. In the example: The next 200 reviews are all answered locally and all right, in 10 µs at the median and 30 µs at p95. This shows the mechanism on an easy set, not an accuracy rate on yours.
8. **Turn itself off** (New labels, Retrain, Back to shadow): Each retrain tests the kept model on the newest labels. If its sure answers are clearly less accurate than the LLM was, its shadow count resets, and it answers again only after 30 more decisions beside the LLM. In the example: That live run stopped before this step. An automated test covers it: labels that disagree send the question back to shadowing.

```python

d = curva.decide(review, {"good": "Is this review positive?"}, learn=True, learned=True)
curva.feedback(d.id, "good", True)    # the true answer, as usual
d["good"].answered_by                 # "learned" once Curva answers this question by itself
```

Send `learn=True` and `learned=True` and keep sending [feedback](/curva/guides/feedback/). Once a question has
enough labels, Curva trains a small model of its own on them, inside your server. When that model
is at least as accurate as the LLM on the same labels and sure of the answer, Curva answers by
itself: no model call, `cost_usd` 0, a few microseconds. Everything else goes to the model as
before.

HTTP: `"learn": true, "learned": true`. TypeScript: `{ learn: true, learned: true }`. To turn it on
for every request, start the server with `curva serve --learned` (a request can still send
`"learned": false`).

## The rules

1. **It learns only from states kept by `learn`.** Curva does not keep decision states unless a
   request asks it to with `learn` ([learn by example](/curva/guides/feedback/#learn-by-example)). Decisions sent without
   `learn` cannot be learned from, so send `learn=True` from the start.
2. **It needs at least 200 labels, with both answers among them**, for one question in one
   project. A reworded question is a new question and starts again. Each project learns alone.
3. **It must beat the model.** Curva holds back every fifth label, trains on the rest, and compares
   its accuracy on the held-back labels with the model's accuracy on the same question's labels.
   Below the model, it never answers.
4. **It shadows the model first.** Once trained, it answers beside the model for 30 decisions where it was sure enough and the
   question also went to the model, without changing them, and how often it agreed is recorded. Only then does it answer by itself.
5. **It answers only when it is sure enough**: at or above the question's `min_confidence`, or the
   threshold its [`target_accuracy`](/curva/guides/promise/) has earned (none earned yet: never), or 0.9 when the
   question has neither.
6. **It turns itself off.** It retrains every minute when new labels came in. When its answers to the
   newest labels are clearly less accurate than the model was, it goes back to shadowing, and
   comes back only after 30 more decisions beside the model.

Labels on answers Curva gave by itself train the learned model, but never the model's own
[calibration](/curva/guides/feedback/) or promised accuracy.

Questions with `depends_on`, multi-choice and text, number or box questions always go to the
model, and so do requests with `images`, `assets` or `sources`. Today it learns from the state's
text.

## See it

The [dashboard](/curva/guides/dashboard/) shows **Answered by Curva itself**, the share of decisions it answered
alone, and **Saved by answering itself**: those decisions times what a model decision costs on
average. `GET /v1/summary` has the same under `learned`, with each learned question's shadow count
and agreement. Each answer it gave says `answered_by: "learned"`, and the decision has
`model: "learned"` and `learned_us`, the microseconds it took.

## What was tested

Live on 20 October 2026, on a local server with a stand-in model that answers "yes" to everything
(so it cost nothing and was right half the time), 250 clearly positive or negative product reviews
were labelled. Curva trained 62 seconds after the last label, shadowed the next 30 decisions
(agreeing with the stand-in on 15), then answered all of the next 200 by itself, all 200 right,
in 10 µs at the median and 30 µs at p95, with no model call. That shows the mechanism on an easy
set, not an accuracy rate on yours.
