SEAICLIRJun 18, 2025

cAST: Enhancing Code Retrieval-Augmented Generation with Structural Chunking via Abstract Syntax Tree

arXiv:2506.15655v221 citationsh-index: 9EMNLP
Originality Incremental advance
AI Analysis

This addresses a critical bottleneck in code generation pipelines for developers and AI systems, offering an incremental improvement over existing chunking heuristics.

The paper tackled the problem of poor chunking in retrieval-augmented generation for code, which breaks semantic structures and degrades quality, by proposing a structure-aware method using abstract syntax trees, resulting in performance boosts such as a 4.3-point increase in Recall@5 on RepoEval and a 2.67-point increase in Pass@1 on SWE-bench.

Retrieval-Augmented Generation (RAG) has become essential for large-scale code generation, grounding predictions in external code corpora to improve actuality. However, a critical yet underexplored aspect of RAG pipelines is chunking -- the process of dividing documents into retrievable units. Existing line-based chunking heuristics often break semantic structures, splitting functions or merging unrelated code, which can degrade generation quality. We propose chunking via Abstract Syntax Trees (\ourwork), a structure-aware method that recursively breaks large AST nodes into smaller chunks and merges sibling nodes while respecting size limits. This approach generates self-contained, semantically coherent units across programming languages and tasks, improving performance on diverse code generation tasks, e.g., boosting Recall@5 by 4.3 points on RepoEval retrieval and Pass@1 by 2.67 points on SWE-bench generation. Our work highlights the importance of structure-aware chunking for scaling retrieval-enhanced code intelligence.

Code Implementations1 repo
Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes