NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Unified Pre-training for Program Understanding and Generation

Wasi Uddin Ahmad, Saikat Chakraborty, Baishakhi Ray, Kai-Wei Chang

In software engineering, code and natural language (NL) are deeply intertwined. Developers write code to implement logic while relying on natural language for documentation, bug reports, and collaborative discussions. Bridging the semantic gap between these two modalities is a central challenge in AI for software engineering. This paper introduces PLBART, a bidirectional Transformer-based model designed to unify the understanding and generation of both code and natural language.

The Need for a Unified Model

Existing models for code often specialize in either understanding or generation. Encoder-only models like CodeBERT excel at discriminative tasks such as classification and vulnerability detection but struggle with generative tasks. Conversely, decoder-only models like CodeGPT are optimized for generation but may lack the deep contextual understanding required for complex reasoning.

PLBART addresses this by employing a sequence-to-sequence (seq2seq) architecture, enabling it to handle a wide spectrum of tasks—from summarizing code into natural language to translating logic between different programming languages.

Methods: Denoising Pre-training

PLBART (Program and Language BART) utilizes a Transformer architecture with a 6-layer encoder and a 6-layer decoder. The model's strength lies in its denoising autoencoding pre-training objective. Instead of simple next-token prediction, PLBART is trained to reconstruct original, clean code or text from corrupted versions.

Examples of denoising pre-training objectives for PLBART across natural language, Java, and Python.

The authors employed three primary noise strategies:

  1. Token Masking: Random tokens are replaced with a [MASK] symbol.
  2. Token Deletion: Random tokens are removed entirely.
  3. Token Infilling: Multiple contiguous tokens are replaced with a single [MASK] token.

By learning to "fix" these corruptions, PLBART internalizes the structural and syntactical rules of programming languages and their relationship to natural language. The model was pre-trained on a massive corpus: 470 million Java functions, 210 million Python functions, and 47 million StackOverflow posts.

Evaluation and Key Insights

The researchers evaluated PLBART on the CodeXGLUE benchmark, covering tasks such as code summarization, generation, translation, program repair, and classification.

Cross-Language Generalization

A significant finding was PLBART's ability to generalize to "unseen" languages. Despite being pre-trained only on Java and Python, PLBART achieved state-of-the-art results on languages like Ruby and Go. This suggests the model learns a "universal" representation of programming logic—such as loops, conditionals, and data structures—that transcends specific syntax.

Bimodal Alignment and Logical Reasoning

Through its exposure to both code and StackOverflow discussions, PLBART learns to align semantic spaces. It recognizes functional equivalents across languages (e.g., Python's sorted() vs. Java's Arrays.sort()) and demonstrates an understanding of logical flow, such as recognizing the equivalence between nested if-else blocks and else if structures.

Key Results

PLBART consistently outperformed or matched established models like CodeBERT and GraphCodeBERT across various benchmarks.

  • Code Summarization: PLBART showed an overall average improvement of 0.49 BLEU over CodeBERT. Notably, it achieved a 16% improvement in Ruby, a language not present in its pre-training data.
  • Code Generation: On the Concode dataset (NL to Java), PLBART reached a 38.52 CodeBLEU score, significantly outperforming GPT-2 and specialized variants like CodeGPT-adapted.
  • Program Repair: In fixing buggy Java code, PLBART generated 17.13% more correct fixes than CodeBERT on the "small" dataset.
Performance comparison on code summarization tasks across six programming languages, highlighting PLBART's superior performance in most categories.

Conclusion and Future Directions

PLBART represents a significant step toward a unified AI assistant for developers. While it shows immense promise, challenges remain, such as lower performance on languages with distinct syntax like PHP. Future work will explore multitask fine-tuning to determine if simultaneous training on diverse tasks like bug fixing and code generation can further enhance the model's general-purpose capabilities.

Summary updated

BibTeX
@inproceedings{ahmad2021unified,
  author = {Wasi Uddin Ahmad and Saikat Chakraborty and Baishakhi Ray and Kai-Wei Chang},
  title = {{Unified Pre-training for Program Understanding and Generation}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.naacl-main.211},
}
Figure