[R] Graph-Oriented Generation (GOG): Replacing Vector R.A.G. for Codebases with Deterministic AST Traversal (70% Average Token Reduction)

Hey everyone. I’m a 5 YoE full-stack engineer who has been crossing over into AI research. Like many of you, I got incredibly frustrated with Vector RAG hallucinating import paths and losing context when navigating deep codebases.

RAG treats strict software architecture like a probabilistic novel. I wanted to see what happened if we treated it like a mathematical graph instead. I wrote a white paper and built a framework around this concept called Graph-Oriented Generation (GOG).

The core idea is offloading architectural reasoning from the LLM to a deterministic Symbolic Reasoning Model (SRM).

How it works:

  1. The Graph: Instead of chunking text, the SRM parses the entire repository using an AST and builds a strict Directed Acyclic Graph (DAG) of all dependencies.
  2. Deterministic Traversal: We use zero-shot lexical seeding to find the user’s target nodes, and then run a strict shortest-path / descendant-capture traversal to isolate the exact execution path. If a file isn’t mathematically on that path, it’s dropped.
  3. O(1) State Evolution: Standard RAG requires O(N) re-indexing when a file changes. The SRM intercepts file saves and uses torch.cat to perform O(1) tensor surgery in-memory, hot-swapping the new AST nodes instantly.

The Benchmark Data: I ran a 3-tier complexity gauntlet using a highly constrained local model (Qwen 0.8B) on a procedurally generated 100+ file Vue/TS enterprise maze loaded with “red herring” files.

  • Local Compute Time (Context Assembly): 1.619s (RAG) vs. 0.001s (GOG) -> 99.9% Reduction
  • Tokens Sent to LLM (Easy Tier): 4,230 (RAG) vs. 451 (GOG) -> 89.3% Reduction
  • Total Execution Time: 136.77s vs. 29.96s -> 78.1% Reduction

By feeding the 0.8B model a pristine, noise-free execution path, it flawlessly solved deep architectural routing that caused the RAG-backed model to suffer catastrophic context collapse. It effectively demotes the LLM from a “reasoning engine” to a “syntax translator.”

I’m relatively new to formal research, so I am actively looking for rigorous feedback, teardowns of the methodology, or anyone interested in collaborating on the next phase (applying this to headless multi-agent loops).

Would love to hear your thoughts on where this architecture falls short or how it might scale into standard IDE environments!

submitted by /u/BodeMan5280
[link] [comments]

Liked Liked