Skip to content
Embedding Space

Docs/Continuous learning

Continuous learning

vegaml-learn gives vega a learner that answers your questions from day one and keeps learning from every answer you confirm, on the machine it runs on. No fine-tuning, no GPU needed to learn, and no record leaves that machine.

Watch out

Free for noncommercial use only.

vegaml-learn is licensed under the PolyForm Noncommercial License 1.0.0. Personal projects, research, study and experiments are free, and so is use by charities, schools, public research bodies and government. Any use by or for a business needs a commercial licence: embedding.in/licence, or write to nandakishor@embedding.in. A company may try it for 30 days first. vegaml itself, the engine underneath, is Apache 2.0.

Install

bash
pip install vegaml-learn             # Learner, Escalator, vllm_teacher
pip install "vegaml-learn[serve]"    # REST server with JWT
pip install "vegaml-learn[proxy]"    # the vega Proxy, self-hosted
pip install "vegaml-learn[claude]"   # claude_teacher

It installs vegaml with it. Code written for vegaml 0.19 keeps working: once vegaml-learn is installed, from vegaml import Learner resolves to this package, and so does from laya import Learner.

Start

python
from vegaml_learn import Learner

questions = {
    "team": {"type": "choice", "instructions": "Which team handles this ticket?",
             "criteria": {"billing": "payments, refunds, invoices",
                          "technical": "bugs, errors, outages",
                          "sales": "pricing, plans, new accounts"}},
    "urgent": {"type": "boolean", "instructions": "Does this need a reply today?"},
}

learner = Learner(questions, workdir="./vega-state")       # loads vega; resumes from workdir

out = learner.decide("I was charged twice this month")
out["answers"]["team"]["answer"], out["answers"]["team"]["confidence"]

# whenever the right answer is known (your team fixed it, the customer confirmed it):
learner.feedback("I was charged twice this month", {"team": "billing", "urgent": False})

It learns every 50 confirmed answers, in a background thread, and switches to the new version between requests. Nothing waits for it.

How it learns

  • Every question gets a small head: a classifier over vega's frozen features. vega itself never changes, so learning takes a few seconds and is not a fine-tune.
  • A head answers only when its cross-validated accuracy, and its balanced accuracy (the mean recall per answer), beat vega's own answer on the same rows. The balanced bar stops a head that always gives the common answer from taking over a question where the other answer is rare. Until then vega answers, with its calibrated probabilities and abstain flag. Every answer says which one answered, in readout ("head" or "engine").
  • Your answers replace the starting set one for one, so after a few hundred it is fitted on your decisions alone.
  • A batch the current heads agree with far less than they agree with your answers so far (a broken feed, or a real change of policy) is held, not learned. You decide: learner.held(), learner.accept(question) or learner.discard(question).
  • learner.undo() goes back one step.

A starting set

Give it labelled examples and it starts with a fitted head instead of vega's zero-shot answer.

python
rows = [("I was charged twice", {"team": "billing", "urgent": False}),
        ("The app crashes on login", {"team": "technical", "urgent": True}),
        ...]
learner = Learner(questions, examples=rows, workdir="./vega-state")
learner.report        # per question: rows used, cross-validated accuracy, vega alone on the same rows

Labels are read the way people write them: an option name, True, "yes", "no", or a level.

Measured across 14 decision templates, starting from about 600 generated examples each and then learning from confirmed answers on 60 held-out rows: 85% right on day one, 92% after 40 confirmed answers, 96% after 120.

A teacher for what it is unsure of

When nobody confirms answers by hand, give the learner a teacher: a person's review queue, a rules engine, or a large model. Escalator sends the teacher only what vega is unsure of, serves the teacher's answer, and learns from it. The share that needs the teacher falls as vega learns.

python
from vegaml_learn import Escalator, Learner, vllm_teacher

# vllm serve Qwen/Qwen3.8-27B --served-model-name teacher --max-model-len 8192
learner = Learner(questions, workdir="./vega-state")
desk = Escalator(learner, teacher=vllm_teacher("http://localhost:8000/v1"))

out = desk.decide("I was charged twice this month")
out["answers"]["team"]["source"]        # "teacher" while vega is learning, "vega" once it is sure
out["answers"]["team"]["escalated"]     # why: "abstain", "unbound", "below line" or "audit"
desk.report()["teacher_share_recent"]   # the share of the last 100 records the teacher still saw

vllm_teacher() asks a model you serve yourself, with vLLM or any OpenAI-compatible server (SGLang, llama.cpp server, Ollama, LM Studio). Nothing leaves your machines and there is no cost per call. claude_teacher() asks Claude instead: the record and the escalated questions go to Anthropic's API and nothing else does.

Any function works as the teacher. teacher(text, {question id: question}) returns {question id: answer}, written the way you would write feedback. A teacher that raises or returns something unusable is skipped: vega's own answer is served and nothing is learned from that record.

Who goes to the teacher:

  • an engine answer that abstains or is unbound (on_engine=("abstain", "unbound"); drop "unbound" where it fires on answers that are already right);
  • a head answer below its question's line (line=0.8), because a head carries no abstain flag;
  • a random share of everything else as an audit (audit=0.05).

Where the line sits is measured. It is the lowest confidence above which vega agreed with the teacher at least 95% of the time (trust), over at least 30 checked answers. As vega learns, the line comes down by itself. If the policy changes, audits catch the disagreement and it goes back up.

Note

Pick a teacher clearly better than vega.

vega learns up to its teacher, not past it. Audits measure agreement with the teacher, so they cannot catch a teacher that is wrong. The last row of the table below is what that looks like.

Measured

One stream of 3,000 assistant-intent records (MASSIVE, 60 intents), in arrival order. vega with the 0.8B reader and no starting set. Gold labels only score: neither vega nor the teacher sees them.

records seen5001,0001,5002,0002,5003,000
sent to the teacher (last 250)64%54%52%56%50%43%
vega alone right (held out)72%75%82%85%84%85%
vega + teacher right87%81%86%84%86%86%

With Claude Opus 5 as the teacher, vega alone went from 35% to 85%, about level with the combined answer, and the share sent to the teacher fell from 100% to 43% and was still falling. It did not reach zero in 3,000 records.

The same stream with different teachers:

teacherteacher alonevega alone at the endvega + teacherstill sentAPI cost
Claude Opus 5about 87%85%86%43%$14.09
Claude Haiku 5.5about 85%83%86%47%$0.33
Qwen3.8-27B on your own GPU83%79%83%40%none
Qwen3.5-4B on your own GPU (vega with the 4B reader)74%72%73%45%none
Qwen3.5-0.8B on your own GPU3%3%3%33%none

A served 27B model teaches nearly as well as Claude with nothing leaving your machines. A teacher worse than vega teaches it to be wrong: the 0.8B model, right 3% of the time on 60 intents, took vega from 35% down to 3%.

Across 12 public decision tasks of 400 records each, vega learned the teacher's policy on 7 with no labels from anyone. On tasks where the answer that matters is rare (jailbreaks are 2% of the stream), no head beat vega's own engine, so the engine kept answering and the teacher kept being asked. The full table is in the vegaml docs.

Landscape learning

Opt in with VEGA_LEARN_HEAD=landscape. Each answer gets a well in vega's energy landscape, placed from its confirmed examples, and the answer is the well the input settles in. Nothing is iterated, and no fit grows with the examples stored.

Measured against the default head on the same features: level on questions with a few answers, behind by 2 to 9 points on questions with 60 to 100 answers until it has several hundred examples, and faster to fit only past about a thousand examples (0.6 s against 4.8 s at 3,000). Use it for long-running learners on questions with few answers. What a learner has stored works with both, so switching back loses nothing.

Saved state, more machines

  • workdir keeps the last three versions and is picked up on the next start, as long as the questions, the starting set and the vega checkpoint are the same. Call learner.flush() before shutting down to learn what is buffered.
  • One writer learns and any number of read-only copies answer: Learner(questions, workdir=shared, follow=30) reloads the writer's newest state every 30 seconds and refuses feedback.
  • learner.save_bundle("acme.zip") writes what it has learned as a file another machine starts from: Learner(bundle="acme.zip").

REST API with JWT

bash
pip install "vegaml-learn[serve]"
export VEGAML_LEARN_JWT_SECRET="$(openssl rand -hex 32)"
python -m vegaml_learn serve --questions questions.json --examples examples.csv \
       --workdir ./vega-state --host 0.0.0.0 --port 8000
python -m vegaml_learn token --subject helpdesk --scope decide feedback --days 30

examples.csv has a text column and one column per question. Tokens are HS256 with the shared secret, or verified with your identity provider's public key (--jwt-public-key key.pem). Every token needs exp and its scopes.

scoperoutes
decidePOST /v1/decide, POST /v1/decide/batch, GET /v1/questions
feedbackPOST /v1/feedback
adminGET /v1/status, POST /v1/learn, GET /v1/held, POST /v1/held/{q}/accept, POST /v1/held/{q}/discard, POST /v1/undo

GET /healthz needs no token.

Cost and limits

Measured on 8 CPU threads with the 0.8B reader: 0.72 s an answer, 6.4 GB of RAM at peak, and 34 s to learn from 300 answers. On a GPU, about 40 ms an answer in 2 GB.

  • The heads are only as good as the answers you confirm. A wrong feed is caught when it disagrees sharply with what was learned, not when it is slightly wrong.
  • A head knows the options it has seen confirmed. An option nobody has confirmed yet is answered by vega until it has examples.
  • A head's confidence is its probability, not a calibrated one. Gate on readout == "engine" answers if you need vega's calibrated abstain flag.

Where next