Repository navigation
Description
Problem or use case
I keep a Markdown knowledge base (~29k files) and build one graphify graph per topic folder (61 graphs). Per-topic runs give richer extraction than one big run, because chunks stay focused. What I want on top is one connected graph across all topics.
graphify merge-graphs combines the graphs but never merges entities: each input is namespaced (prefix_graph_for_global, cli.py:3956 on v0.9.124) and then nx.composed, so the same concept stays as N separate nodes. deduplicate_entities cannot be used afterwards either, because it refuses nodes from more than one repo (dedup.py:1167-1171, "Cross-project dedup is disabled — run dedup per-repo before merging").
I understand why that guard exists (#3094, code repos where equal names are often a coincidence). In a single-owner document corpus, though, the same label in two topics is almost always the same thing.
Measured on graphify 0.9.77 (code references re-checked on v0.9.124), CPU only. Each row starts from the merge-graphs output:
| Merged graph of 61 inputs | nodes | edges | components | largest component | inputs inside the largest component |
|---|---|---|---|---|---|
merge-graphs only |
27,973 | 22,311 | 8,561 (= sum of the inputs) | 4,878 (17.4%) | 1 / 61 |
+ exact normalized-label merge across graphs (build._norm_label, code nodes excluded) |
27,616 | 22,292 | 8,368 | 11,790 (42.7%) | 39 / 61 |
+ deduplicate_entities with the repo guard bypassed (default JW 92) |
27,425 | 22,287 | 8,224 | 11,266 (41.1%) | 36 / 61 |
- 341 labels appear in 2 or more graphs: 815 nodes that stay apart after
merge-graphs. - The exact-label merge unified 357 nodes in 1.6 s (~120 MB peak RSS). By construction it only joins identical normalized labels, and it connects more inputs than the fuzzy pipeline.
- The fuzzy pipeline across graphs merged 548 nodes (206 exact, 342 fuzzy). In a random sample of 30 fuzzy pairs at least 7 were wrong (e.g.
Coeficiente ro→Coeficiente ri). - Raising
_MERGE_THRESHOLDto 99 / 100 (patched in the module) leaves 49 / 31 fuzzy merges and the same 36 / 61 connectivity. At 100,Classe albero k6,n6andp6are still merged intoClasse albero g6: Jaro-Winkler ≈ 97 plus_COMMUNITY_BOOST(+5) clears even 100. That one happens inside a single repo too, at the default threshold.
Proposed solution
Minimum (this alone solves my case): an opt-in flag, e.g.
graphify merge-graphs a.json b.json ... --unify-labels
(and the same for global add). After namespacing, it merges non-code nodes whose normalized label (_norm_label) is identical across inputs, rewires edges to the survivor, keeps provenance (for example a repos list on the survivor), and prints how many nodes were unified. It is off by default, so code-repo behaviour and the #3094 protection stay exactly as they are.
Nice to have, only if it fits your plans:
- Make
_MERGE_THRESHOLDand_COMMUNITY_BOOSTconfigurable (env var or CLI). Today they are module constants. - An opt-in cross-project fuzzy mode that reuses
deduplicate_entities, with--dedup-llmas the arbiter for ambiguous pairs. - A report of merged pairs (label → survivor, source repos) written next to the output, so merges can be reviewed.
- A guard for short letter+digit codes that differ in one character (
k6/g6), like_numeric_tokens_differdoes for digit runs._is_variant_paircovers digits followed by letters (ASR1603), not this case.
Alternatives considered
- One big run over everything. Tested earlier on a 28-file subset with 0.8.18: 130 nodes / 86 edges / 44 components, against 206 / 179 / 31 for per-folder graphs merged. graphify chunks at the token budget anyway, so a single run never sees the whole corpus at once.
- Graph size. Not the problem: the merged graph is 24.8 MB, and
GRAPHIFY_MAX_GRAPH_BYTESalready lifts the 512 MiB cap. - Embedding-based merge (BGE-m3, cosine ≥ 0.92, digit guard) on top of the exact-label merge: 1,444 nodes merged, 43 / 61 inputs connected, but 26 min on CPU and wrong merges below ~0.96 (
OpenSearch→Elasticsearch,max_tokens→max_output_tokens). So I am not asking for that. - Post-processing outside graphify. This is what I do now: a small script on the merged JSON. It works, but anyone with a multi-folder document corpus hits the same wall, and the logic already exists in graphify.
Area
Graph building or querying
Happy to test a branch on this corpus and report the numbers.
Activity
github-actions commentedon Dec 1, 2026
Thanks for opening this issue, @Rasco94. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.