https://blog.nenkoru.com

Can 16 memory tokens carry the one fact that matters? A work report on Memorilla's token path

TL;DR: Memorilla packs each stored fact about a user into 16 memory tokens for Qwen3-8B. On fact types it never trained on, the best pipeline on those tokens acts on the one relevant fact in 44% of answers; a perfect picker would reach 80%, and a 27B judge reading the facts as text reaches 68%. The gaps are finding the fact among 48+ others and a reader that mostly uses it only when it comes first; the next step, teaching the token rater from the 27B judge, is ready to run. Done mostly by an AI agent (Claude) under the author's direction.

How to read this

State of the work

Background

Memorilla

The token path

Each stored fact goes through the untouched core alone, conditioned on the request, and comes out as one 16-token block. The k picked blocks are concatenated into 16·k memory tokens.

stored facts (a profile of 8 / 16 / 48 / 192)
   |  each fact + request --> frozen core --> 16-token block
   v
picker: rate each block alone ("does this fact change a good reply?") --> keep top k
   v
reader (Qwen3-8B + LoRA) with k blocks in memory --> "Relevant fact: ..." + answer

The reader is Qwen3-8B with a LoRA (rank 16, alpha 32, on q/k/v/o of all 36 layers), lora_lsort.pt. It was trained on blocks sorted best-first and writes Relevant fact: … before the answer.

Glossary

Term Meaning
clue the one stored fact that should change the answer
profile the clue plus 7, 15, 47 or 191 other users' facts (distractors)
block the 16 memory tokens of one fact
rater / picker scores each fact for a request; the top k go to the reader
text rater a decoder rating the fact given as plain text (off the token path)
block rater a decoder plus LoRA rating the fact from its block (on the token path)
acts the regex rubric says the answer acts on the clue (the main metric)
held-out types health, no_car, toddler, flying: never trained on

Benchmark and noise

Results

Ceiling and where things are (acts, held-out types)

Condition 8 facts 48 facts Test
Clue alone (perfect picker) 0.80–0.83 – 41
Whole profile as text, plain decoder 0.53–0.58 0.32–0.35 31, 41
8B text rater, best top k 0.60 0.47 38b, 41
27B text rater ("wrong" wording), best top k 0.68 0.53 41
Block rater (16 tokens, LoRA), top 1 / top 4 0.44 0.30 43

Where each rater ranks the clue

Rater Top 2 of 8 First of 48 Top 8 of 48
Plain decoder on the block, "change" wording 0.46 – 0.38
Block rater, 90 min int8 training 0.60 0.09 0.55
8B text rater (the block rater's teacher) 0.75 0.16 0.72
27B text rater, "wrong" wording 0.84 0.35 0.82

The "wrong" wording: "Could a typical reply to this request be wrong, unsafe or unsuitable for this user because of the fact? Answer Yes or No." The score is the Yes/No logit difference.

Picking: what was tried

Test Idea Result
17–22, 26 Learned map (request × fact embedding) Good on topical types (flying, no_car). Fails health and toddler. 2.7× more pairs: flat
30 Write-time "standing" score, request-independent Hand-written category lists fix health at 8–16 facts, but only for what the list names. Label-free scores miss health
32 The 8B quotes which facts matter False: quotes the clue in 49% at 8 facts, 22% at 48
35b, 35c Rate each fact alone with a yes/no, keep the top k True: beats the map and the whole profile. Wording matters per type
36 Distil the rating into an embedding scorer False: below plain cosine on held-out types
37, 38, 38b Attention as the selector; rate all facts in one pass False as a substitute: rates by topic in a crowd. Attention + rating: top 8 of 48 at 0.48 acts
39 Shortlist, then think or compare +2 points at 5× the cost. Comparing in a group loses health
40 LoRA rater, listwise, hard labels False: learns the training types; health falls to 0 at 192 facts
41 27B rates each fact as text True, the biggest gain. Lifts every type. An 8B shortlist re-rated by the 27B keeps most of it at 25–33% of the cost
43 Rate from the 16-token block: plain decoder; draft-then-judge; LoRA distilled from the 8B text rater Picking improves but the student is capped by its teacher. Answers gain 2–6 points
43 Abstain (skip memory) when the top score is low False: AUC 0.51–0.61 (8B), 0.59–0.75 (27B)

Reading: what was tried

Test Idea Result
19, 23, 27, 29 Restate the relevant fact first, then answer; blocks sorted best-first; trained with distractors Became the current reader
31 No picker: whole profile as text, reader trained to restate The plain decoder with the whole profile beat the picker of that time (0.58 vs 0.39)
33 Self-distillation: the fact-only decoder teaches the whole-profile one False: it learned the teacher's style
34 Token weights (learn only the tokens the fact changes) No gain
44 GRPO on the reader Stopped at step 19, no signal yet

What worked and what didn't

  1. A stronger general judge beats any narrow trained one (test 41 vs 36 and 40). Training on 8–100 generated fact types teaches those types, not "what matters".
  2. Rate each fact alone. In a crowd, a model rates by topic, and that is exactly where non-topical facts such as health get lost (35b vs 32, 37, 38).
  3. Distillation is capped by its teacher (43). Longer training on the same teacher adds 1–6 points.
  4. The reader is its own bottleneck (41, 43, 44). It leans on the clue being the first block, and it restates and follows wrong picks that look relevant.
  5. An int8 laptop setup is good enough for screening. Int8 ratings match bf16 at Spearman 0.993, and first answers are identical word for word.

The GRPO pilot (test 44)

Steps Reward, clue shown (acts) Reward, clue not shown Groups with any spread
1–10 0.28 0.89 3.1 / 8
11–19 0.29 0.87 3.2 / 8

What to try next

Ranked by expected value per hour.

1. Check 4c: a 27B teacher for the block rater

This is the cheapest test of whether the teacher cap is the whole story. If it passes, the 27B's judgement survives distillation onto 16-token blocks, and inference still needs only one 8B.

  1. Serve the 27B with vLLM.
  2. Have it rate the block rater's training pairs (poc_rate27train.py --requests 1000, about 25k pairs, giving rater_train27.json).
  3. Train: poc_tokrater.py --data rater_train27.json --minutes 45 --out lora_tokrater27.pt.
  4. Rate: poc_tok.py rate --lora lora_tokrater27.pt --raters tokL --tag 27 --wordings change.
  5. Answer: poc_tok.py answer --tables tokL27_change --conds "top+1+from+8,top+1+from+48,top+2+from+8,top+4+from+48".

Promotion bar: the clue ranked first of 48 ≥ 0.20, and top 1 of 8 acts ≥ 0.50.

2. GRPO v2 on the reader

3. Write-time salience judged by a model

Test 30 showed that an always-on set of "facts that matter whatever the topic" fixes health. But its scores came from hand-written lists, and the label-free scores failed. The untried version asks a model once per fact, at write time, how broadly the fact matters. The top few stay in context, and the per-request rating fills the rest. On the token path, the 8B reads the block. No training is needed.

4. A small fast judge

The block rater already has the shape of a "System-1" judge: one forward pass, with the Yes/No logits as the score. A smaller decision model would be faster, not better, unless it is trained on better labels. If check 4c passes, a ~400M bidirectional cross-encoder trained on the 27B labels is worth a look. It reads text, so it leaves the token path.

5. Lower priority

Constraints the work kept to

Compute

Known traps

Project files (for whoever continues)

File Role
experiments/AGENTMEM_HYPOTHESES.md every test 1–44 with full tables
experiments/REPORT_2026-11-24_token_path.md the internal version of this report, with run commands
experiments/poc_tok.py rate / answer / dry on the token path
experiments/poc_tokrater.py train the block rater
experiments/poc_grpo.py the GRPO pilot
experiments/poc_rate27train.py 27B teacher data for check 4c
experiments/poc_clue.py benchmark and rubrics
experiments/q8.py int8 decoder loader
work/runs/poc/synth.json the benchmark: 252 pairs with rubrics
work/runs/agentmem/lora_lsort.pt the current reader
work/runs/agentmem/lora_grpo_s10.pt GRPO step 10, not evaluated

AI use

This work was done mostly by AI, under human direction. Read the results with that in mind.

Part Who did it
Goals, constraints, which ideas to pursue, what to publish the author
Experiment design, most of the code, running the experiments, analysis Claude (Anthropic), working as a coding agent in Claude Code, directed by the author
Some routine code, including this blog's site generator a local Qwen model, given a written spec, with Claude checking the output
This report and post written by Claude from the experiment logs, reviewed by the author before publishing
Benchmark clue chats generated by an LLM and checked by regex; filler chats come from Memorilla's demo data
Benchmark questions and rubrics fixed config and regular expressions written during the AI-assisted sessions; no model judges answers at eval time
Rater training labels and teacher answers generated by the 8B and 27B models (that is the method, not a shortcut)

The models under test (Qwen3-8B, Qwen3-Embedding-4B, a 27B Qwen-family model, and the Memorilla core) are research subjects, not authors.


AI disclosure: posts here are written with AI help, and much of the work they report is done by AI agents under the author's direction. Each post says what was done by which model.
last update: November 24, 2026. For agents: markdown, llms.txt, feed.