CodeChemist: Test-Time Scaling for Low-Resource Code Generation via Functional Knowledge Transfer

Kaixin Wang, Tianlin Li, Xiaoyu Zhang, Aishan Liu, Xianglong Liu, Ziqi Liu, Zhiqiang Zhang, Jun Zhou, and Bin Shi

TL;DR

CodeChemist is a training-free, test-time scaling framework that significantly boosts CodeLLM performance in low-resource programming languages (like Lua) by transferring functional knowledge from high-resource languages (like Python). By introducing an uncertainty-aware adaptive selection mechanism, it intelligently balances accuracy and computational cost, outperforming existing inference-time methods while running up to 4x faster.

What Problem Does This Paper Address?

Code Large Language Models (CodeLLMs) have become indispensable tools for developers, but their proficiency is highly unequal. While they excel in high-resource languages like Python due to the abundance of training data, their performance plummets when handling low-resource languages (e.g., Lua) or those with highly complex syntax (e.g., C++, Java).

Traditional approaches to bridge this gap rely on fine-tuning models with cross-lingual datasets or translated code snippets. However, fine-tuning is computationally expensive, often requires language-specific toolchains that low-resource languages lack, and can inadvertently degrade the model's performance on high-resource languages. CodeChemist tackles this by shifting the solution entirely to inference time (test-time scaling), allowing models to self-correct and improve without any additional training.

Methods

CodeChemist operates via a three-stage, training-free pipeline designed to optimize both code diversity and selection accuracy:

  1. Hedged Sampling: Instead of sampling candidates at a single temperature, CodeChemist uses multi-temperature hedged sampling (combining greedy decoding $\tau=0$ with higher temperatures like $\tau \in \{0.7, 0.9, 1.1\}$). This ensures a candidate pool that balances high-quality, stable solutions with diverse alternatives.
  2. Uncertainty-Aware Adaptive Selection: To save compute, CodeChemist evaluates the target language candidate pool using both execution-based clustering and Abstract Syntax Tree (AST) similarity. If the model exhibits high internal consistency (low uncertainty), it bypasses expensive validation and directly selects an answer via a cheap in-language majority vote.
  3. Cross-Lingual Knowledge Transfer: If uncertainty is high, CodeChemist triggers a knowledge transfer. It generates test inputs and multiple reference solutions in a high-resource "teacher" language (usually Python). By executing these reference solutions, it establishes a reliable Input/Output (I/O) test oracle via majority voting. The target language candidates are then executed against this oracle, and the candidate with the highest pass rate is selected.
Figure 2. The overview of CodeChemist. k represents the uncertainty of the target PL candidate pool.

Datasets

The authors evaluated CodeChemist across several model families (Qwen2.5-Coder, Llama 3.2, GPT-4o-mini, and DeepSeek-V3) using two prominent multilingual benchmarks:

  • MultiPL-E: Comprising MultiPL-HumanEval (161 problems) and MultiPL-MBPP (396 problems), which translate standard Python benchmarks into multiple target languages.
  • Ag-LiveCodeBench-X: A more rigorous, contamination-free benchmark containing 499 problems featuring higher algorithmic complexity.

Evaluations were primarily conducted on Lua, C++, and Java, with extensions to Julia, R, and Rust.

Key Insights and Ideas

  • Test Cases as Universal Translators: The core "aha" moment is that test cases (I/O pairs) encapsulate functional knowledge—the pure, language-agnostic logic of a problem. This allows a model's strong Python capabilities to act as a judge for its weaker Lua or C++ generations.
  • Syntactic + Semantic Filtering: Relying solely on execution outputs can lead to "spurious consistency," where completely different, incorrect code snippets happen to produce the same output on a limited test set. Incorporating AST clustering ensures structural consensus, making uncertainty estimation far more robust.
  • Compute Allocation Efficiency: Rather than paying the heavy computational tax of cross-lingual execution for every single query, CodeChemist only invokes the high-resource teacher when the target language candidate pool is genuinely chaotic.

Key Results

  • State-of-the-Art Performance: CodeChemist consistently outperformed vanilla baselines and existing test-time scaling methods (like S and Self-Debugging). On Ag-LiveCodeBench-X, it delivered substantial relative improvements for Lua. Notably, DeepSeek-V3 enhanced by CodeChemist achieved 50.5% Pass@1* in Lua, beating the official leaderboard's top entry of 43.0% at the time of evaluation.
Figure 1. Performance improvement with CodeChemist on Ag-LiveCodeBench-X (Boruch-Gruszecki et al., 2025). Code- Chemist consistently enhances performance across a wide range of model sizes. The improvement is particularly pronounced for the low-resource language Lua. Notably, DeepSeek-V3 enhanced by CodeChemist achieves 50.5 in Lua, surpassing the official leaderboard’s top entry of 43.0 at the time of our evaluation1. “Qwen” denotes the “Qwen2.5-Coder-Instruct” series.
  • High Computational Efficiency: Thanks to its adaptive selection routing, CodeChemist consumed roughly 2x fewer tokens and ran 4x faster than the state-of-the-art S* method on Qwen-32B, making it a highly practical framework for real-world deployment.
Figure 3. Comparison of computational efficiency on the MultiPL- HumanEval benchmark using Qwen-32B. “w/o Adapt.” refers to the CodeChemist variant without the uncertainty-aware adaptive selection mechanism.

Limitations and Future Work

  • Functional Logic Bound: CodeChemist relies entirely on I/O behavior to characterize program correctness. It remains limited for tasks that depend heavily on language-specific non-functional properties, such as memory management, execution overhead, or parallel efficiency.
  • Teacher Model Bottleneck: The framework is fundamentally bounded by the model's underlying problem-solving capability in the high-resource language. If the model cannot solve the problem in Python, it cannot generate a valid oracle to fix the low-resource code.
  • Granularity: The current implementation focuses primarily on function-level code generation. While a case study on RepoClassBench showed promise for class-level generation, broader validation on repository-level codebases is left for future work.

Summary updated

BibTeX
@inproceedings{wang2026codechemist,
  author = {Kaixin Wang and Tianlin Li and Xiaoyu Zhang and Aishan Liu and Xianglong Liu and Ziqi Liu and Zhiqiang Zhang and Jun Zhou and and Bin Shi},
  title = {{CodeChemist: Test-Time Scaling for Low-Resource Code Generation via Functional Knowledge Transfer}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=WVm7jMnA9t},
}
Figure