Abstract
MultiCoder is a novel pre-training framework designed to enhance code completion for low-resource programming languages. By integrating multi-lingual pre-training with a Programming Language-level Mixture-of-Experts (PL-MoE) strategy, the framework scales model capacity for specific languages without significant computational overhead. Evaluation shows that MultiCoder effectively mitigates the "curse of multilinguality," outperforming standard models on low-resource languages like Ruby and Go.
Introduction
Modern code completion tools, such as GitHub Copilot, rely on large-scale language models that typically excel in high-resource languages like Python or Java but falter in low-resource environments. While training a single model on multiple languages (MultiPL) facilitates cross-lingual knowledge transfer, it often hits a "capacity bottleneck." In fixed-parameter models, adding more languages causes internal representations to "crowd," leading to performance degradation across all languages—a phenomenon known as the "curse of multilinguality." Standard Mixture-of-Experts (MoE) models attempt to address this via sparse routing, yet they lack guarantees that specific experts will specialize in the nuances of individual languages.
The MultiCoder Framework
MultiCoder addresses these challenges using a 12-layer decoder-only Transformer architecture based on GPT-2. The model employs a hierarchical design to balance general programming knowledge with language-specific specialization.
Hierarchical Layering
- Dense Bottom Layers: The first eight layers are standard dense Transformer layers. These layers focus on learning "surface-level" information and general programming patterns common to all languages.
- PL-MoE Top Layers: The final four layers implement the Programming Language-level Mixture-of-Experts strategy.
- Language-Specific Experts: Experts are assigned to specific programming languages based on data distribution, ensuring dedicated capacity for unique language features.
- Shared Experts: A set of shared experts remains accessible to all languages, facilitating the learning of language-agnostic logic and common literals.
Sparse Routing
MultiCoder utilizes sparse routing where each token is directed to the top-2 experts—typically one language-specific and one shared. This approach maintains low computational overhead while effectively increasing the total parameter count available for processing.
Experimental Setup and Results
The framework was pre-trained on a comprehensive dataset compiled from CodeSearchNet and Pytorrent, covering Go, Java, JavaScript, PHP, Python, and Ruby. Evaluation was conducted using CodeXGLUE and a new multi-programming-lingual dataset, MultiCC.
MultiCoder consistently outperforms both mono-lingual and standard multi-lingual baselines. On the CodeXGLUE Java corpus, it improved Accuracy by +1.16 and Edit Similarity by +1.09 over CodeGPT.
Specialization and Efficiency
The PL-MoE routing mechanism is highly efficient, utilizing only about 19% of available experts for any given language while achieving superior results. The hierarchical structure mimics human learning by mastering syntax in shared layers before specializing in advanced semantics.
As shown in the expert utilization heatmaps, PL-MoE demonstrates much clearer specialization compared to the more uniform distribution of standard MoE. This specialization is particularly beneficial for low-resource languages; for instance, Ruby saw improvements of +1.83 in Accuracy and +0.81 in Edit Similarity over the baseline.
Cross-Lingual Transfer
A notable finding was the benefit low-resource languages like Go received from high-resource counterparts like Java. The shared experts effectively bridged the gap between languages with similar syntax and literals, proving that common ground for language-agnostic knowledge is vital for performance.
Conclusion and Future Work
MultiCoder successfully breaks the capacity bottleneck in multilingual code completion. While currently focused on token-level completion using a GPT-2 backbone, future research will explore applying the PL-MoE strategy to other architectures like BERT and T5, as well as evaluating performance on larger tasks such as text-to-code generation.
Summary updated