AST-Graphs Outperform LLM-Generated for Code RAG Accuracy
Deterministic AST-derived knowledge graphs (DKB) demonstrated superior correctness for multi-hop architectural reasoning queries and significantly lower indexing costs, building graphs in seconds compared to LLM-generated graphs (LLM-KB) which take minutes, while also achieving higher coverage.
The top 3
- AST-Graphs' Accuracy Lead: Multi-Hop Code Reasoning: Deterministic AST-derived knowledge graphs (DKB) achieve significantly higher correctness for complex architectural queries, scoring 15/15 on multi-hop tracing tasks where LLM-generated graphs managed 13/15 (with partials) and vector-only RAG scored 6/15, often hallucinating.
- AST-Graphs Preserve Code's Deep Structural Semantics: Unlike LLM-generated embeddings that often treat code as flat text, AST-Graphs explicitly capture the hierarchical relationships, control flow, and data dependencies inherent in source code, preventing the loss of critical structural context crucial for accurate retrieval.
- Beyond Keywords: AST-Graphs for Semantic Code Retrieval: AST-Graphs empower RAG systems to retrieve code based on deep semantic understanding and functional equivalence, rather than superficial lexical matches. This allows for deterministic traversal of code relationships and more relevant context for generation tasks.
Sources
Open the full topic