Prompt Engineering Strategies for LLM-based Qualitative Coding of Psychological Safety in Software Engineering Communities: A Controlled Empirical Study

📄 arXiv: 2605.07422v1 📥 PDF

作者: Moaath Alshaikh, Tasneem Alshaher, Ricardo Vieira, Beatriz Santana, Clelio Xavier, Jose Amancio, Glauco Carneiro, Julio Leite, Savio Freire, Manoel Mendonca

分类: cs.SE, cs.AI

发布日期: 2026-05-08

备注: 9 pages, 5 figures. Accepted at the 1st International Workshop on Prompt Engineering for Software Engineering (PROMPT-SE 2026), co-located with the 30th International Conference on Evaluation and Assessment in Software Engineering (EASE 2026), Glasgow, Scotland, United Kingdom, June 9--12, 2026


💡 一句话要点

评估LLM在软件工程心理安全定性编码中的提示工程策略,揭示模型稳定性与偏差规律

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 大语言模型 定性分析 提示工程 软件工程 心理安全 实证研究 模型一致性

📋 核心要点

  1. 定性分析依赖研究者主观判断,且LLM在处理此类任务时的可靠性与提示词敏感度缺乏系统性实证研究。
  2. 通过受控实验对比零样本与多样本闭合编码策略,评估不同LLM在软件工程心理安全编码任务中的表现。
  3. 实验发现多样本提示对特定模型有效,但模型普遍存在显著的类别预测偏差,且稳定性表现各异。

📝 摘要(中文)

定性分析在理解软件工程中的人文与社会因素方面至关重要,但该过程高度依赖研究者的主观解释,且对提示词设计等方法论选择极为敏感。大语言模型(LLM)为辅助此类分析提供了新机遇,但其在不同提示条件下复现人类定性推理的可靠性尚待验证。本研究对Claude Haiku、DeepSeek-Chat和Gemini 2.5 Flash三个模型进行了受控实证评估,对比了零样本(zero-shot)与多样本(multi-shot)闭合编码策略。通过十次独立运行并以Cohen's kappa作为一致性指标,结果显示多样本提示显著提升了Claude Haiku的一致性(Delta kappa = +0.034, p=0.004),但对其他模型影响有限。模型内部稳定性差异显著,DeepSeek-Chat与Claude Haiku表现出最低方差,而Gemini 2.5 Flash最不稳定。此外,所有模型均表现出对“分享负面反馈”的系统性过预测(偏差比高达5.25倍)及对“表达担忧”的持续低预测。这些发现为LLM辅助软件工程定性编码提供了实证指导。

🔬 方法详解

问题定义:论文旨在解决软件工程定性分析中,研究者主观性强且LLM辅助编码缺乏标准化提示工程指南的问题。核心痛点在于LLM在处理复杂社会心理指标(如心理安全)时,其输出的一致性、稳定性和偏差程度尚不明确。

核心思路:通过受控实证研究,对比不同提示策略(零样本 vs 多样本)对LLM编码性能的影响。研究假设通过提供示例(多样本)可以引导模型更好地对齐人类编码逻辑,并利用Cohen's kappa量化模型的一致性。

技术框架:实验选取Claude Haiku、DeepSeek-Chat和Gemini 2.5 Flash三个模型,针对软件工程社区的心理安全文本进行闭合编码。每种配置下进行十次独立运行,以评估模型在相同输入下的输出波动性。

关键创新:首次针对软件工程特定领域(心理安全)的定性编码任务,系统性地量化了LLM的提示策略敏感度、模型内稳定性以及类别预测偏差,为LLM在社会科学研究中的应用提供了实证基准。

关键设计:采用Cohen's kappa作为一致性度量指标,通过对比不同提示策略下的Delta kappa值评估改进效果;同时引入偏差比(Bias Ratio)分析模型在特定类别(如“分享负面反馈”)上的系统性过拟合或欠拟合倾向。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验发现多样本提示仅对Claude Haiku有显著一致性提升(Delta kappa=+0.034)。模型稳定性方面,DeepSeek-Chat与Claude Haiku表现最优(SD≈0.017),Gemini 2.5 Flash最不稳定(SD=0.038)。此外,所有模型均存在严重的类别偏差,对“分享负面反馈”的过预测比率高达5.25倍,显示出LLM在处理敏感社会心理标签时的局限性。

🎯 应用场景

本研究成果可直接应用于软件工程领域的人文社会研究,帮助研究者构建更可靠的LLM辅助定性分析工作流。此外,该研究揭示的偏差模式为开发针对特定领域(如心理安全、团队协作)的提示工程规范提供了参考,有助于提升AI在社会科学定性研究中的辅助决策质量。

📄 摘要(原文)

Qualitative analysis plays a pivotal role in understanding the human and social aspects of software engineering. However, it remains a demanding process shaped by the subjective interpretation of individual researchers and sensitive to methodological choices such as prompt design. Recent advancements in Large Language Models (LLMs) offer promising opportunities to support this type of analysis, although their reliability in reproducing human qualitative reasoning under varying prompting conditions remains largely untested. This study presents a controlled empirical evaluation of three LLMs -- Claude Haiku, DeepSeek-Chat, and Gemini 2.5 Flash -- across two prompt engineering strategies (zero-shot and multi-shot closed coding), using Cohen's kappa as the primary agreement metric over ten independent runs per configuration. Results suggest that multi-shot prompting significantly improves agreement for Claude Haiku (Delta kappa = +0.034, Wilcoxon p = 0.004) but not for DeepSeek-Chat or Gemini 2.5 Flash. Intra-model stability varies substantially -- DeepSeek-Chat and Claude Haiku exhibit the lowest variance (SD approx. 0.017), while Gemini 2.5 Flash is the least stable (SD = 0.038). A systematic over-prediction of "Sharing Negative Feedback" is identified across all models (bias ratios up to 5.25x), alongside consistent under-prediction of "Expressing Concerns." Collectively, these findings provide empirical evidence for prompt engineering guidelines in LLM-assisted qualitative coding for software engineering research.