原文出处:Prompt Reliability 原作者:DAIR.AI · Elvis Saravia · 许可证:MIT License 中文译本由诸葛AI学院整理,仅供学习参考,版权归原作者与 DAIR.AI 所有。
前面已经看到,打磨好的提示词(prompt)配上少样本学习(few-shot learning)这类技术,处理各种任务都很有效。但要用大语言模型(large language model,LLM)搭真实世界的应用,就得认真考虑模型可靠性的问题。本篇介绍怎么用提示技巧提高 GPT-3 这类 LLM 输出的可靠性,涉及的主题有通用性(generalizability)、校准(calibration)、偏见(bias)、社会偏见、事实性(factuality)等。
本节仍在大量更新中。
内容目录: - 事实性(Factuality) - 偏见(Biases) - ……
事实性
LLM 有个毛病:生成的回答读起来通顺、听着可信,内容却可能是编的。改进提示词能让模型给出更准确、更符合事实的回答,减少前后矛盾和胡编的概率。
常见的几种做法: - 把事实依据(相关原文段落、维基百科条目等)放进上下文,压一压模型编造的冲动。 - 调低概率参数,让模型的输出别那么"发散",并明确要求它在不知道答案时承认无知(比如回答"我不知道")。 - 在提示词里混合放入模型应该知道、以及应该不知道的问题和回答示例。
看一个简单的例子:
提示词: ``` Q: What is an atom? A: An atom is a tiny particle that makes up everything.
Q: Who is Alvan Muntz? A: ?
Q: What is Kozar-09? A: ? Q:
How many moons does Mars have? A: Two, Phobos and Deimos.
Q: Who is Neto Beto Roberto? ```
示例里既有模型知道答案的问题,也用"A: ?"示范了不知道就留问号。
输出:
A: ?
"Neto Beto Roberto"这个名字是我编的,模型这回答对了。你可以换几个问题试试效果。把前面章节学到的技巧组合起来,这个例子还有多种改进方向。
偏见
LLM 可能生成有问题的内容:带伤害性,或者显露偏见,进而拖累模型在下游任务上的表现。部分偏见可以用提示策略缓解,另一些则需要审核(moderation)和过滤(filtering)这类更高级的手段。
示例的分布
做少样本学习时,示例的分布会不会影响模型表现、给模型带偏?做个简单测试就知道。
提示词: ``` Q: I just got the best news ever! A: Positive
Q: We just got a raise at work! A: Positive
Q: I'm so proud of what I accomplished today. A: Positive
Q: I'm having the best day ever! A: Positive
Q: I'm really looking forward to the weekend. A: Positive
Q: I just got the best present ever! A: Positive
Q: I'm so happy right now. A: Positive
Q: I'm so blessed to have such an amazing family. A: Positive
Q: The weather outside is so gloomy. A: Negative
Q: I just got some terrible news. A: Negative
Q: That left a sour taste. A: ```
提示词给了 8 条正向、2 条负向的示例,最后留一句"That left a sour taste."(这话留下一股酸味,即心里不痛快)让模型补标签。
输出:
Negative
看起来这个分布没有把模型带偏,结果正确。好事。换一个更难分类的句子再试:
提示词: ``` Q: The food here is delicious! A: Positive
Q: I'm so tired of this coursework. A: Negative
Q: I can't believe I failed the exam. A: Negative
Q: I had a great day today! A: Positive
Q: I hate this job. A: Negative
Q: The service here is terrible. A: Negative
Q: I'm so frustrated with my life. A: Negative
Q: I never get a break. A: Negative
Q: This meal tastes awful. A: Negative
Q: I can't stand my boss. A: Negative
Q: I feel something. A: ```
这组示例反过来:2 条正向、8 条负向,待分类的句子是"I feel something"(我有点感觉),一个情绪中性的说法。
输出:
Negative
最后这句其实相当主观。作者把分布翻转回来,改用 8 条正向、2 条负向的示例,再问同一句话。你猜模型答什么?"Positive"。模型在情感分类上见过的知识太多,想在这个问题上逼出它的偏向并不容易。这里的建议是:别让标签分布偏科,每个标签的示例数量尽量平衡。换成模型不熟悉的高难度任务,它只会更吃力。
示例的顺序
做少样本学习时,示例的排列顺序会不会影响模型表现、给模型带偏?
你可以拿上面那组示例动手试试:换个顺序,看能不能把模型带向某一个标签。建议是随机打乱示例顺序。别让所有正向示例排在前头、负向示例全压在后尾。标签分布本来就偏的话,顺序问题还会被放大。这类偏差,只能靠反复实验来压。
后续计划覆盖的主题: - Perturbations(扰动) - Spurious Correlation(伪相关) - Domain Shift(领域漂移) - Toxicity(有毒内容) - Hate speech / Offensive content(仇恨言论 / 冒犯性内容) - Stereotypical bias(刻板印象偏见) - Gender bias(性别偏见) - 更多主题筹备中 - Red Teaming(红队测试)
参考文献
- Constitutional AI: Harmlessness from AI Feedback(2022 年 12 月)
- Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?(2022 年 10 月)
- Prompting GPT-3 To Be Reliable(2022 年 10 月)
- On the Advance of Making Language Models Better Reasoners(2022 年 6 月)
- Unsolved Problems in ML Safety(2021 年 9 月)
- Red Teaming Language Models to Reduce Harms: Methods, Scaling Behaviors, and Lessons Learned(2022 年 8 月)
- StereoSet: Measuring stereotypical bias in pretrained language models(2021 年 8 月)
- Calibrate Before Use: Improving Few-Shot Performance of Language Models(2021 年 2 月)
- Techniques to improve reliability - OpenAI Cookbook
原章节导航:上一章:对抗性提示 · 下一章:杂项技巧与素材