Abstract
Automated code summarization is a critical task for software maintenance, yet existing models often suffer from "tunnel vision" by focusing solely on local code snippets. This paper introduces CE-GCS, a novel framework for data denoising and structured context extraction, alongside GA-FCSM, a Transformer-based model designed to integrate project-level information. By utilizing specific calling and dependency rules, the proposed approach achieves state-of-the-art results on the Funcom-java benchmarks, demonstrating that project context is essential for generating semantically rich summaries.
Introduction
Code summarization—the process of generating natural language descriptions for code fragments—is vital for improving code readability and developer productivity. Despite the success of deep learning models, many current approaches fail to capture the developer's intent because they ignore the broader project environment. This "tunnel vision" leads to summaries that describe how a function works but miss why it exists. Furthermore, real-world datasets are often cluttered with noise, such as boilerplate comments and "TODO" tags, which hinder model training. This research addresses these issues by proposing a systematic way to select relevant project context and a robust architecture to fuse this information with local code features.
Methodology
The authors propose a two-stage approach: a preprocessing framework called CE-GCS and a specialized neural architecture named GA-FCSM.
Data Denoising and Context Selection
To mitigate data noise, the CE-GCS framework aggressively cleans the training data by removing non-functional comments and normalizing text. More importantly, it replaces random context selection with structured rules. Calling rules identify functions that invoke the target snippet, while dependency rules identify functions called by the target. This ensures the model receives semantically relevant external information.
GA-FCSM Architecture
The GA-FCSM model is built upon the Transformer architecture but incorporates a multi-stream input system. It processes textual tokens, Abstract Syntax Trees (ASTs), and the extracted project context in parallel.
A central component of this architecture is the Fusion Network, which intelligently merges these three streams. Additionally, a Copy Mechanism allows the decoder to directly extract rare or technical terms from the source code, ensuring high precision in the generated summaries.
Experimental Results
The model was evaluated on the Funcom-java dataset (~2.1 million functions) and its "hard mode" variant, Funcom-java-long, which focuses on complex, long-form code.
Performance Comparison
GA-FCSM consistently outperformed established baselines such as DeepCom and AST-AttendGRU-FC. On the standard Funcom-java set, it achieved a BLEU score of 21.39. On the more challenging Funcom-java-long dataset, it maintained a score of 19.18, highlighting the increasing importance of context as code complexity grows.
The Value of Calling Context
A key insight from the experiments is that Calling Context (who calls the function) is generally more informative than Dependency Context (what the function calls). The "caller" often provides the high-level purpose or "why" of a function, which is the primary goal of a summary.
Discussion and Conclusion
The research demonstrates that structured project context is a powerful signal for code summarization. The Fusion Network serves as the "secret sauce," effectively balancing local syntax with global project semantics. However, the study is currently limited to the Java language and intra-project context. Future work could explore cross-project relationships and the application of these techniques to other programming languages like Python or Rust. By bridging the gap between local code and project-wide intent, GA-FCSM sets a new standard for automated documentation tools.
Summary updated