The AI industry defaults to embeddings for everything. Embed your code, vector search for relevant chunks, stuff them in a prompt. It's the RAG pattern, and it works — for text.
Code is not text. Code has structure: functions call other functions, types reference other types, files import other files. Embeddings flatten this structure into vectors, losing the relationship information that makes code intelligence possible.
What Embeddings Are Good At
Embeddings capture semantic similarity. "Find code similar to this function" returns functions that do comparable things, even if they use different names and patterns.
Good for:
- "Find functions similar to validateSession"
- "Show me authentication-related code"
- "Find examples of error handling patterns"
What Embeddings Miss
Embeddings don't capture structural relationships. They can't answer:
- "What calls validateSession?" (requires call graph)
- "What breaks if I change this return type?" (requires dependency analysis)
- "Which files always change together?" (requires change coupling analysis)
- "What feature does this file belong to?" (requires community detection on the dependency graph)
Knowledge Graphs for Code
A code knowledge graph represents:
- Nodes: files, functions, types, features
- Edges: imports, calls, references, depends-on, belongs-to
- Properties: authorship, change frequency, complexity metrics
This graph answers structural questions that embeddings cannot.
The Hybrid Approach
The best code intelligence systems use both:
- Knowledge graph for structural queries (call paths, dependencies, blast radius)
- Embeddings for semantic queries (find similar code, natural language Q&A)
- Graph-augmented retrieval — use embedding search to find entry points, then graph traversal to expand to structurally related code
This hybrid approach is what Glue uses. Vector search for initial relevance, knowledge graph for structural completeness. The combination produces answers that are both semantically relevant and structurally accurate.
Originally published on glue.tools. Glue is the pre-code intelligence platform — paste a ticket, get a battle plan.
Top comments (0)