Pull down to go back
Codebase-scale retrieval using AST-derived graphs + BM25 — reducing LLM context from 100K to 5K tokens

Codebase-scale retrieval using AST-derived graphs + BM25 — reducing LLM context from 100K to 5K tokens

使用 AST 衍生圖表 + BM25 進行程式碼庫規模檢索——將大型語言模型上下文從 100K 降至 5K 語言單位

A practical approach for retrieval-augmented generation (RAG) over large codebases that solves a real problem: naive code RAG fails because it treats code like regular text. When you chunk files and embed them, you miss structural relationships — a function in file A calling a type from file C won't show up in similarity searches. This technique uses Abstract Syntax Trees (AST) to build dependency graphs, then combines them with BM25 ranking to pull only the most relevant code snippets. The payoff? Shrinking your LLM context window from 100K tokens down to just 5K while keeping the same quality. If you're building code analysis tools or AI-assisted development platforms, this is worth understanding.