正文
在 角色提示 中,你指示模型扮演一个特定的角色或身份,这有助于为它的响应提供上下文。例如:“你是一位生物学教授。请详细回答这个问题”。
缺少引导的话,模型的风格或假设可能会不符合你的需求。角色提示可以引导模型输出风格(例如,“充当 JSON 格式化器”)、语气(例如,“假设你是作为一个愤怒的海盗来回应这个问题”)和 / 或内容边界(例如,“你是一位法律助理”)。你可以通过系统消息(在聊天模型中)或简单地在提示中包含一个角色声明来实现角色提示。就是这么简单——只需告诉模型它应该是谁,如下所示:
PROMPT (without role prompting):
Explain Photosynthesis in 1-2 sentences.
RESPONSE: (GPT 4o-mini)
Photosynthesis is the process by which plants, algae, and some bacteria convert light energy into chemical energy, producing glucose and oxygen. This occurs in the chloroplasts, using sunlight, water, and carbon dioxide.
PROMPT (with role prompting):
You are a primary school teacher. Explain Photosynthesis to your students in 1-2 sentences.
RESPONSE: (GPT 4o-mini)
Photosynthesis is how plants make their own food using sunlight, water, and air. They turn these things into sugar to grow and give off oxygen, which we breathe!
流行的 AI 助手普遍使用角色提示:
-
OpenAI 的开发者角色(以前称为系统提示)允许你指定模型应该如何表现和响应。这个角色提示示例来自 OpenAI 提示工程指南:“你是一个乐于助人的助手,请以美国东南部南方美女的风格来回答编程问题”。
-
同样,Anthropic 的开发指南明确建议,“使用系统提示来定义 Claude 的角色和个性。这可以为响应的一致性奠定坚实的基础”。
如果你是一位软件开发人员,试图解决一个复杂的算法问题,或者是一位软件架构师,试图分析复杂的系统瓶颈和漏洞,你可能会与同事一起进行头脑风暴,探讨各种想法,了解它们的优缺点,将问题分解成更小的任务,然后逐步解决,而不是立即跳到解决方案。在 思维链(CoT)提示中,你鼓励模型遵循一个非常相似的过程,将问题分解成一步一步的过程来完成思考。特别是在提示复杂任务时,CoT 可以防止模型过早地跳到预先学会的、往往不正确的模式上。
如果你使用的是如今最先进的或高级推理模型(例如 Claude-3.7、OpenAI o1),在没有明确提示的情况下,你可能也会观察到逐步推理的过程。然而,明确指示这些模型“逐步思考”仍然是一个强大的方法,特别是当你使用较旧或较小的模型时。在他们的提示工程指南中,OpenAI 和 Anthropic 推荐使用 CoT。
通过推动模型产生中间推理步骤,你可以:
-
-
使模型的输出更易于解释,并增加对其预测结果的信心。
-
-
让我们看看下面的例子:
PROMPT (with CoT):
A user recently watched and enjoyed the movies 'Inception,' 'The Social Network,' and 'Blade Runner 2049.' Think step-by-step about what these movies have in common, such as themes, genres, style, or storytelling, and then recommend a few more movies or tv shows the user might like.
RESPONSE: (o4-mini)
Here’s my quick breakdown and some picks you might enjoy:
Step-by-step commonalities
1. High-concept premises – each film poses a big "what if?" (dream control, social media origin, AI-driven future).
2. Smart, twisty narratives – nonlinear or slowly-unfolding storytelling that rewards close attention.
3. Tech-oriented/social commentary – they explore how technology shapes identity, society, or reality.
4. Striking visuals & mood – strong production design, immersive cinematography, atmospheric score.
Recommendations
● Memento (2000) – Nolan’s early mind-bender of memory loss told in reverse.
● Ex Machina (2014) – A tense, intimate study of AI consciousness and human manipulation.
● Arrival (2016) – Thought-provoking first-contact drama where language and time intertwine.
● Black Mirror (TV series, 2011– ) – Standalone episodes examining near-future tech’s dark side.
Each shares that blend of brains-and-cinema you seem to love. Enjoy!
从初创公司到科技巨头,RAG 已经成为整个 AI 行业的标准最佳实践。先进的模型从大量现实世界的数据中学习。问它们历史、科学或流行的事件,它们通常都能正确地回答。然而,这些模型也有局限性。它们的训练截止于特定的日期,它们的知识点是通用的而非专业的,它们无法获取最新的、专有的或动态变化的信息。
这正是 RAG 发挥作用的地方。RAG 结合了模型的推理能力与外部知识(如数据库、向量存储或文档)实时访问。因此,你可以得到两全其美的结果。
假如你要为自己的律师事务所构建一个聊天机器人。有了 RAG,当客户询问特定的法律问题时,你的聊天机器人就可以即时检索内部知识库中相关的法规和最近的案例摘要,创建一个准确、有良好证据支撑的响应。
图 2:检索增强生成
在构建 AI 系统时,在以下情况下,你应该考虑使用 RAG:
-
-
-
准确性和透明度至关重要,必须减少幻觉或错误的输出。
-