Background
LLMs in Social Computing:社会计算研究依赖人工标注数据集,耗时且成本高。ChatGPT 等 LLM 工具的发布为自动化文本数据标注任务提供了可能,但 LLMs 的标注性能在不同模型、领域和数据集上存在差异,其通用性和可靠性有待提高。
Prompt-Tuning for Text Annotation:现有的基于 LLM 的文本标注方法中,提示调优技术多依赖领域专业知识和人工判断,阻碍了 LLMs 在自动化标注任务中的应用。因此,需要一种能够自动进行提示调优的工具
Contributions
• We propose APT-Pipe, an automatic and extensible prompt-tuning pipeline to improve ChatGPT’s performance for social computing data annotation. 【提出一个基于LLM的自动标注流水线】
• We implement and validate APT-Pipe’s effectiveness. We show that APT-Pipe can improve ChatGPT’s classification performance on nine out of twelve different datasets, with improvement on ChatGPT’s F1-score by 7.01% on average. 【整体性能】
• We show that APT-Pipe prompts generate annotations in a consistent format and take less time compared to existing prompt
designs. On average, 97.08% responses generated by APT-Pipe are parsable and it decreases the time cost by over 25%. 【计算效率】
• We highlight APT-Pipe’s extensibility by introducing two additional prompt-tuning techniques: Chain of Thought (CoT) and
Tree of Thought (ToT). CoT improves APT-Pipe’s F1-scores on five datasets by 4.01%, and ToT improves APT-Pipe’s F1-scores on six datasets by 3.49%. Importantly, we show that APT-Pipe can learn these improvements on a per-dataset basis, automatically tuning the prompts without human intervention. 【可拓展性】
Method
Step 1: Preparing Initial Prompt
提示工程师使用 JSON 模板输入初始提示,明确文本分类任务、输入文本、分类领域和标签等信息
template:
将待分类数据集全部转为目标格式,作为step2的输入
Step2 Prompt-tuning with Few-shot
使用少样本进行提示调优:
-
从数据集中选择与待分类文本相似度最高的样本作为候选样本;
OpenAI的text-embedding-ada-002模型生成数据集中每个数据样本的嵌入,然后计算每个样本的嵌入与文本的嵌入之间的成对余弦相似度,取top-n个样本。
-
选择能提高性能的提示样本;
- 人工手动标注的小数据子集;
- 设置两个实验组,第一组让 ChatGPT 在不包含少量样本的情况下标注该子集作为基线;第二组令提示词中包含个少量样本来标注数据;
- 通过对比 ChatGPT 的输出与人类真实标签来计算分类的加权 F1 分数。若 F1 分数未下降,APT-Pipe 输出获得最高 F1 分数提升的提示词并输入下一步;若 F1 分数下降,则移除样本的键值对并将原始提示传递到下一步骤。
Step 3: Prompt-tuning with NLP Metrics
首先将人工标注的数据分成两个部分:一个包含75%数据的训练集,和一个包含剩余25%数据的验证集;
- 获取基线:以 ChatGPT 使用Step2中提示词(不包含任何额外指标)标注的数据集作为基线数据集;
- 选择能够提升提示词标注性能的NLP指标:训练一个 XGBoost 分类器来估计每个指标的预测能力并排名,以减少搜索空间;
- 构建了一个新的数据集,其中包含每个数据样本、人类标签、ChatGPT标签(步骤3.1)和每个NLP指标向量;
- 利用ChatGPT的标签、原始文本及其附加的指标,为每个NLP指标训练一个单独训练的分类器来预测ChatGPT生成的标签是否与原始的人工标签相同;
- 文章认为能够更好地预测ChatGPT生成正确标签的能力的指标将更适合于包含在提示符中;
- 添加指标并测试:选择排名最高的指标添加到现有提示词中,让 ChatGPT 标注验证集并记录其给出标签,若加权 F1 分数比基线有所提高,则标记该NLP指标用于最终提示词中;
- 迭代:重复上述过程,直到所有指标都被测试。每次迭代时,使用包含已选指标的新提示重新标注训练数据,重新训练 XGBoost 指标分类器并选择下一个指标添加到新提示中;
- 最终,APT-Pipe 会返回一个包含所有选定指标作为 JSON 属性的最终提示。
EXPERIMENTAL SETTINGS
Datasets:
Metrics:
- 分类器性能:将 ChatGPT 视为文本分类引擎,使用加权 F1 分数、准确率和召回率作为评估指标。
- 响应的可解析性:基于期望格式计算可解析响应的百分比,通过正则表达式匹配和解析 ChatGPT 响应中的标签。
- 时间成本:计算 ChatGPT 返回注释响应的时间。
NLP Metrics
实验中使用了情感、情绪、毒性和主题四个 NLP 指标,并将其以特定的键值对形式添加到提示中
Baselines
选择了 Cloze 提示、字典提示和 JSON 提示作为基线
Cloze 提示
字典提示
Overall performance
few shot:在模型训练过程中,如果每个类别只有少量样本(一个或几个),研究人员希望机器学习模型在学习了一定类别的大量数据后,对于新的类别,只需要少量的样本就能快速学习。
zero shot:在训练集中没有某个类别的样本,但在测试集中出现了这个类别。我们需要模型在训练过程中,即使没有接触过这个类别的样本,但仍然可以通过对这个类别的描述,对没见过的类别进行分类。
Effectiveness of ChatGPT’s Responses
Ablation Study
EXTENDING APT-PIPE PROMPTS
Example
Implement details:
Conclusion
This paper proposes APT-Pipe, an automatic prompttuning tool. Given a text classification dataset, APT-Pipe aims to
automatically tune a prompt for ChatGPT to reproduce identical annotations to a small set of ground-truth labels.Our results show that APT-Pipe improves ChatGPT’s overall performance on nine datsets, improving their F1-score by 7.01% on average
Limitations
- First, we only test APT-Pipe across three task domains
- Second, in our evaluation, we assume that the prompt engineer can annotate small parts of their datasets.
- . Third, as an extensible framework, APT-Pipe has only been evaluated with two modules — few-shot learning and NLP metrics selection — alongside the CoT and ToT extensions.