NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Code Graph Model (CGM): A Graph-Integrated Large Language Model for Repository-Level Software Engineering Tasks

Hongyuan Tao, Ying Zhang, Zhenhao Tang, Hongen Peng, Xukun Zhu, Bingchang Liu, Yingguang Yang, Ziyin Zhang, Zhaogui Xu, Haipeng Zhang, Linchao Zhu, Rui Wang, Hang Yu, Jianguo Li, Peng Di

Abstract

Repository-level software engineering tasks require navigating complex dependencies across massive codebases, a challenge typically addressed by proprietary, agentic systems. We present the Code Graph Model (CGM), a graph-integrated large language model that natively incorporates codebase structure into its attention mechanism. By combining semantic node compression with a graph-aware attention mask and an agentless Retrieval-Augmented Generation (RAG) framework, CGM achieves state-of-the-art performance for open-weight models. On SWE-bench Lite, CGM reaches a 43.00% resolution rate, demonstrating that structured architectural awareness can match or exceed the performance of complex autonomous agents.

1. Introduction

While Large Language Models (LLMs) have demonstrated proficiency in localized code generation, real-world software engineering occurs at the repository level. Tasks such as fixing bugs or implementing features require an understanding of cross-file dependencies, class hierarchies, and complex import structures. Current state-of-the-art solutions often rely on proprietary models (e.g., GPT-4o, Claude 3.5 Sonnet) wrapped in autonomous agentic loops. These agents iteratively execute commands and parse errors, a process that is often expensive, unpredictable, and potentially insecure for proprietary codebases.

The Code Graph Model (CGM) addresses these challenges by moving away from the agentic paradigm. Instead, it focuses on enhancing the underlying model's ability to perceive repository structure directly. By treating a codebase as a text-rich directed graph rather than a flat collection of files, CGM bridges the gap between open-source models and closed-source proprietary systems.

2. Methodology

The core innovation of CGM lies in its integration of structural information into the LLM's transformer architecture.

2.1 Code Graph Construction

CGM represents a repository as a directed graph where nodes represent entities such as files, classes, and functions. Edges represent relationships, including "contains," "calls," "imports," and "extends." This representation preserves the architectural context that is often lost when code is flattened into a linear text prompt.

2.2 Semantic and Structural Integration

To process this graph, CGM employs two primary mechanisms:

  • Semantic Compression: A pretrained CodeT5+ encoder serves as a node-level adapter. It compresses the textual content of each node into a fixed set of "node tokens." This allows the model to process large portions of the codebase within a limited context window by using dense representations.
  • Graph-Aware Attention: Rather than allowing global attention across all node tokens, CGM modifies the LLM’s attention mechanism. It implements a graph-aware attention mask where message passing is restricted to neighboring nodes in the code graph. This effectively mimics the behavior of a Graph Neural Network (GNN) within the transformer blocks, ensuring the model respects the codebase's actual topology.

2.3 Agentless Graph RAG

CGM operates within a deterministic, four-step Retrieval-Augmented Generation (RAG) pipeline, avoiding the unpredictability of autonomous loops:

  1. Rewriter: Clarifies and expands the initial user issue.
  2. Retriever: Extracts a relevant subgraph from the repository based on the issue description.
  3. Reranker: Identifies the specific files and nodes most likely to require modification.
  4. Reader (CGM): The model processes the retrieved context and generates the final code patch.

3. Experimental Evaluation

The authors evaluated CGM across several rigorous benchmarks, focusing on issue resolution and code completion.

3.1 SWE-bench Performance

On SWE-bench Lite, CGM achieved a resolution rate of 43.00%. This result is significant for several reasons:

  • It ranks first among all open-weight models.
  • It outperforms the previous open-source leader (Moatless + DeepSeek-V3) by 12.33%.
  • It competes with and occasionally surpasses closed-source agentic systems.

Similar success was observed on SWE-bench Verified (50.40%) and SWE-bench-java Verified, confirming the model's robustness across different languages and evaluation sets.

3.2 Repository-Level Code Completion

CGM was tested on CrossCodeEval and ComplexCodeEval, which specifically target cross-file dependencies. The 72B parameter version (CGM-Multi) outperformed significantly larger models, such as DeepSeek-V2.5 (236B) and Mistral-Large (123B). This suggests that structural awareness is a more efficient path to repository understanding than simply increasing parameter count.

4. Discussion and Limitations

CGM demonstrates that the "agentic" approach is not the only path to high-performance software engineering AI. By improving the model's native understanding of code structure, deterministic pipelines can achieve state-of-the-art results.

However, limitations remain. The current graph schema is optimized for object-oriented paradigms (Python and Java). Adapting CGM to functional or multi-paradigm languages like Rust or Haskell will require new graph construction logic. Additionally, the initial construction of the code graph introduces an offline overhead (approximately 3 minutes for large repos), though this does not affect inference speed.

5. Conclusion

The Code Graph Model represents a significant step forward for open-source AI in software engineering. By integrating graph-based structural awareness directly into the LLM's attention mechanism, CGM provides a high-performance, privacy-conscious, and predictable alternative to proprietary agentic systems.

Summary updated

BibTeX
@inproceedings{tao2025code,
  author = {Hongyuan Tao and Ying Zhang and Zhenhao Tang and Hongen Peng and Xukun Zhu and Bingchang Liu and Yingguang Yang and Ziyin Zhang and Zhaogui Xu and Haipeng Zhang and Linchao Zhu and Rui Wang and Hang Yu and Jianguo Li and Peng Di},
  title = {{Code Graph Model (CGM): A Graph-Integrated Large Language Model for Repository-Level Software Engineering Tasks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=b98ODdeYq5},
}
Figure