27th EAAAI (EANN) 2026, 16 - 19 July 2026, Chania, Crete, Greece

A Hybrid Transformer-GNN Architecture for Code Understanding

Sanketi Advay, Verulkar Aditya, M Saji Abhijith, Arya Arti

Abstract:

  Modern code intelligence tools struggle to achieve a unified understanding of code semantics and structure, limiting their applicability to advanced refactoring, optimization, and evolution tasks. This paper proposes a novel hybrid architecture that combines sequential transformers for capturing semantic relationships in code with Graph Neural Networks (GNNs) for modeling its structural properties. A hybrid architecture is proposed in this paper where Transformer and GNN layers alternate, enhancing both context-aware representation and structural reasoning. The alternating arrangement between Transformer and GNN layers enables the model to iteratively refine both semantic and structural representations. Each pass enhances the other’s context awareness—Transformers benefit from graph-level dependencies, while GNNs gain richer token-level semantics—resulting in more precise and comprehensive code understanding. The proposed model is evaluated on the 150k Python Dataset for the task of source code vulnerability detection. Our results demonstrate a 92.3\% accuracy and 92.0\% F1-score, outperforming existing baselines like CodeBERT and GraphCodeBERT while maintaining a 20\% improvement in training efficiency. The proposed architecture sets a new direction for intelligent software engineering tools, bridging the semantic-structural gap in code comprehension.  

*** Title, author list and abstract as submitted during Camera-Ready version delivery. Small changes that may have occurred during processing by Springer may not appear in this window.