Code Search: Graph-Based Approaches Prove Effective
·2026.05.10 21:12
Key point
For code search, graph structures leveraging LLM-based semantic information are more effective than vector embeddings.
Details
To build persistent structural memory for codebases, a comparison of various retrieval methods showed that the LLM-based semantic graph approach delivered the best performance.
Key Attempts and Limitations:
- Vector Embeddings: Vectorizing code chunks flattens structural relationships such as call graphs, inheritance, and imports, causing significant information loss. It fails to distinguish between functions with similar tokens but different contexts, resulting in low search precision.
- AST Parsing (Tree-sitter): While accurate and fast at grasping structure, it fails to provide semantic information such as business logic or the actual purpose of a function.
Optimal Solution: Graph-Based Semantic Search
- For each file, an LLM is used to generate its purpose, summary, and business context.
- The generated information is stored as nodes in a Neo4j graph, with edges connecting relationships among classes, functions, keywords, and imports.
- Instead of vector similarity, full-text search is leveraged over these semantic fields.
Performance and Cost Management:
- RepoGraph (ICLR 2025) and the Code-Craft study also demonstrated that graph-based approaches yield significant performance gains in SWE-bench and search precision.
- The issue of LLM call cost per file was optimized to a manageable level by applying SHA-256 diffing technology, re-indexing only files that have changed.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.