Repository navigation
Studio: fast incremental RAG indexing (warm embedder + FTS5) - #5899
danielhanchen wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new documentation file, studio/RAG_FAST_INDEXING.md, which outlines the design, root causes of slow indexing, proposed optimizations (such as warming the embedder at startup, in-process ingestion, and incremental SQLite FTS5 BM25), and validation strategies for fast incremental indexing in Studio RAG. There are no review comments provided, and I have no additional feedback to offer.
… behind UNSLOTH_RAG_FAST
Benchmark results (real Studio HTTP API, baseline vs
|
| Document | Baseline | Improved | Speedup |
|---|---|---|---|
| attention 1706.03762 | 23.4 s | 7.4 s | 3.2x |
| bert 1810.04805 | 24.6 s | 8.0 s | 3.1x |
| rag 2005.11401 | 23.2 s | 6.9 s | 3.4x |
| rfc9110.txt | 19.4 s | 1.2 s | 16x |
| mean | 22.7 s | 5.9 s | ~4x |
Scaling (8 small docs into one KB, per-document): baseline 17.6 s/doc, improved 0.12 s/doc.
Retrieval accuracy (no regression)
| Mode | Baseline R@5 / MRR | Improved R@5 / MRR |
|---|---|---|
| dense | 1.000 / 0.875 | 1.000 / 0.875 |
| hybrid | 1.000 / 0.833 | 1.000 / 0.844 |
Indexing a paper drops from ~23 s to ~7 s and a small document from ~18 s to ~0.12 s, accuracy held.
Cause of the baseline cost: the embedder is reloaded inside a fresh spawn subprocess on every
upload, plus a full BM25 scope rebuild per document. UI walkthrough and local-GGUF chat path next.
End-to-end validation in the real Studio UI (Playwright + local GGUF)Drove both Studios through the actual web UI with Playwright and the local
The fast path preserves the PR's full RAG behavior (document types, RAG toggle, tool-call retrieval |
"Shorter" follow-up: trimmed RAG surface (branch
|
| Subsystem | LoC removed | Why it is safe |
|---|---|---|
| cross-encoder reranker | ~375 (with test) | enable_rerank=False everywhere; off by default, adds a second model download + a candidate-widening pass on every search |
| late chunking (Jina single-pass) | ~360 (with test) | chunking_strategy defaults to standard; the standard per-chunk encoder already hits Recall@5 = 1.0 on the gold set |
Net git diff --shortstat: 10 files, 9 insertions, 777 deletions. RAG suite: 99 passed (the 2
multimodal failures are a pre-existing test-isolation issue on the base branch, reproduced there
unchanged, not introduced by the trim).
Assessed but intentionally kept (removable, but coupled to persisted schema + the frontend
citation/preview UX, so not ripped out unattended):
- preview / chunk-locator (~4.5K incl. frontend): retrieval and the tool do not depend on it, but
the preview routes back the citation -> source-preview UX this PR ships. - multimodal captioning + image embeddings (~0.5-0.9K):
mode/kind/image_pathare persisted
columns the preview routes read, so removing it cascades into preview/locator and reduces the
"many document types" coverage.
Net: the clean, fully-testable trim is ~768 lines; the larger preview/locator + multimodal
removals are documented as a coordinated frontend follow-up rather than an unattended change.
|
Superseded by #5910. #5910 (clean-room compact RAG) already incorporates the fast-indexing
Since this PR is stacked on |
Summary
Stacked on
feature/rag(PR #5759). Keeps that PR's UX and retrieval accuracy while cuttingper-document indexing from about a minute to a few seconds. All changes sit behind a single
UNSLOTH_RAG_FAST=1flag, so with the flag unset the behavior is identical tofeature/rag.This PR is a running progress log; it is updated as benchmark runs complete. Details and live
results are in
studio/RAG_FAST_INDEXING.md.Root cause of the slow path (measured on feature/rag)
spawnsubprocess on every upload, so the cold model loadrecurs each time rather than once at startup.
Change
document's chunks. Dense (sqlite-vec) and RRF fusion are unchanged.
Validation
Two isolated Studios (baseline vs improved), same corpus and model, driven through the real UI with
Playwright. Authoritative corpus (arXiv Attention/BERT/RAG, RFC 9110). Local GGUF
unsloth/Qwen3.5-9B-GGUFfor the chat tool path. Metrics: upload-to-ready latency, Recall@k/MRR,scaling, and end-to-end UI with citations.