Skip to content

i18n: honor source-content language for extraction labels - #2901

Open
motuo520 wants to merge 1 commit into
Graphify-Labs:mainfrom
motuo520:i18n-label-language
Open

i18n: honor source-content language for extraction labels#2901
motuo520 wants to merge 1 commit into
Graphify-Labs:mainfrom
motuo520:i18n-label-language

Conversation

@motuo520

Copy link
Copy Markdown

Problem

_EXTRACTION_SYSTEM (graphify/llm.py) is entirely English and code-oriented, and
nothing 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:

  • Before: 28 nodes, 0/28 Chinese labels (e.g. Chinese notes on Kantian ethics
    produced "Kantian Deontology", "Categorical Imperative", ...). Hyperedge labels
    likewise English.
  • After appending the language rule below: 27/27 Chinese labels, and edges
    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:

LANGUAGE RULE: Write all human-readable text (node labels, hyperedge labels) in
the dominant language of the source content. Chinese source content MUST produce
Chinese labels with verbatim Chinese concepts (e.g. 道德义务论, 绝对命令) — do NOT
translate them to English. Node IDs stay ASCII per the format rules above.

ConfigurableGRAPHIFY_LABEL_LANGUAGE=auto|zh-CN|en|..., default auto
(= 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

  • Node IDs intentionally stay ASCII ([a-z0-9_]); this change only affects
    human-readable labels.
  • Existing graphs keep their labels until rebuilt — no migration concern.
  • Happy to open the PR with tests if you tell me which variant you prefer.

Suggested patch (minimal variant)

--- a/graphify/llm.py
+++ b/graphify/llm.py
@@ _EXTRACTION_SYSTEM tail @@
 ...],"input_tokens":0,"output_tokens":0}
+
+LANGUAGE RULE: Write all human-readable text (node labels, hyperedge labels) in
+the dominant language of the source content. Chinese source content MUST produce
+Chinese labels with verbatim Chinese concepts (e.g. 道德义务论, 绝对命令) — do NOT
+translate them to English. Node IDs stay ASCII per the format rules above.
 """

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.
@motuo520
motuo520 force-pushed the i18n-label-language branch from 67c4b81 to 9d96ac8 Compare August 20, 2026 15:03

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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.

1 participant