EduFuncSum: a function-wise progressive transformer for code summarization in undergraduate programming education

Yi Rong, M. Xu, Ruiteng Li, Xin Lin, Wenting BaoJournal of King Saud University - Computer and Information Sciences 2025 · DOI

TL;DR

EduFuncSum is a novel Transformer-based model designed to summarize multi-function codebases by mimicking an instructional walkthrough. Unlike traditional models that summarize functions in isolation, EduFuncSum generates summaries progressively, conditioning each new description on the summary of the previous function to ensure global coherence and pedagogical value for students.

The Challenge: Bridging the "Big Picture" Gap

In undergraduate programming education, students often struggle to see the "big picture." While they might understand what a single line or a single function does, they often fail to grasp how multiple functions interact to achieve a larger goal.

Current state-of-the-art (SOTA) code summarization tools typically operate at the single-function level. They produce isolated "docstrings" that ignore the broader context of the program. For a novice learner, reading five disconnected summaries of five interacting functions is far less helpful than a cohesive narrative that explains how data flows from one part of the program to the next.

The EduFuncSum Architecture

The authors propose EduFuncSum, a "function-wise progressive transformer." Its architecture is built on a standard Transformer encoder-decoder backbone but introduces specialized modifications to handle multi-function context.

The EduFuncSum architecture featuring progressive summarization and a gating mechanism.

As shown in the architecture diagram above, the model utilizes three key innovations:

  1. Progressive Summarization: The model processes a program function-by-function. When generating a summary for function $F_i$, the decoder doesn't just look at the code for $F_i$; it also "listens" to the summary it just wrote for function $F_{i-1}$ via a Previous Summary Encoder.
  2. Cross-Function Attention & Gating: To manage these two different inputs (the current code and the previous summary), the authors implemented a specialized gating mechanism. This sigmoid-based gate dynamically weights the two contexts. If the current code is self-explanatory, the gate relies on the code; if the function relies heavily on a previously established object or variable, the gate allows more information from the prior summary to flow through.
  3. Summary Integration: Finally, the model concatenates these context-aware snippets into a single, cohesive multi-sentence description of the entire program.

This approach effectively turns the summarization process into a "storytelling" task, where each chapter (function) builds upon the last.

Key Insights and Results

The model was evaluated on three major public benchmarks: CodeSearchNet (CSN), FUNCOM, and CodeXGLUE. Because these datasets are typically structured as single (code, summary) pairs, the authors simulated multi-function scenarios by concatenating related functions during testing.

Quantitative Performance

EduFuncSum consistently outperformed ten SOTA baselines, including heavyweights like CodeT5 and OpenAI Codex. On the CodeSearchNet Python dataset, EduFuncSum achieved a BLEU-4 score of 22.45, surpassing OpenAI Codex (20.98) and CodeT5 (20.53). Similar gains were observed in ROUGE-L and METEOR metrics across all datasets.

Pedagogical Impact

In a human study involving undergraduate CS students, EduFuncSum scored significantly higher in "Learning Support" (4.28/5) compared to CodeT5 (3.61/5). Students noted that the summaries felt like a "coherent explanation" rather than a disjointed list of facts. The researchers found that providing the previous summary didn't just make the overall program description better; it actually improved the accuracy of the individual function summaries by allowing the model to use more precise, context-aware terminology.

Limitations and Future Work

While powerful, the authors acknowledge a few hurdles:

  • Logic Blindness: Like most LLM-based tools, EduFuncSum can sometimes miss deep semantic errors, such as an infinite loop, if the function name and structure look "normal."
  • Scaling to Large Systems: The current model relies on a linear sequence of functions. Future versions may need to incorporate static analysis to determine the best "narrative order" for complex, non-linear call graphs.
  • Exposure Bias: There is a risk that a small error in an early summary could "snowball" into later ones, though the Transformer decoder remained remarkably stable in initial experiments.

Summary updated

Abstract

Automatic code summarization holds significant promise for enhancing program comprehension in undergraduate programming education. Traditional end-to-end summarization models generate isolated descriptions for individual functions, but they often fail to convey how multiple functions interact, limiting their pedagogical value. Moreover, existing approaches rarely align summaries with educational objectives, such as guiding novice learners through code structure and logic. To address these gaps, we propose EduFuncSum, a novel Transformer-based approach to code summarization designed specifically for undergraduate programming courses. EduFuncSum decomposes a program into its constituent functions and then generates summaries in a progressive, function-wise manner: each function’s summary is conditioned on both its own code and the preceding summary, thereby building context step by step. This progressive summarization mirrors an instructional walkthrough-function by function-yielding cohesive, context-rich explanations of multi-function codebases. We integrate specialized cross-function attention and summary-integration mechanisms within a Transformer backbone to ensure both local accuracy and global coherence. Empirical evaluation on three public benchmarks demonstrates that EduFuncSum surpasses state-of-the-art models in BLEU-4, ROUGE-L, and METEOR, and ablation studies confirm the value of its progressive design. By producing sequential, context-aware summaries, EduFuncSum offers a powerful pedagogical tool for helping students grasp complex programs and for assisting educators in generating clear documentation and assessments.
BibTeX
@article{rong2025edufuncsum,
  author = {Yi Rong and M. Xu and Ruiteng Li and Xin Lin and Wenting Bao},
  title = {{EduFuncSum: a function-wise progressive transformer for code summarization in undergraduate programming education}},
  journal = {Journal of King Saud University - Computer and Information Sciences},
  year = {2025},
  doi = {10.1007/s44443-025-00075-6},
}
Figure