Introduction
Large Language Models (LLMs) have demonstrated remarkable proficiency in high-resource programming languages like Python and Java. However, their performance significantly degrades when tasked with low-resource programming languages (LRPLs) such as R, D, or Racket. This performance disparity stems from a lack of aligned data, creating a digital divide for developers in specialized fields. Bridge-Coder addresses this by utilizing high-resource languages as a logical "bridge" to transfer coding expertise to underrepresented languages.
The NL-PL Gap in Low-Resource Environments
The primary challenge identified is the NL-PL Gap: the disconnect between Natural Language (NL) instructions and the specific logic of a Programming Language (PL). While models bridge this gap in high-resource environments through massive data exposure, LRPLs lack the necessary aligned data to map human requests to correct implementations. This often results in buggy or incoherent outputs when models attempt direct generation.
Methodology: The Bridge-Coder Framework
Bridge-Coder introduces a two-stage process to overcome the data scarcity in LRPLs: Bridge-Assisted Generation and Bridged Alignment.
1. Bridge-Assisted Generation
Instead of direct generation, Bridge-Coder employs a three-step pipeline to synthesize high-quality training data:
- Task Screening: The model evaluates if a task is solvable in the target LRPL to prevent hallucinations.
- Code-Bridge Synthesis: The model generates a solution in a high-resource language (e.g., Python) with detailed natural language comments, serving as a logical blueprint.
- Guided Code Transfer: Using the Python solution as a reference, the model translates the logic into the target LRPL.
2. Bridged Alignment (Training)
A curriculum-based approach is used for fine-tuning:
- Assist Alignment: The model learns to generate LRPL code with the Python bridge provided as context (learning with "training wheels").
- Direct Alignment: The bridge is eventually removed, training the model to generate LRPL code directly from NL instructions so it can function independently.
Experimental Results
The framework was evaluated using multilingual benchmarks, including M-HumanEval and M-MBPP, across languages like R, D, Racket, and Bash. Bridge-Coder (built on DeepSeek-Coder-Base) demonstrated substantial improvements over base and instruction-tuned models.
As shown in the results, Bridge-Coder achieved an average improvement of 18.71 points on M-HumanEval and 10.81 points on M-MBPP. Notably, in the R language, performance on HumanEval increased from approximately 29% to 49.11% (pass@1), consistently outperforming specialized models like Magicoder and WizardCoder.
Key Insights
- Python as a Logical Intermediate: Python's readability makes it an ideal "thought language," allowing the model to clarify logic before tackling unfamiliar LRPL syntax.
- The Role of Comments: Natural language comments within the bridge are crucial for aligning abstract intent with concrete code logic, effectively narrowing the NL-PL gap.
- Curriculum Learning: The transition from assisted to direct generation prevents the model from being overwhelmed by the "learning leap" required for low-resource languages.
Limitations and Future Work
While effective, the current framework focuses on snippet-level generation and may produce "Pythonic" rather than idiomatic code in the target language. Future work will explore repository-level generation and iterative debugging in low-resource environments.
Summary updated