fix: holographic memory CJK (Chinese/Japanese/Korean) support - #87159
Open
edward1229 wants to merge 4 commits into
Open
fix: holographic memory CJK (Chinese/Japanese/Korean) support#87159edward1229 wants to merge 4 commits into
edward1229 wants to merge 4 commits into
Conversation
Contributor
fix: holographic memory CJK (Chinese/Japanese/Korean) support The bigram-tokenization + FTS/LIKE routing split is a sensible approach for unspaced CJK. Observations:
|
…pty fallback Co-authored-by: u010820761 <u010820761@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Facts stored in the holographic memory plugin are completely unsearchable for CJK (Chinese/Japanese/Korean) users:
search("科技公司")returns empty (the FTS index swallows whole sentences into single tokens)probe("张伟")returns empty (entity extraction recognizes no Chinese names)reason([a, b])returns irrelevant facts (HRR vectors behave as near-random noise for Chinese)Root causes (6 layers, all verified in source)
store.pycreates FTS tables without a tokenizer → defaultunicode61merges consecutive CJK characters into one giant token (verified viafts5vocab)retrieval.py::_sanitize_fts_querysplits on whitespace + English stopwords, no CJK handlingstore.pyentity regexes are English-only (capitalized words / English quotes / "aka") → zero extraction for Chineseholographic.py::encode_textsplits on whitespace → whole Chinese sentences hash into a single bucketretrieval.py::_tokenizewhitespace splitting → CJK query/fact token intersection is always 0Fix
holographic.py
_cjk_tokenize(): CJK runs split into overlapping bigrams, runs ≥3 chars also keep the full run (exact phrase match); non-CJK split on whitespaceencode_textnow uses_cjk_tokenizeretrieval.py
_CJK_REclass attribute (CJK Unicode block regex)_is_short_cjk_query(): detects queries consisting only of <3-char CJK runs_cjk_fts_query(): CJK runs ≥3 chars → phrase literal (trigram-matchable); non-CJK words keep stopword+OR logic_sanitize_fts_querydelegates to the CJK path first; pure-English logic unchanged_get_fts_candidatesdual-arm execution: MATCH arm (English / ≥3-char CJK) + LIKE arm (<3-char CJK runs, per-run LIKE), merged & deduped in Python; LIKE arm ordered by trust_score/updated_at; each arm fails independentlyVerification (real DB: 5 facts / 19 entities, all Chinese)
Design notes