i18n: honor source-content language for extraction labels - #2901
Conversation
The extraction prompt (skill.md) is all-English with no label-language rule, so non-English corpora get English labels — LLMs follow the prompt language. Reproduced with a 4-doc Chinese corpus (v8 line / graphifyy 0.9.16, deepseek/qwen): before = 28 nodes, 0/28 Chinese labels (Chinese notes on Kantian ethics produced 'Kantian Deontology' etc.); after = 27/27 Chinese labels, edges 17 -> 21. Append a LANGUAGE RULE after the extraction JSON schema in both skill.md copies (graphify/skill.md and skills/graphify/skill.md). Node IDs stay ASCII; existing graphs relabel on rebuild.
67c4b81 to
9d96ac8
Compare
There was a problem hiding this comment.
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify review — findings
Adds a language rule to the semantic extraction prompt in both graphify/skill.md and skills/graphify/skill.md, instructing labels to use the source content's dominant language (Chinese concepts stay verbatim, not translated) while node IDs remain ASCII.
No blocking issues surfaced.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 60 functions depend on the 60 functions this change touches.
Health — grade A; no new coupling hotspots.
Verification — 60 functions in the blast radius were not formally verified this run (proofs are advisory here).
Health delta baseline: last indexed commit b14b52e (diverged from this PR's base — delta is approximate).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 60 function(s) in the blast radius were not formally verified this run
Problem
_EXTRACTION_SYSTEM(graphify/llm.py) is entirely English and code-oriented, andnothing in it tells the model what language to write labels in. LLMs follow the
system prompt's language, so non-English corpora get English labels.
Reproduced with a 4-document Chinese corpus (deepseek-v4-flash / qwen via
OpenAI-compatible endpoint), graphifyy 0.9.16:
produced "Kantian Deontology", "Categorical Imperative", ...). Hyperedge labels
likewise English.
even improved (17 → 21).
Proposal
Append a language rule to the extraction system prompt. Two variants; either works.
Minimal (always-on, recommended) — models are good at detecting the dominant
language, no config surface needed:
Configurable —
GRAPHIFY_LABEL_LANGUAGE=auto|zh-CN|en|..., defaultauto(= the rule above); an explicit value pins the label language regardless of
source language (useful for bilingual corpora where the user wants uniform labels).
Notes
[a-z0-9_]); this change only affectshuman-readable labels.
Suggested patch (minimal variant)