LangSelect: Cost-Aware Target-Language Routing for LLM Code Generation
Son Ha Xuan, Phat T. Tran-Truong, Xuan-Bach Le, Nghia Duong-Trung
Abstract
LLM code-generation systems usually choose a target programming language before decoding and treat that choice as fixed. We show that, for language-flexible programming tasks -- tasks where several target languages are acceptable and checkable by the same tests -- this choice is a measurable cost lever: verified implementations of the same task can differ substantially in generated-token length. We introduce LangSelect, a verification-aware router that selects the target language before generation and falls back when the first attempt fails. To separate offline routing opportunity from end-to-end behavior, we evaluate verified-solution replay, which chooses among already accepted corpus solutions, and live GPT-5 generation, which charges every generation attempt, including failures and fallbacks. On MultiLang-Bench, a 3,000-task, 8-language verified corpus, replay shows substantial language-routing headroom. In live evaluation on 450 held-out tasks, a train-split Domain heuristic baseline reduces harness-proxy tokens, which include wrapper and entrypoint overhead, by 50.3\% at 92.9\% pass after fallback, while a learned CodeBERT+metadata selector reaches the highest pass after fallback, 93.8\%, with a 3.7\% token increase. These results show that output-language routing can define a practical cost-correctness frontier for unit-test-verifiable code generation.
Create a lesson
Related papers
What Should a Skill Remember? Quality--Cost Trade-offs in Cost-Aware Skill Rewriting for Language Model Agents
Shared title terminologycs.CLQinghua Xing, Yinda Chen, Yaping Jin et al.
NORMCRAFT: Cultural Norm Generation for Context-Aware Language Model Alignment
Shared title terminologycs.CLTangyuan Zhang, Zhuang Li, Fatemeh Shiri et al.
Less Experts, Faster Decoding: Cost-Aware Speculative Decoding for Mixture-of-Experts
Shared title terminologycs.CLJincheng Xie, Runheng Liu, Heyan Huang et al.
VulnSafe: Measuring Vulnerability-Aware Relational Safety in Large Language Models
Shared title terminologycs.CLJiaming Luo, Jiacheng Ji, Haoan Jin et al.
Evaluating Large Language Models on conversational African American English: Feature classification and next-turn generation
Shared title terminologycs.CLRomeo De Timmerman, Thomas Demeester, Els Lefever
Though Language Models Err While They Strive: Conformal Prediction for Self-Correcting Scientific Generation
Shared title terminologycs.CLMingqiao Mo, Yunlong Tan, Hao Zhang