LangChoiceBench: Measuring and Explaining Programming-Language Choice in LLMs
作者: Lukas Twist, Twm Stone, Helen Yannakoudakis, Jie M. Zhang
分类: cs.SE, cs.CL
发布日期: 2026-08-06
备注: 19 pages, 9 tables, 2 figures
💡 一句话要点
提出LangChoiceBench以系统性测量LLMs的编程语言选择
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 编程语言选择 大型语言模型 代码生成 Python偏好 推荐一致性 语言多样性 幻影证据
📋 核心要点
- 现有方法缺乏系统性测量LLMs在编程语言选择上的行为,尤其是Python的偏好。
- 论文提出LangChoiceBench基准,通过项目级代码生成来测量Python偏好及其一致性。
- 实验结果显示Python选择过于频繁,且较小模型表现出更强的Python偏好和较低的语言多样性。
📝 摘要(中文)
大型语言模型(LLMs)在生成项目级代码时表现出强烈的Python偏好,但目前缺乏系统性的方法来测量这种行为。为此,本文提出了LangChoiceBench,这是一个用于测量Python偏好、推荐-实现一致性和语言多样性的项目级代码生成基准。LangChoiceBench涵盖了28个项目,涉及七个软件领域,其中Python通常并非最佳选择。对25个不同的LLMs进行评估后发现,Python的选择仍然过于频繁,推荐-实现一致性较低,而较小的开放权重模型通常表现出更强的Python偏好和较低的语言多样性。此外,分析了9,826个推理轨迹,发现大多数Python选择是自动化的,主要由易用性驱动,而非对项目需求的明确考虑。少数情况下,模型会虚构选择Python的上下文支持,这种失败模式称为“幻影证据”,或者生成与自身推理中选择的语言相矛盾的代码。
🔬 方法详解
问题定义:本文旨在解决当前缺乏系统性测量LLMs在编程语言选择上的行为的问题,尤其是Python的偏好及其一致性。现有方法未能全面评估不同模型在项目级代码生成中的表现,导致对模型选择行为的理解不足。
核心思路:论文的核心思路是通过构建LangChoiceBench基准,系统性地评估和分析LLMs在不同项目中的编程语言选择,特别是Python的偏好。通过对多种模型的比较,揭示其在推荐和实现上的一致性问题。
技术框架:LangChoiceBench的整体架构包括多个模块:项目选择、代码生成、语言选择评估和结果分析。涵盖28个项目,涉及七个软件领域,确保评估的全面性和多样性。
关键创新:最重要的技术创新在于引入了“幻影证据”这一概念,指出模型在选择Python时可能会虚构上下文支持。此外,系统性地评估了25个不同的LLMs,揭示了它们在语言选择上的一致性问题。
关键设计:在实验中,采用了多种模型和项目组合,设置了不同的评估指标,如推荐-实现一致性和语言多样性,确保了实验结果的可靠性和可比性。
🖼️ 关键图片
📊 实验亮点
实验结果显示,Python在代码生成中的选择频率过高,且推荐与实现的一致性较低。较小的开放权重模型表现出更强的Python偏好,语言多样性较低。通过分析9,826个推理轨迹,发现大多数Python选择是基于易用性,而非项目需求的明确考虑。
🎯 应用场景
该研究的潜在应用领域包括软件开发工具、代码生成系统和教育领域。通过更好地理解LLMs的编程语言选择行为,可以优化代码生成过程,提高开发效率,并为教育者提供更有效的教学工具。未来,LangChoiceBench可能成为评估和改进LLMs的重要基准。
📄 摘要(原文)
Large language models (LLMs) have been shown to exhibit strong Python preferences when generating project-level code, but there is currently no systematic way to measure this behaviour across new models. To bridge this gap, we introduce LangChoiceBench, a project-level code-generation benchmark for measuring Python preference, recommendation-implementation consistency, and language diversity. LangChoiceBench covers 28 projects across seven software areas where Python is often a poor default. We evaluate 25 diverse LLMs and find that Python remains heavily over-selected, recommendation-implementation consistency is low, and smaller open-weight models generally show stronger Python preference and lower language diversity. We further analyse 9,826 reasoning traces and find that most Python choices are automatic or driven primarily by ease, rather than explicit consideration of project requirements. In a smaller but important set of cases, models fabricate contextual support for choosing Python - a failure mode we call phantom evidence - or produce code that contradicts the language selected in their own reasoning.