Skip to content

Decision-model judge for the answer guard and fact merges; training keeps the yes/no habit - #12

Merged
FMXExpress merged 10 commits into
mainfrom
claude/optimistic-allen-i3bd3d
Nov 7, 2026
Merged

FMXExpress merged 10 commits into
mainfrom
claude/optimistic-allen-i3bd3d

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

This PR adds a decision-model judge (Mem.Decide) that decides the answer guard and fact merges in place of rules, plus the benchmarks behind it. It also changes training so models keep answering yes/no questions with yes or no. These are the commits that came after #11 was merged; v0.4.0 does not include them.

The judge (memagent/Mem.Decide.pas, [judge] in the config)

A decision model, OpenJev-Flash-9B, runs beside the chat model. memagent reads it the way JevBan does: one forward pass, then the logits of the option letters give a calibrated probability, with no generated text. Questions, answers and facts go into its state as quoted JSON, never into the question it is asked.

  • Answer guard: an answer about the user's people is shown only if P(the turn's retrieved facts back it) ≥ guard_min (0.9). Statements skip the guard; there is no answer to check.
  • Fact merges: the rules still propose that a new fact replaces an old one, and the judge must agree (merge_min 0.9); otherwise both facts are kept. When the rules find nothing, the judge may also merge the closest similar fact, at P ≥ 0.97 (rescue_min) and never across DistinctSubjects.
  • Off by default. The launchers turn it on for GPU presets with a CUDA llama.cpp and 16 GB or more. On a CPU it adds about 11–35 s per decision. It downloads 5.6 GB once.

Results (bench/README.md)

Answer guard, on 120 answers the models really gave, 60 right and 60 wrong (bench/jev/):

Guard Right kept Wrong blocked Accuracy
Current rules 28/60 37/60 0.54
Same readout with the 1.5B chat model 44/60 23/60 0.56
OpenJev-Flash-9B, p ≥ 0.9 47/60 55/60 0.85

The judge got all 40 two-fact answers right. It is also well calibrated: every answer it scored below 0.1 was wrong, and every one it scored 0.97 or above was right. Routing the uncertain middle band to the rules did worse (0.80), so the guard withholds those answers.

Fact merges, on 75 labelled pairs. The 39 that must not merge are look-alikes, following Hightouch's write-up on LLM judges for identity resolution:

Merge policy Wrong merges (fact lost) Missed merges (duplicate)
Rules alone (before) 6 4
Rules + judge veto 0 4
+ judge rescue (the default) 0 0

Caveat: rescue_min and rescue_cos were tuned on the same 75 pairs.

Training keeps the yes/no habit

Deep sleep taught models to answer "Is my friend the one whose city is Porto? Answer yes or no." with "Your friend's city is Porto." After training, verify scored 0/24 at 1.5B and 5/24 at 24B. The fix, in both trainers:

  • Varied examples for every profile: small, medium and large now use them, as tiny already did.
  • Short yes/no examples: "Is Ana's city Lisbon? Answer yes or no." → "Yes.", and "No." for another fact's value of the same attribute.
  • Yes/no anchors: six general yes/no prompts come first among the anchors. The held-out drift prompts are unchanged.

This fix is not measured yet. It needs a GPU rerun of deep sleep and the integration benchmark at 1.5B, 4B and 24B. bench/README.md says so.

Testing

  • make test: extraction 710/710, priors 39/39, retrieval, HTTPS, and the Python unit tests pass.
  • Live in the agent (small profile, CPU, judge on):
    • "Which city does my sister live in?" → "Lisbon." (allowed).
    • "Ana's city is Porto" replaced "Lisbon" (the judge agreed).
    • "My dog is called Max." replaced "Your dog's name is Rex." (the rules matched and the judge confirmed; the rescue path itself was tested offline only).
    • A statement no longer goes through the guard.
  • Tools: memagent/tests/jev_guard.lpr and memagent/tests/merge_judge.lpr reproduce the two tables. Mem.Llama now binds llama_get_logits_ith.
  • Not tested: the judge on a GPU; the yes/no fix's effect on scores.

Generated by Claude Code

claude added 10 commits November 7, 2026 02:56
…he current guard

bench/jev/make_cases.py: 120 answers models really gave (GPU runs, 1.5B/4B/24B),
half right and half wrong, strictly labelled. memagent/tests/jev_guard.lpr runs
Mem.Guard.Licensed and a Jev-style readout (JevBan's prompt and letter-logit
readout, one forward pass) on each. Mem.Llama binds llama_get_logits_ith.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…or the current guard

On 120 answers models really gave (half right, half wrong), a Jev readout
over the two-hop retrieved facts kept 47/60 right answers and blocked 55/60
wrong ones at p>=0.9 (AUC 0.93); the current reranker + rules guard kept
28/60 and blocked 37/60. Bridge answers: 40/40 judged right. The same
readout with the 1.5B chat model: 0.56-0.68. 11.5 s per judgement on 4 CPU
cores.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…oes unsure fact merges

[judge] model=off | openjev-flash-9b | path. TJudge loads a GGUF beside the chat
model and reads the option letters' logits (JevBan's readout, one forward pass).

- Guard: P(the turn's retrieved facts back the answer) >= guard_min (0.9) or the
  answer is withheld. 0.85 vs 0.54 for the rule guard on 120 real answers.
- Merges: the rules still propose; the judge must agree that the new fact
  replaces the old (same person, same attribute), else both are kept. An unsure
  judge never overwrites (cf. Hightouch's over-merge lesson: a duplicate costs a
  line, a wrong merge lost 14 of 112 facts).
- Launchers turn it on for GPU presets with a CUDA llama.cpp and 16 GB+;
  off on CPU (~11 s per decision there).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…es; rescue merges reworded slots (0 wrong, 0 missed)

- [judge] merge_min stays 0.9: right merges scored 0.92-1.00, wrong ones 0.00-0.04
- new: when the rules find no match, the judge may merge the closest fact
  (subject cosine >= rescue_cos 0.4, not DistinctSubjects) at p >= rescue_min
  0.97. It catches the reworded slots the rules miss ("dog's name is Rex" ->
  "dog is called Max"); same-name different people scored up to 0.95, below
  the bar, and DistinctSubjects blocks them anyway. Tuned on the same set:
  noted as a caveat.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…s, varied examples for every profile

Training on question -> fact sentence alone taught models to answer "Is my
friend the one whose city is Porto? Answer yes or no." with "Your friend's
city is Porto." (verify 0/24 at 1.5B, 5/24 at 24B after deep sleep).

- varied examples (Mem.Examples / memlib.varied_qas), kinds 3 and 4 on even
  rounds: "Is Ana's city Lisbon? Answer yes or no." -> "Yes.", and "No." for
  another fact's value, of the same attribute when there is one
- six yes/no anchor prompts first in ANCHOR_PROMPTS (both trainers), so every
  profile rehearses answering yes or no; the held-out drift prompts (the last
  eight) are unchanged
- small, medium and large use [train] examples = varied (tiny already did)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
@FMXExpress
FMXExpress merged commit fced48e into main Nov 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants