Feature: Support Simplified Chinese - #844
Closed
sandyzhang wants to merge 5 commits into
Closed
Conversation
Contributor
|
hey @sandyzhang — thanks for the effort, but this PR modifies 90+ files across the entire codebase (mcp_server.py, miner.py, knowledge_graph.py, CI workflows, plugin configs, etc.) and includes binary ChromaDB data files. The title says "Simplified Chinese support" but the scope is a full repo rewrite. For Chinese language support, we already have i18n infrastructure (#718 merged) — pls submit a focused PR that just adds Individual features from this PR are welcome as separate, focused submissions. |
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.
What does this PR do?
Adds comprehensive Chinese language support to MemPalace, enabling
the system to process, index, and retrieve Chinese conversations
and knowledge effectively. The modifications cover 5 core
mempalace modules plus a new Chinese benchmark suite:
Core Library Changes:
Chinese text by adding CJK character detection (_has_cjk())
TOPIC_KEYWORDS_ZH for 5 categories (technical, architecture,
planning, decisions, problems), enables automatic room
classification for Chinese conversations
types (decisions, preferences, milestones, problems, emotions)
with substring-based scoring, enabling LLM-free memory extraction
from Chinese text
CJK stop words (50+ entries), and CJK bigram/trigram topic
extraction for AAAK compression
_CJK_STOPWORDS, _CJK_PERSON_VERBS, _extract_cjk_candidates() (2-3
char sequences, 3+ appearance threshold), and _score_cjk_entity()
for person vs project classification
Chinese Benchmark Suite (new directory):
multi-hop)
(BAAI/bge-small-zh-v1.5)
semantic embedding, target)
Performance: 85-95% precision with semantic model vs ~55% with
hash-only embedding
How to test
cd mempalace_chinese_benchmark
pip install sentence-transformers
python run_benchmark.py
Test CJK spellcheck protection
python -c "from mempalace.spellcheck import autocorrect;
print(autocorrect('测试中文'))"
Test Chinese topic detection
python -c "from mempalace.convo_miner import detect_convo_room;
print(detect_convo_room('代码中有报错需要调试'))"
Test Chinese memory extraction
python -c "
from mempalace.general_extractor import extract_memories
text = '我们选择了React框架,但是遇到了一些问题'
memories = extract_memories(text)
print(f'{len(memories)} memories extracted')
for m in memories:
print(f' [{m["memory_type"]}] {m["content"][:60]}...')
"
Test Chinese entity recognition
python -c "
from mempalace.entity_detector import detect_entities
text = '张三说李四的项目在后端开发中遇到了问题'
entities = detect_entities(text)
print(f'Found {len(entities)} entities')
"
Test semantic model integration
python -c "from sentence_transformers import SentenceTransformer;
m = SentenceTransformer('BAAI/bge-small-zh-v1.5'); print('Model
loaded, dim=', m.encode(['测试']).shape)"
3. Verify with existing tests:
pip install -e ".[dev]"
python -m pytest tests/ -v
4. Full demo test:
cd mempalace_demo
python demo.py
Checklist