[Paper Review] DeepSumm -- Deep Code Summaries using Neural Transformer Architecture
This paper proposes DeepSumm, a neural transformer-based model for automatic source code summarization in Java, replacing recurrent architectures with self-attention mechanisms. It achieves a BLEU score of 17.99 on a test set of 2.1M code-comment pairs, reducing training time by over 50% compared to RNN-based models while outperforming the baseline in both speed and performance.
Source code summarizing is a task of writing short, natural language descriptions of source code behavior during run time. Such summaries are extremely useful for software development and maintenance but are expensive to manually author,hence it is done for small fraction of the code that is produced and is often ignored. Automatic code documentation can possibly solve this at a low cost. This is thus an emerging research field with further applications to program comprehension, and software maintenance. Traditional methods often relied on cognitive models that were built in the form of templates and by heuristics and had varying degree of adoption by the developer community. But with recent advancements, end to end data-driven approaches based on neural techniques have largely overtaken the traditional techniques. Much of the current landscape employs neural translation based architectures with recurrence and attention which is resource and time intensive training procedure. In this paper, we employ neural techniques to solve the task of source code summarizing and specifically compare NMT based techniques to more simplified and appealing Transformer architecture on a dataset of Java methods and comments. We bring forth an argument to dispense the need of recurrence in the training procedure. To the best of our knowledge, transformer based models have not been used for the task before. With supervised samples of more than 2.1m comments and code, we reduce the training time by more than 50% and achieve the BLEU score of 17.99 for the test set of examples.
Motivation & Objective
- To address the high cost and low coverage of manual code documentation in software development.
- To improve upon traditional template-based and heuristic methods that lack flexibility and scalability.
- To evaluate the effectiveness of the transformer architecture—previously untested in code summarization—against established RNN-based seq2seq models.
- To reduce training time and improve inference efficiency without sacrificing summarization quality.
- To explore the potential of self-attention mechanisms in capturing long-range dependencies in code sequences more effectively than recurrence.
Proposed method
- Adopts a sequence-to-sequence transformer architecture with multi-head self-attention and feed-forward networks, eliminating recurrent units.
- Trains on a large-scale dataset of 2.1 million Java method-comment pairs, tokenizing code and comments into subword units.
- Uses a standard transformer encoder-decoder structure with learned positional embeddings, replacing RNNs for both encoder and decoder.
- Employs cross-attention mechanisms to align source code tokens with target summary words during decoding.
- Applies label smoothing and Adam optimization with a fixed learning rate, training for only 5 epochs due to computational constraints.
- Evaluates performance using BLEU score and analyzes attention distributions to interpret model behavior on sample inputs.
Experimental results
Research questions
- RQ1Can a transformer-based architecture outperform RNN-based seq2seq models in code summarization in terms of both BLEU score and training efficiency?
- RQ2Does eliminating recurrence in the model architecture lead to faster training without significant degradation in summarization quality?
- RQ3How do attention distributions in the transformer model reflect alignment between code tokens and summary words?
- RQ4To what extent does the absence of structural or syntactic code composition in the model affect performance compared to state-of-the-art methods?
- RQ5Can a simpler, non-recurrent architecture achieve competitive results with significantly reduced training time on code summarization tasks?
Key findings
- The transformer-based DeepSumm model achieved a BLEU score of 17.99 on the test set, outperforming the RNN-based baseline by more than one BLEU point.
- Training time was reduced by over 50% compared to the recurrent model, demonstrating the efficiency gains of the self-attention mechanism.
- The model successfully generated meaningful summaries for simple methods, such as "gets the child" for a getter method, with attention correctly aligning to relevant tokens.
- In complex cases, such as method name and return type mismatches, the model occasionally generated incorrect terms (e.g., "water" instead of "oxygen"), indicating limitations in semantic understanding.
- The model’s performance was limited by short training duration (only 5 epochs) and lack of structural code representation, suggesting that longer training and architectural enhancements could improve results.
- Despite not reaching state-of-the-art performance, the results confirm the viability and advantages of transformers for code summarization, especially in training speed and scalability.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.