Abstract
Training Large Language Models (LLMs) to handle multiple programming languages effectively remains a significant challenge, often forcing a choice between storage-heavy specialized models and performance-limited generalists. This paper introduces Mix-of-Language-Experts (MOLE), a novel parameter-efficient fine-tuning architecture. MOLE decomposes programming tasks into language-agnostic logic and language-specific syntax by utilizing a shared LoRA adapter alongside dedicated expert adapters. Our results demonstrate that MOLE outperforms standard LoRA methods and achieves parity with full fine-tuning across diverse benchmarks, including code summarization, synthesis, and translation.
1. Introduction
The proliferation of programming languages necessitates LLMs that are proficient across various syntaxes and paradigms. Current fine-tuning strategies typically fall into two categories: the Generalist Approach, which uses a single set of parameters for all languages, and the Specialist Approach, which trains distinct models for each language. The former often fails to capture the subtle nuances of specific languages (e.g., the distinct behavior of Python’s elif versus C++'s else if), while the latter incurs prohibitive computational and storage costs due to parameter duplication.
Furthermore, independent specialists cannot leverage cross-lingual knowledge. Logic learned in a high-resource language like Python should ideally benefit performance in low-resource languages like Rust. To bridge this gap, we propose Mix-of-Language-Experts (MOLE), an architecture designed to maximize knowledge sharing while preserving syntactic specialization.
2. The MOLE Architecture
MOLE builds upon the Low-Rank Adaptation (LoRA) framework, introducing a modular hierarchy of adapters:
- Shared Adapter: This component is designed to capture universal programming patterns, such as control flow, algorithmic logic, and data structures, which are consistent across most imperative and object-oriented languages.
- Expert Adapters ($K$): A set of $K$ adapters, each fine-tuned for the specific syntax and semantics of a single programming language (e.g., C++, Java, Go).
- NL (Natural Language) Adapter: A specialized adapter dedicated to processing non-code elements, such as comments, docstrings, and user instructions.
This separation of concerns reflects the inherent structure of programming: logic is largely language-agnostic, whereas syntax is language-specific.
3. Technical Innovations
3.1 Dynamic Routing
To manage the multi-adapter system, MOLE employs a dynamic routing mechanism. During inference, the model identifies the target language—often via metadata or code block indicators (e.g., ```python)—and activates the corresponding expert adapter in tandem with the shared and NL adapters. This ensures that the model applies the correct syntactic constraints for the task at hand.
3.2 SVD-based Initialization
Rather than initializing adapter weights randomly, MOLE utilizes a strategy inspired by Principal Singular Values and Singular Vectors Adaptation (PiSSA). By performing Singular Value Decomposition (SVD) on the base model's pre-trained weights, the most significant components (representing core knowledge) are assigned to the shared adapter, while the residual "nuance" components initialize the expert adapters. This "bootstraps" the model using knowledge already present in the pretrained base.
4. Experimental Setup
We evaluated MOLE using DeepSeek Coder 1.3B as the base model.
- Training Data: We utilized the Glaive-code-assistant-v3 dataset, curated for eight primary languages: C, C++, C#, Go, Java, JavaScript, Python, and Rust, totaling approximately 192,000 samples.
- Benchmarks: Performance was assessed via HumanEvalPack, focusing on three core tasks: code summarization (explanation), synthesis (generation), and translation (cross-language conversion).
5. Results and Analysis
5.1 Performance vs. Baselines
MOLE consistently outperformed standard LoRA configurations, including AllLang-FT (a single adapter for all data) and PerLang-FT (individual adapters for each language). Notably, MOLE achieved results competitive with Full Fine-Tuning (Full-FT). In code summarization tasks, MOLE reached a Pass@1 score of 23.75, slightly exceeding the 23.71 achieved by Full-FT, despite updating significantly fewer parameters.
5.2 The Importance of Natural Language Specialization
A key finding was the necessity of the dedicated NL Adapter. Ablation studies showed that treating natural language as just another "programming language" (the NLExpert ablation) resulted in a marked decrease in performance. This suggests that the cognitive patterns required for human language instructions are distinct from those required for formal code syntax.
5.3 Rank Distribution and Knowledge Sharing
Empirical testing revealed that a 48/16 rank split (rank 48 for the shared adapter and rank 16 for experts) was optimal. This indicates that the "common logic" of programming constitutes a larger portion of the required parameter space than the "syntactic sugar" of individual languages. This architecture particularly benefited low-resource languages like Go and Rust, which were able to "borrow" reasoning capabilities from the shared adapter, leading to superior translation performance (e.g., an average of 37.76% Pass@1 for Rust, beating the baseline's 36.87%).
6. Conclusion and Future Work
MOLE provides a scalable and efficient solution for multilingual code intelligence. By decoupling logic from syntax, it enables high-performance adaptation without the overhead of full parameter updates. Future research will focus on scaling MOLE to larger models (7B+ parameters), addressing data imbalances between languages, and extending the architecture to handle more complex tasks such as repository-level reasoning and multi-modal inputs.
Summary updated