Abstract
CodeT5+ is a new family of open-source encoder-decoder large language models (LLMs) designed to excel at both code understanding and generation. By employing a flexible architecture that can operate in encoder-only, decoder-only, or unified modes and a compute-efficient scaling strategy using frozen off-the-shelf LLMs, CodeT5+ achieves state-of-the-art results across 20+ code-related benchmarks, including a 35.0% pass@1 on HumanEval.
Introduction
Despite the success of models like Codex and StarCoder, existing code LLMs typically suffer from two main limitations: architectural rigidity and limited pretraining objectives. Most models are either encoder-only (optimized for understanding and retrieval) or decoder-only (optimized for generation). Even existing encoder-decoder models often use a "one-size-fits-all" approach that leads to suboptimal performance on specific tasks. Furthermore, many models rely on a single objective like next-token prediction, creating a "pretrain-finetune gap" where the model isn't optimized for the diversity of downstream tasks.
The authors propose CodeT5+ to bridge these gaps, creating a "compositional" model where different modules can be activated depending on whether the task requires understanding, generation, or a mix of both.
Architecture and Methodology
The core of CodeT5+ lies in its flexible architecture and its multi-stage pretraining strategy.
Flexible Encoder-Decoder
The model is built so that its components can be combined differently. For retrieval, the encoder is used; for code completion, the decoder; and for summarization, the full pipeline. This compositionality allows CodeT5+ to treat the encoder and decoder as specialized tools that can be "activated" based on the specific requirements of the task.
Multi-Stage Pretraining
- Stage 1 (Unimodal Code): Uses span denoising (filling in missing chunks) and Causal Language Modeling (predicting the next token) to learn code structure.
- Stage 2 (Bimodal Text-Code): Employs contrastive learning (aligning text and code embeddings), text-code matching, and cross-modal generation to bridge the gap between natural language and programming logic.
Compute-Efficient Scaling
To scale up to 16B parameters without starting from scratch, the authors utilized a "shallow encoder, deep decoder" setup. They initialized the decoder with frozen, off-the-shelf code LLMs (like CodeGen) and only trained a small encoder and the cross-attention layers. This significantly reduces the number of trainable parameters while gaining new capabilities.
Experimental Results
CodeT5+ was pretrained on an enlarged version of CodeSearchNet combined with a newly curated GitHub Code dataset, totaling 51.5 billion tokens. The model was further refined using 20,000 synthetic instructions to better align outputs with human-like prompts.
The model demonstrated dominant performance across over 20 benchmarks:
- HumanEval: The 16B instruction-tuned version achieved 35.0% pass@1, surpassing other open-source models and even OpenAI’s
code-cushman-001. - Math Programming: Small versions of CodeT5+ (770M) outperformed models 100x larger, such as the 137B LaMDA, on MathQA-Python.
- Code Retrieval: Achieved a +3.2 average MRR (Mean Reciprocal Rank) improvement over previous state-of-the-art models across 8 retrieval tasks.
- Code Completion: Showed a +2.1 average Exact Match improvement on line-level completion tasks.
Discussion and Conclusion
The "shallow encoder, deep decoder" approach proves that retraining massive models from scratch is not always necessary to gain new capabilities. By keeping the large decoder frozen and training a smaller "adapter" encoder, CodeT5+ achieved SOTA results with much higher efficiency.
However, limitations remain regarding the quality of synthetic instruction data and the high resource intensity required for serving 16B parameter models. Future work will focus on exploring more diverse pretraining data and further optimizing serving efficiency for real-world developer tools.
Summary updated