Skip to content

fix: warm Cyrillic search and drop shared-word neighbours - #70

Merged
hmbanan666 merged 1 commit into
mainfrom
fix/small-corpus-followup
Nov 17, 2026
Merged

hmbanan666 merged 1 commit into
mainfrom
fix/small-corpus-followup

Conversation

@hmbanan666

Copy link
Copy Markdown
Owner

Follow-up to #69 on a three-note RU/EN instance. Tools stay search, remember, read, and timeline.

Done

  • Latency. A fresh-process timing pass (EN, RU, and title queries in three orders, fake embedder) put lexical search at about 8–20 ms and the stemmer, Unicode regex, and NFKC at under 10 ms. The 2143 ms query matches the two-second query-embedding timeout. Startup only embedded the ASCII word warmup, so the first Cyrillic question still initialized the tokenizer and the runtime. Warmup now stems and embeds an English question and Как устроена память бота? before it logs embeddings_ready. Listen is still not blocked.
  • English grounding. does was already removed. work was not, and because it occurs in no note its inverse-document-frequency is the largest weight in the denominator. How does the bot's memory work? matched only bot and memory and stayed weak (share about 0.41). work / works / working / worked and нет are now function words for the share. The memory note does not need to contain the word work.
  • Card floor. It was counting every stemmed query word, including бот and сайт, and it did not see the title. A neighbour with one shared word stayed at about half the best score, which the 0.5 floor keeps. The floor now counts the same function-word list as grounding, ignores a term that occurs in half or more of a corpus below the margin floor, and includes the title. When no card has a distinctive term, the floor does not run, so an accepted-ADR score boost cannot drop a superseded copy of the same words.
  • Docs updated in docs/search.md and docs/curated-instance.md.

Tests

pnpm run check — lint, typecheck, 288 tests passed.

node dist/test/evaluate-grounding.js (lexical, no model files):

  • curated: on-topic 10/10 not-none on the right source, off-topic 10/10 none
  • mixed: on-topic 10/10 not-none on the right source, off-topic 10/10 not strong (all none)

New fixture, three notes that all mention the bot and the site: How does the bot's memory work? is strong and returns the memory note. Как устроена память бота?, О чём отвечает AI Бот?, and Почему на сайте нет бейджей технологий? are each strong and return one card.

Skipped

  • Semantic grounding eval. Model files are not in this checkout, so the Cyrillic warmup could not be timed against the real ONNX runtime. The 2143 ms figure is the existing two-second embed timeout, not a measurement of this machine's model.
  • No new MCP tools. Full-text search still indexes function words; only the share and the small-corpus floor ignore them.
  • Not merged and not deployed.

Friction

  1. What took long. The first timing pass was the useful part, about ten minutes including a tsc because Node still cannot import package-query.js from the TypeScript sources. Stemmer, regex, and NFKC were red herrings (all under 10 ms). Seeing share 0.414 for bot|memory made the work weight obvious. The card-floor change then failed test/documents.test.ts: once every term was shared, concept counts went to zero and the accepted-ADR +1 versus superseded ×0.5 looked like a huge score gap, so the superseded card disappeared. One full pnpm run check (about 28 s) caught that. No model download and no flake loop.
  2. Hacks. None beyond not having the embedding weights. The Cyrillic probe is the fix for a timeout we could not reproduce locally.
  3. Misleading spots. src/embedding-index.ts logged embeddings_ready after one ASCII embed and the comment said that removed the first-query cost. src/embedding-index.ts search races the embed against 2000 ms, which is why a cold Cyrillic query lands near 2143 ms and the next ones are 50–90 ms. src/documents.ts adjustDocumentScore adds a full point, larger than the whole reciprocal-rank score, so a floor written as "fraction of the score" drops superseded documents when the term count is zero.
  4. Faster next time. Put the pinned multilingual-e5-small weights where this environment can load them, and have context grounding explain print each term's weight and whether it was dropped as a function word or as shared. The share line alone did not say that unmatched work was most of the denominator.
Open in Web Open in Cursor 

An ASCII warmup left the first Russian query to initialize the tokenizer
and spend the two-second embed budget. The card floor now counts distinctive
terms, including the title, so бот and сайт do not keep every note. "How
does it work" no longer puts an unmatched work in the grounding share.

Co-authored-by: Nick Kosarev <nick@kosarev.space>
@hmbanan666
hmbanan666 merged commit 073f15d into main Nov 17, 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