Research: modern-web-guidance's cheap knowledge injection (router + cards with token counts, static Model2Vec query embeddings, BM25+vector RRF, quote-to-claim) against Eureka's measured load

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Eureka 2026-11-11 06:13:09 +01:00
commit b72ec37aef

View file

@ -0,0 +1,49 @@
# Research: how GoogleChrome/modern-web-guidance injects knowledge cheaply
Served: Meta, 2026-11-11, "worth a close look to see if there's anything we can get better at injecting knowledge into
Eureka". Source read: github.com/GoogleChrome/modern-web-guidance @ 4dd9683 (2026-11-10), npm `modern-web-guidance@1.0.0`
(`skills/modern-web-guidance/search.mjs`, `gen/`). Apache-2.0.
## What it does (read from the code, not the README)
- **Router plus corpus.** One 9.9 KB SKILL.md is all that enters context. The corpus (209 guides, 2.4 MB of Markdown) stays
on disk behind a CLI.
- **Two steps.** `search "<2-5 word query>"` returns cards: `{id, description, category, featuresUsed, tokenCount, similarity}`,
top 10. The agent reads the descriptions, then `retrieve "<id>[,<id>]"` loads whole guides. `tokenCount` on the card lets
the agent budget before loading. Weak or empty results mean the agent rephrases once, then proceeds without retrieving.
- **Query embedding with no model at runtime.** `gen/query-words.json` (29,165 words) and `query-words.i8` hold a static word
table of 256 dims, int8, with a per-row f32 scale (~7.5 MB). A query vector is the scale-weighted sum of its words' rows,
normalised, and hyphenated words split and share weight. This is Model2Vec-style distillation of a real embedder. The chunks
(2,016, ~6 per guide) are pre-embedded into the same 256-dim int8 space (`guide-chunks.i8` + `.scale.f32`). Search is a
dot product over 2,016 vectors in Node, offline, in milliseconds, with no GPU, network or server.
- **Hybrid ranking.** BM25 (k1 1.2, b 0.75; a stopword list and a tiny plural stemmer) over `description + chunkContent`,
fused with the vector ranking by reciprocal rank fusion (k = 60). There's a vector floor of 0.3: below it, only BM25
hits count, and if there are none the result is empty (no guessed match).
- **Grounding by quote.** The agent must end with one bullet per applied guide id, carrying a short verbatim quote of the
rule it applied, and must never cite ids or quotes from memory after compaction. That makes an unread guide hard to claim.
- **Plugin packaging.** One skill tree with manifests for Claude, Codex, Cursor, Gemini, Kimi and Grok.
## Where Eureka stands (measured 2026-11-11)
- `SKILL.md` 54 KB (~13-14k tokens) is loaded whole on every invocation, in every Self session and every Mind Self run.
References load on demand already (briefs.md 41 KB, campaign-state.md 21 KB, changelog.md 110 KB).
- Every Persona process carries `colossus.md` 16 KB + `persona.md` 9 KB + `swarm-purpose.md` 1 KB.
- Huginn `query --near` embeds through `qwen3-embedding:0.6b` on an Ollama pool (Raven and Starfire GPUs, Yggdrasil CPU
reserve). Every query is a network call to a GPU that Deru's games and other jobs contend for.
- Huginn cards (`query` rows) are already the first step of a two-step read (`query`, then `view`), but they carry no token count.
## What transfers
1. **Split the skill into a router and retrievable sections.** Keep in SKILL.md only what every invocation needs (the loop,
the faculty table, the hard rules). Everything situational (sizing Hands, Soul's method, the git rules, the mutation
tooling, the git scars) moves to sections retrieved by name. The expected cut is ~13k tokens to ~3-4k on every
invocation. This is the biggest saving and costs only an edit.
2. **Token count on Huginn cards**, so an agent budgets a `view` before paying for it.
3. **A static-embedding query path for Huginn.** Distil `qwen3-embedding:0.6b` into a static word table (Model2Vec) and
embed queries in-process. Re-embed stored records with the same static model, or keep qwen for documents only if the
spaces align, which needs measuring before relying on it. That removes the Ollama network hop and GPU contention from
every read. Measure recall against the current qwen path on real Huginn queries before switching.
4. **Hybrid BM25 + vector with RRF and a floor**, if Huginn's ranking is vector-only today. Exact ids and labels (ruling
names, file paths) are what BM25 catches and embeddings miss.
5. **Quote-to-claim.** When an agent says a ruling applies, it quotes the operator words or statement from the record it
viewed this turn, not from memory.