* Docs: the check, exactly as the code does it docs/CHECK.md: test moments, who answers, who judges (the original weights, no adapter), the question asked, win/loss/tie, the decision (drift, wins > losses, health, looping), which notes leave, what the dashboard shows. DESIGN 3.5 described the older KL gate; it now matches the code. README's Checking line links the page. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Docs: only a real moment's guide is cut to 600 characters; the result is cycle.result Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RCtP49ftEWF4mdBpvTZVby * Docs: a Deep Dream trains on one test moment; the check refuses it under min_heldout Co-Authored-By: Claude Opus 5.5 <[email protected]> * Docs: the fallback rule counts measured moments, not conversations Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: JIxuan Wang <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Frank Wu <[email protected]>
7.3 KiB
The check: when a Deep Dream is used
A Deep Dream trains a LoRA adapter. Before it is served, Songe checks it against the version in use, on moments from your own conversations. This is a check on your moments, not a benchmark: it says whether the new version does better for you than what you have now, nothing about the model in general.
This page describes the code on main: src/songe/sleep/judged.py,
sleep/gate.py, sleep/evaluate.py, and the wiring in sleep/worker.py.
Defaults are in src/songe/config.py.
Test moments
- Real moments. Every recorded moment that something followed (your next
message, a tool result). Under the default
learning = "dreams", real conversations are never trained on, so each of these is a fair test. Up to 3 per conversation, picked by a hash of their id so the same ones come back every Dream (practice/pool.py,gate_moments). - Held-out practice. Practice scenes of lessons kept out of training
(about one lesson in five, plus more when the test set is short). They
fill the test set up to
min_heldout(5). - At most 24 moments are judged per Dream (
MOMENTS), every conversation or lesson getting one before any gets more. - A Deep Dream starts with one test moment (under
learning = "dreams",practice/pool.pydream_minimums;sleep/worker.pywaits only with none). It trains, and the check then refuses the candidate while it has fewer thanmin_heldout(5) measured moments ("Waiting for held-out experience",sleep/gate.pydecide), unless the judged moments already refused it.
Who answers
At each moment both versions answer from the context alone, greedy, up to 384 tokens, the way you would be served:
- the version in use, with all the Quick Dream notes now in the prompt;
- the new version, with only the notes that would stay if it were adopted (see "Which notes leave" below).
Who judges
The judge is your own model's original weights, with no adapter, loaded
in Songe's training backend (MLX or PyTorch). It is neither the version in
use nor the candidate, and it is not a cloud model. Thinking is switched off
where the chat template allows it, and the reply is started for it as
{"follows": ", so only yes or no is left to write (48 tokens at most).
The question
Each answer is judged on its own; the judge never sees the two side by
side and is never asked which it prefers. The prompt (DOES in
sleep/judged.py) gives:
- the request: the last user message before the moment (600 characters at most);
- the guide: for a real moment, the first message you wrote after it (600 characters at most); for a practice scene, its lesson, in full;
- the answer: its visible text without reasoning, plus any tool calls as
name(arguments)(1,500 characters at most).
and asks:
Does this answer do what the feedback asks? Judge only that, not whether the answer is long, complete or helpful.
Win, loss, tie
- Two answers that are the same action as written (same tool calls and arguments, same visible text, whitespace aside) are a tie without asking the judge.
- Win: only the new version's answer follows the guide.
- Loss: only the answer in use follows it.
- Tie: both follow it, neither does, or a reply cannot be read as yes or no.
Ties count for neither side. The teacher's preference is never used to break a tie, because training pulls the candidate towards it.
The decision
The candidate is tried at full strength, then at half (wake_scales
(1.0, 0.5)); the first strength that passes everything is used. For each
strength, in order:
-
Drift. The mean per-token KL divergence of the candidate from the original model, on answers the original model wrote, must stay at or below
general_drift_limit(0.05 nats per token). It is measured on your confirmed successes (moments the model already got right, never trained on, up to 48) once they come from at least 10 conversations (min_drift) and their 95% bootstrap interval is narrower than the limit; until then, on 150 bundled general prompts (src/songe/sleep/anchors.json). -
Judged moments. The candidate must win more moments than it loses (
wins > losses). The code also names a candidate "worse than what you have now" whenlosses - wins > 1.64 * sqrt(losses + wins); withwins > lossesrequired, that only changes the reason shown. -
Answer health, from one sampled answer per moment, each version:
- tool-call validity at moments where the logged action was a tool call (the call parses, names a known tool, and its arguments fit the tool's schema) must not drop;
- the share of empty answers must not rise.
Both use a paired bootstrap over conversations at 95%: only a significant change refuses. Then, looping: an answer with half or more of its 4-word phrases repeated is looping; the candidate is refused if it has more looping answers than the version in use by more than 1, or 10% of the moments, whichever is larger. A model whose tool-call format Songe cannot read is refused.
On model servers that serve a merged copy (LM Studio, Ollama), the merged model is measured again (drift and health) before it is used, with the judged outcomes carried over.
If the backend cannot answer the judge's questions, the older rule decides
and the record says judged_error: the KL to the teacher on the test
moments must fall by more than its bootstrap noise, over at least 5
measured moments (min_heldout).
Which notes leave
When a version is adopted, a Quick Dream note leaves the prompt only if the
new version follows its lesson without it (judged.learned). On up to 3 of
the lesson's held-out practice scenes, it answers (128 tokens) with the
other notes in the prompt and without this one. The original weights then
compare that answer with the teacher's stored answer (written with the
note), in both orders, using the practice check's question (CHANGES in
practice/prompts.py). An answer passes if the judge says it follows the
note, alone or with the other, in at least one order; the same action as the
teacher's passes without asking. Every scene must pass. A lesson with no
held-out scene keeps its note.
A note that passed still stays if the candidate, served without it, lost at
a moment from that lesson's own conversation (judged.kept_back); the
moments are then judged again with that note back in.
Not counted
Each version also answers up to 8 confirmed successes the lessons are not
about. How often the candidate acts differently there is kept in the record
(unrelated_actions) and decides nothing.
What the dashboard shows
The Check stage of a Deep Dream (cycle.checks):
- Better where you gave feedback: "Better on N, worse on M, same on K".
- Didn't change what it already did right (confirmed successes) or Didn't change how it answers in general (bundled prompts): the drift before and after, against the 0.05 limit.
- Answers stayed healthy: passed, failed, or not reached.
The result (cycle.result, with cycle.dream_report as its report)
shows whether the version was adopted, up
to 3 moments it won as before/after examples (real conversations first), for
each habit how many answers followed it before and after at its own judged
moments, which notes left, and for each strength refused the reason with
its better/worse counts and drift.