arXiv:2504.01850cs.SEcs.AI2025-04被引 8

测试主流大模型编程时的有害输出,发现代码专用模型未必更安全

Code Red! On the Harmfulness of Applying Off-the-shelf Large Language Models to Programming Tasks

  • 构建软件工程有害场景分类与提示数据集
  • 发现部分模型(如Openhermes)比基础模型更易生成有害内容
  • 模型越大越安全,微调不当反而会降低安全性

当前开发者越来越多地依赖大语言模型(LLM)完成编码任务,因此确保这些工具符合人类价值观、防止恶意滥用至关重要。本文提出一个全面框架,评估LLM在软件工程领域潜在的有害性。首先构建了潜在有害软件工程场景的分类体系,并基于此创建提示数据集。设计并验证了一种自动评估器,可对多种开源与闭源模型、通用型与代码专用型模型的输出进行分类评估。研究发现不同模型在无害性对齐上存在显著差异:部分模型(如Openhermes)比其他模型更具危害性,且代码专用模型并未优于通用模型。值得注意的是,某些微调模型因设计缺陷表现远差于基线模型。另一方面,更大的模型更倾向于提供帮助,产生有害内容的可能性更低。结果凸显了针对软件工程任务定制对齐策略的重要性,为该关键领域的后续研究奠定基础。

原文摘要 · Abstract (English)

Nowadays, developers increasingly rely on solutions powered by Large Language Models (LLM) to assist them with their coding tasks. This makes it crucial to align these tools with human values to prevent malicious misuse. In this paper, we propose a comprehensive framework for assessing the potential harmfulness of LLMs within the software engineering domain. We begin by developing a taxonomy of potentially harmful software engineering scenarios and subsequently, create a dataset of prompts based on this taxonomy. To systematically assess the responses, we design and validate an automatic evaluator that classifies the outputs of a variety of LLMs both open-source and closed-source models, as well as general-purpose and code-specific LLMs. Furthermore, we investigate the impact of models size, architecture family, and alignment strategies on their tendency to generate harmful content. The results show significant disparities in the alignment of various LLMs for harmlessness. We find that some models and model families, such as Openhermes, are more harmful than others and that code-specific models do not perform better than their general-purpose counterparts. Notably, some fine-tuned models perform significantly worse than their base-models due to their design choices. On the other side, we find that larger models tend to be more helpful and are less likely to respond with harmful information. These results highlight the importance of targeted alignment strategies tailored to the unique challenges of software engineering tasks and provide a foundation for future work in this critical area.

大模型安全代码生成有害内容模型评估

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。