← Writing

Articles

What happens when a local GraphRAG pipeline meets long documents

In my previous post, I spent four weeks benchmarking Orb, my offline note-taking app, on short notes. But real-world documents are rarely brief. A lecture transcript, meeting recording, or technical PDF can easily stretch to tens of thousands of tokens. So I spent the following few weeks testing what happens to a local GraphRAG pipeline when documents get long.

The results surprised me. Trying to ingest an entire 32,000-token document in one pass caused more than half of the documents to fail due to timeouts. Splitting documents into modest 1,500-token chunks, on the other hand, had a 100% success rate with zero lost files. And a clever idea I expected to help (giving every chunk a global document summary for context) actually made answer quality worse.

How I tested it

I ran Orb's actual backend end to end on rented GPUs, keeping the same strict rule from my earlier benchmarks: zero post-processing or silent repair of model outputs. If an extraction was malformed, that data was lost. Gemma 4 12B handled knowledge graph extraction, while Qwen 3.5 9B generated the answers. Both models ran locally using llama.cpp.

MuSiQue, the tougher of the two multi-hop benchmarks I use, consists of short passages. To turn it into a realistic long-document test, I concatenated its passages into long synthetic documents, deliberately positioning the gold answer passages at the beginning, middle, or end. The original ground-truth answers remained valid, but the facts were now buried inside documents ranging from 20,000 to 35,000 tokens.

Chunk size mattered less than I thought

The first round used 15 long documents and 25 questions:

Setup Answer F1 Exact Match Gold Passages Indexed Documents Ingested
Orb defaults at 32k context 0.406 32% 100% 15 of 15
Orb defaults at 16k context 0.541 44% 100% 15 of 15
Fixed 8,000-token chunks 0.537 36% 96% 15 of 15
Whole document, no chunks 0.470 40% 55% 7 of 15

Across 25 questions, the F1 differences are within standard error margins, so I am not declaring a definitive winner on accuracy.

The crucial finding is in the last row. Ingesting whole documents without chunking caused 8 out of 15 documents to fail completely due to request timeouts. The model was not generating invalid JSON or hallucinating. It simply could not finish processing before the timeout window expired when running six parallel ingestion slots.

While extending the timeout might rescue a few documents, the hardware constraints make full-document ingestion impractical on consumer machines. Gemma 4 12B uses 40 sliding-window attention layers. Keeping their full key-value cache for a 32,000-token document requires roughly 13.8 GB of VRAM on top of the 7.3 GB needed for model weights. That pushes past the practical limits of a 24 GB laptop. Without caching, every single extraction pass must re-read the entire document from scratch.

Moreover, expanding the context window did not improve answer quality. The 16k setup matched or outperformed 32k while requiring significantly less memory.

A global summary did not help

For the next round, I expanded the test set to 30 long documents and 50 questions, settling on 1,500-token chunks as the baseline.

Small chunks have a well-known vulnerability: coreference loss. If a chunk begins with 'she joined the company in 1998', the model has no idea who 'she' refers to. To solve this, I designed a two-stage global pass. Before extracting the graph, the model reads the full document to generate a high-level summary along with a list of key entities. Every chunk is then injected with this background context during extraction.

Setup Answer F1 Exact Match Retrieval Recall Failed Documents
1,500-token chunks 0.510 44% 0.975 0 of 30
1,500-token chunks + global pass 0.420 34% 0.980 0 of 30

Strictly speaking, the bootstrap confidence interval for the F1 difference spans from -0.20 to +0.02, meaning it is not a statistically guaranteed loss. However, adding the global pass produced worse answers on 11 questions and improved only 6, while adding an extra LLM call for every single document. Because there was zero evidence of a benefit, I left it disabled.

Interestingly, retrieval recall remained virtually identical (0.975 vs 0.980), showing that both configurations located the necessary passages. The degradation happened downstream during graph extraction or final answer synthesis. One likely explanation is that prepending background context ate into the prompt budget, effectively shrinking the amount of actual text each chunk could contain.

Two cheaper questions with clearer answers

1. A much smaller embedding model works just as well:
I benchmarked different embedding models across 50 HotpotQA questions. To isolate retrieval performance from extraction noise, I used Claude Haiku 5.5 for both graph extraction and final question answering.

Embedder Disk Footprint Answer F1 Exact Match Retrieval Recall
Qwen3-Embedding 4B 2.5 GB 0.884 72% 1.000
Qwen3-Embedding 0.6B 639 MB 0.839 68% 0.990
EmbeddingGemma 1 334 MB 0.841 72% 0.940
EmbeddingGemma 2 310 MB 0.882 74% 1.000
EmbeddingGemma 2 (256-dim Matryoshka) 310 MB 0.846 68% 1.000

All four models performed within standard error margins of the 4B baseline. But EmbeddingGemma 2 matched the flagship model's accuracy at one-eighth of the file size, making it the obvious default for Orb.

One practical caveat: cosine similarity distributions vary significantly between models. A similarity threshold tuned for Qwen let almost every vector pass through under EmbeddingGemma 2, requiring recalibration to a new threshold of 0.69.

2. Entity alias expansion added latency with zero value:
Orb previously included an entity-resolution step that searched for name variants and aliases across the graph. Removing this lookup on 20 MuSiQue questions reduced retrieval latency from 186 seconds per question down to just 13 seconds, with retrieval recall holding steady at 0.917.

Most of the 'aliases' it surfaced were accidental substring overlaps rather than genuine real-world entity synonyms. The correct place to handle entity resolution is during index creation through entity deduplication, which I am implementing next.

How far from the frontier?

To understand how local models compare against state-of-the-art hosted LLMs, I ran Claude Opus 5.5 through the identical pipeline on the original short-note benchmarks, handling both graph extraction and synthesis.

Opus achieved an F1 of 0.884 on HotpotQA and 0.642 on MuSiQue. By comparison, my top local models reached roughly 0.69 and 0.41. Because those evaluations used slightly different runtime configurations, this should be viewed as a ballpark comparison rather than a precise head-to-head score. Even so, it confirms two things: multi-hop reasoning on MuSiQue remains challenging even for frontier models, and there is still meaningful headroom for local models to catch up.

What I did not finish

My rented GPU credits ran out before I could finish the final suite of experiments. Two configurations (15% chunk overlap and 800-token chunks) completed index creation, but did not have remaining compute budget to run question answering. Tests with 3,000-token chunks and llama.cpp's DRY repetition sampler never ran at all.

As a result, while I can confidently say that 1,500-token chunks handle long documents reliably without timeouts, I cannot yet prove they represent the absolute optimal chunk size.

Additionally, a 50-question test set has statistical limits: F1 differences smaller than roughly 0.10 do not achieve statistical significance at this sample size. Resolving fine-grained architectural tradeoffs will require expanding the evaluation set to several hundred questions.

The data

All experimental artifacts are publicly accessible: the raw scores, 87,203 cached model inferences, nine prebuilt indexes, dataset splits, and the exact evaluation harness. The complete bundle is available on Hugging Face, and everything except the index files is archived permanently on Zenodo.

One transparent caveat regarding reproduction: when I replayed a benchmark on Apple silicon against an index originally generated on x86 Linux, the very first test query retrieved 67 vector candidates instead of 68. As a result, it requested an un-cached reranker score. Floating-point variations across hardware architectures near the similarity threshold are the probable cause. Because I paused the local validation after that first mismatch, a full automated replay from the published archive across disparate architectures remains untested. Subsequent benchmarks will run on Linux GPU instances matching the original setup.


Tested October and November 2026.

Comments