mirror of
https://github.com/Pasta-Devs/Marinara-Agents.git
synced 2026-12-03 18:55:07 +07:00
[GH-ISSUE #1295] [Bug/Enhancement] LTM recall: Korean tokenization, short keyword filtering, and multilingual embedding support #658
Labels
No labels
agent: chess
agent: conversation-calls
agent: eightball
agent: haptic
agent: hierarchical-maps
agent: hierarchical-maps
agent: illustrator
agent: poker
agent: rock-paper-scissors
agent: tic-tac-toe
agent: uno
artifacts
bug
bugfix
build
catalog
ci
client
dependencies
docs
documentation
enhancement
feature
fixed-in-staging
in-pr
normal-scope
packages
pull-request
qol
regression
roadmap
scope-risk
server
soup
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Agents#658
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tlsiddl on GitHub (Oct 10, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1295
Originally assigned to: @Promansis on GitHub.
Summary
I'd like to report several potential issues affecting Long-Term Memory (LTM) recall quality when using Korean or other non-English languages.
A Korean community member investigated LTM's retrieval behavior and shared a detailed technical analysis. I received permission to share the findings here.
I also reviewed the relevant source files in the
stagingbranch.The main concern is that valid memories may be stored successfully but become difficult to retrieve in Korean conversations, especially when semantic retrieval is unavailable or lexical matching fails.
This is separate from the extraction and subject-identity issues addressed in #1277.
1. Korean Keywords Shorter Than 3 Characters Are Filtered Out
Confirmed in source code.
File:
keyword-extract.tsThe keyword normalization function contains:
This removes tokens shorter than three characters.
Although this may be reasonable for filtering short English terms, many important Korean words and character names contain only two syllables.
Examples:
For example, a memory may contain:
"서래는 무진에게 반지를 선물받았다."
If the extracted keywords are
서래,무진,반지, and선물, all four are shorter than three characters and may be excluded from keyword indexing.The memory itself is not deleted, but the keyword retrieval lane may lose important matching signals.
Suggested Improvement
2. BM25 Tokenization Does Not Account for Korean Particles or Morphology
Confirmed in source code.
File:
bm25.tsThe current tokenizer uses:
This supports Unicode characters but does not perform Korean morphological analysis or particle separation.
Consequently, semantically related forms can become different tokens.
Examples:
For example:
Query: "반지를 받았다"
Memory: "반지 선물"
The lexical tokenizer produces different tokens, even though both phrases may refer to the same event.
BM25 requires matching indexed terms, so Korean inflection and spacing differences can reduce lexical recall.
Other shared words may still allow a match; this does not mean every Korean query fails.
Suggested Improvement
3. Graph Recall Depends on Lexical and Keyword Seeds
Confirmed in source code.
File:
retrieval.tsGraph recall uses seed notes selected from BM25 and keyword search results:
The graph traversal itself supports linked memories, including incoming and outgoing links.
However, it needs initial seed memories.
If Korean lexical matching fails and short keywords are filtered out, the graph lane may have no relevant seed from which to begin traversal.
For example:
반지를with반지.반지is filtered out.This is a cascading effect of the previous two issues rather than necessarily a separate graph implementation bug.
Semantic retrieval may still find the memory independently if suitable embeddings are available.
Suggested Improvement
Please consider whether graph recall should have alternative seed sources when lexical and keyword matching are weak, potentially including semantic retrieval results.
4. Multilingual Embedding Support and Configuration
Further verification requested.
The community analysis raised concerns about Korean semantic retrieval when LTM uses an English-oriented local embedding model.
The LTM source includes support for an embedding adapter, and
package-runtime.tsresolves an adapter through the host runtime:However, I have not independently confirmed:
The original community report suggested that the default local model may not adequately support Korean, but I don't want to claim that Korean semantic scores are always zero without verifying the actual runtime behavior.
Suggested Investigation
Could you clarify:
A configurable multilingual embedding provider could be especially useful for users running Korean, Japanese, Chinese, or mixed-language roleplay sessions.
5. Mixed-Language Recall
An additional concern is that some users have conversations in one language but store summaries or LTM memories in another.
For example:
Exact lexical matching between languages cannot reliably recover equivalent words.
Keyword matching may also become ineffective when the query and stored keywords use different languages.
In these cases, multilingual semantic retrieval becomes particularly important.
It would be helpful to document which retrieval components support cross-language matching and which require matching languages.
Expected Behavior
LTM should be able to retrieve relevant memories in Korean conversations without systematically losing important signals because of Korean word length, particles, or spacing.
Ideally:
Relevant Source Files
packages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/keyword-extract.tspackages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/bm25.tspackages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/keyword-index.tspackages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/retrieval.tspackages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/graph.tspackages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/embedding-adapter.tspackages/long-term-memory/src/engine/packages/server/src/services/long-term-memory/package-runtime.tsTesting Status
The short-keyword filtering, Unicode lexical tokenization, and graph-seed dependency were verified through source inspection.
I have not yet performed a full end-to-end recall benchmark with controlled Korean conversations. The examples above illustrate likely failure conditions based on the implementation, rather than measured retrieval failure rates.
The default embedding model's Korean performance also remains unverified.
I'd appreciate confirmation of these behaviors and any guidance on improving multilingual recall.
Thank you for your continued work on LTM and for considering feedback from Korean users!
@SpicyMarinara commented on GitHub (Oct 10, 2026):
@Promansis
@Promansis commented on GitHub (Oct 10, 2026):
Done :) @tlsiddl please let me know how that goes so far, I have another set of work ready to go for the embedding stuff but it's taking a bit longer. Interested to see if 1.4.23 helps though
@tlsiddl commented on GitHub (Oct 12, 2026):
Thanks again for the fix in #1295!
I noticed one remaining edge case involving single-character Korean names.
In the current staging code:
keyword-extract.ts
bm25.ts
These conditions still exclude single-character Korean tokens.
Some Korean character and persona names consist of only one Hangul syllable (e.g., 온, 린). These are meaningful proper nouns, but they are currently discarded during keyword extraction and BM25 tokenization.
Would it be possible to preserve single-syllable Korean character/persona names, perhaps through exact-name matching or another targeted exception, without allowing excessive noise from arbitrary single-character tokens?
This is a follow-up to #1295 rather than a separate issue.
Thanks!
@tlsiddl commented on GitHub (Oct 12, 2026):
One more detail: the particle-stripping helper has the same minimum-length restriction.
hangul-lexical.ts (stripHangulParticle):
This prevents single-syllable names with Korean particles, such as 린이, 린에게, and 온은, from being normalized to 린 and 온.
This is particularly important in Korean roleplay, where character names frequently appear with grammatical particles.
Example (lexical retrieval only):
Simply relaxing the minimum token lengths in keyword-extract.ts and bm25.ts would not fully resolve this issue.
Suggestion: When the remaining stem matches a known character or persona name, allow a single-syllable stem in stripHangulParticle and preserve it during keyword extraction and BM25 tokenization.
This would help support short Korean proper names without broadly enabling noisy single-character matches.
@tlsiddl commented on GitHub (Oct 15, 2026):
Hi @Promansis, thanks for the recent Korean name matching improvements!
Could you also take a look at the one-syllable Korean name issue I mentioned earlier?
For example:
The current particle-stripping logic appears to require at least two characters to remain, so one-syllable names may still be excluded from keyword/BM25 matching.
Does the recent fix cover this case, or would it need a separate change?
Thanks!