Skip to main content
QUICK REVIEW

[Paper Review] Fine-grained Pseudo-code Generation Method via Code Feature Extraction and Transformer

Guang Yang, Yanlin Zhou|arXiv (Cornell University)|Feb 12, 2021
Software Engineering ResearchComputer Science5 citations
TL;DR

This paper proposes DeepPseudo, a Transformer-based method that combines code feature extraction via CNN with sequence-to-sequence learning to generate fine-grained pseudo-code from source code. By fusing local code features with global context representations and incorporating adversarial training, DeepPseudo achieves state-of-the-art performance on Django and SPoC datasets, outperforming seven baselines across four evaluation metrics.

ABSTRACT

Pseudo-code written by natural language is helpful for novice developers' program comprehension. However, writing such pseudo-code is time-consuming and laborious. Motivated by the research advancements of sequence-to-sequence learning and code semantic learning, we propose a novel deep pseudo-code generation method DeepPseudo via code feature extraction and Transformer. In particular, DeepPseudo utilizes a Transformer encoder to perform encoding for source code and then use a code feature extractor to learn the knowledge of local features. Finally, it uses a pseudo-code generator to perform decoding, which can generate the corresponding pseudo-code. We choose two corpora (i.e., Django and SPoC) from real-world large-scale projects as our empirical subjects. We first compare DeepPseudo with seven state-of-the-art baselines from pseudo-code generation and neural machine translation domains in terms of four performance measures. Results show the competitiveness of DeepPseudo. Moreover, we also analyze the rationality of the component settings in DeepPseudo.

Motivation & Objective

  • To address the challenge of time-consuming, manual pseudo-code creation for novice developers.
  • To improve program comprehension by automatically generating human-readable, natural language descriptions of source code.
  • To enhance pseudo-code generation through fusion of local code features and global context representations.
  • To validate the effectiveness and robustness of the proposed model using real-world code corpora.
  • To provide open-source access to code, models, and datasets to support reproducibility and future research.

Proposed method

  • A Transformer encoder processes source code to learn global contextual representations.
  • A CNN-based code feature extractor captures local syntactic and structural features of the code.
  • The encoded representations from the Transformer and CNN are concatenated and fed into a decoder for pseudo-code generation.
  • The decoder uses beam search to generate high-quality, natural language pseudo-code sequences.
  • Adversarial training via PGD is applied to the embedding layers to improve model robustness and reduce overfitting.
  • Multiple attention mechanisms, including norm-attention, are evaluated to optimize decoding performance.

Experimental results

Research questions

  • RQ1Does the integration of code feature extraction improve pseudo-code generation performance compared to standard Transformer models?
  • RQ2How does the choice of attention mechanism (e.g., norm-attention) affect the model’s performance?
  • RQ3What is the optimal configuration for hyperparameters such as model depth (N), model width (d_model), and kernel size (K)?
  • RQ4How does adversarial training impact the model’s robustness and generalization?

Key findings

  • DeepPseudo outperforms seven state-of-the-art baselines on both the Django and SPoC datasets across four evaluation metrics: BLEU, ROUGE-L, CIDER, and METEOR.
  • On the Django dataset, DeepPseudo achieved a BLEU score of 50.817, ROUGE-L of 39.201, CIDER of 77.773, and METEOR of 5.813.
  • On the SPoC dataset, DeepPseudo achieved a BLEU score of 46.454, ROUGE-L of 40.809, CIDER of 63.430, and METEOR of 4.113.
  • The ablation study confirmed that the code feature extractor significantly improves performance, with the highest gains observed when combined with norm-attention.
  • Optimal hyperparameters were found to be N=3, d_model=256, and kernel_size=5, as larger values led to training instability and performance degradation.
  • Adversarial training improved model robustness and reduced overfitting, particularly in low-resource settings.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.