arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.15607cs.CLcs.LG
收藏

无语义的语法:教大语言模型在未见过的语言中编程

Syntax Without Semantics: Teaching Large Language Models to Code in an Unseen Language

AWS AI Labs(AWS人工智能实验室)

Vinayshekhar Bannihatti Kumar, Disha Makhija, Manoj Ghuhan Arivazhagan, Rashmi Gangadharaiah

AI总结:

研究探讨大语言模型在未见过的语言中生成代码的能力,发现微调仅能教授语法而无法转移语义能力,揭示了推理与语言实现之间的鸿沟。

摘要:

大型语言模型(LLMs)在代码生成基准测试中表现出高通过率,但它们能否将这种能力转移到训练时未见过的语言仍不清楚。我们介绍了PyLang,一种最小的命令式语言,未出现在所有预训练语料库中,并评估了前沿模型在352个问题上的零样本和微调Qwen3(4B、8B、32B)的表现。我们发现微调快速教授了语法,但无法转移语义能力:Python在所有配置中比PyLang高出高达19%,且没有干预(多任务学习、偏好微调、代码填充或潜在空间目标)无法缩小差距。一个LLM法官发现,前沿模型有80%的时间选择与Python相同的算法,但无法将其翻译成有效的PyLang实现。CKA分析确认,微调模型在不同语言中收敛到几乎相同的内部表示(CKA > 0.97),但在输出阶段却不同。我们称这种现象为实现忠实度鸿沟:模型具有语言无关的算法理解,但无法用不熟悉的语言表达它。我们的发现强调了需要训练方法将推理与语言特定的实现解耦。

英文摘要:

Large language models (LLMs) achieve high pass rates on code generation benchmarks, yet whether they can transfer this ability to languages absent from pretraining remains poorly understood. We introduce PyLang, a minimal imperative language absent from all pretraining corpora, and evaluate frontier models zero-shot and fine-tuned Qwen3 (4B, 8B, 32B) on 352 problems. We find that fine-tuning quickly teaches syntax but fails to transfer semantic competence: Python outperforms PyLang by up to 19% across all configurations, and no intervention (multi-task learning, preference tuning, code infilling, or latent-space objectives) closes the gap. An LLM judge reveals that frontier models select an identical algorithm to Python 80% of the time, yet cannot translate it into a working PyLang implementation., and CKA analysis confirms that fine-tuned models converge to nearly identical internal representations across languages (CKA > 0.97) while diverging at the output stage. We term this the implementation fidelity gap: models possess language-agnostic algorithmic understanding but cannot express it in an unfamiliar language. Our findings highlight the need for training methods that decouple reasoning from language-specific realization.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑