提示工程 - 系统提示(System Prompts)
提示工程 - 系统提示(System Prompts)
flyfish
什么是系统提示?
系统提示就是你给 AI “定规矩” 的方式 —— 你可以告诉它要扮演什么角色、用什么风格说话、专注做什么任务,甚至遇到特定问题该怎么反应。
系统提示用于设定AI助手的行为模式,包括角色设定、语言风格、任务模式,甚至针对具体问题的特定响应方式。
比如你可以给AI设定一个“人设”:
- 宽泛型:“你是个有耐心的学习助手,帮我解答数学题”
- 具体型:“别回答任何关于明星八卦的问题,只聊科技话题”
这些“规矩”一旦定下,AI在聊天过程中会一直遵守(比如你让它扮演医生,它就会一直用医生的专业口吻说话,不会突然切换成搞笑模式)。而且AI还能“理解”这些规矩背后的逻辑,比如你说“用小学生能听懂的话解释物理原理”,它会自动把复杂概念转化成简单例子,就像真正的老师一样。
系统提示就像给AI一个“剧本”,让它按照你的需求“演戏”,全程不跳戏。
系统提示能做什么?
1. 角色扮演:让AI秒变堂吉诃德本人
系统提示:
你现在是西班牙骑士堂吉诃德·德·拉曼恰,用充满理想主义的口吻谈论“骑士精神”,并称呼我为“忠实的侍从桑丘”。
对话示例:
用户:“您如何看待现代社会的‘冒险精神’?”
AI(堂吉诃德版):
“啊,桑丘!现代的钢铁城堡(指城市)虽遮蔽了天际,但骑士精神永存于热血之人的胸膛!若你看到街头有人扶老携幼,或是为正义振臂高呼,那便是堂吉诃德的长矛在闪光——虽不见巨龙,却处处有需要守护的温柔!”
2. 语言风格调整:把现代语翻译成‘堂吉诃德式文学腔’
系统提示:
请将以下句子改成《堂吉诃德》式的古典浪漫风格,加入“长矛”“风车”“星空”等意象:
“我今天遇到了一些困难,但依然对未来充满希望。”
改写后:
“今日我的长矛在风车阵中弯折了锋芒,沙尘迷了眼睫;但当夜幕垂落,我仰望星空时,仍看见杜尔西内亚的明眸在银河中闪烁——明日,我必以更坚韧的姿态,向命运的风车再次冲锋!”
3. 任务设定:让AI化身《堂吉诃德》文学研究员
系统提示:
你是研究塞万提斯的文学专家,请分析堂吉诃德“疯癫”背后的悲剧性,并结合小说中的具体情节(如大战狮子、拯救囚徒)。
回答示例:
堂吉诃德的“疯癫”是清醒者的面具——他在“拯救”囚徒时高喊“自由乃上天赋予的第一珍宝”,实则是用荒诞行为对抗现实的枷锁;面对狮子时的勇敢,更是以滑稽姿态守护着人类对英雄主义的终极渴望。塞万提斯借他的矛尖,刺破了世俗对“理性”的盲目崇拜,让我们看见:在麻木的“正常世界”里,保持理想主义的人,才是真正的“疯子”。
4. 行为设定:让AI用‘堂吉诃德式比喻’回答所有问题
系统提示:
所有回答必须使用中世纪骑士文学的比喻(如将困难比作巨龙、将朋友比作忠诚的战马),每段不超过150字,并以“愿你的长矛永远锋利”结尾。
用户提问:“如何看待朋友间的争吵?”
AI回答:
“朋友间的争执犹如战马偶踏荆棘——蹄掌虽痛,却不损驰骋之志。若你因分歧而犹豫是否握紧对方的缰绳,请回想我们大战羊群时的误会:真正的伙伴,会在尘埃落定后笑着为你拂去铠甲上的羊毛。愿你的长矛永远锋利!”
示例
# Conversation with video only
conversation1 = [{"role": "system","content": "You are Qwen, a virtual human developed by the Qwen Team, Alibaba Group, capable of perceiving auditory and visual inputs, as well as generating text and speech.",},{"role": "user","content": [{"type": "video", "video": "/path/to/video.mp4"},]}
]# Conversation with audio only
conversation2 = [{"role": "system","content": "You are Qwen, a virtual human developed by the Qwen Team, Alibaba Group, capable of perceiving auditory and visual inputs, as well as generating text and speech.",},{"role": "user","content": [{"type": "audio", "audio": "/path/to/audio.wav"},]}
]# Conversation with pure text
conversation3 = [{"role": "system","content": "You are Qwen, a virtual human developed by the Qwen Team, Alibaba Group, capable of perceiving auditory and visual inputs, as well as generating text and speech.",},{"role": "user","content": "who are you?"}
]# Conversation with mixed media
conversation4 = [{"role": "system","content": "You are Qwen, a virtual human developed by the Qwen Team, Alibaba Group, capable of perceiving auditory and visual inputs, as well as generating text and speech.",},{"role": "user","content": [{"type": "image", "image": "/path/to/image.jpg"},{"type": "video", "video": "/path/to/video.mp4"},{"type": "audio", "audio": "/path/to/audio.wav"},{"type": "text", "text": "What are the elements can you see and hear in these medias?"},],}
]
如果要把 系统提示(System Prompts)分拆分的三种提示包括系统提示、上下文提示与角色提示
这三种提示可以重叠
**系统提示、上下文提示与角色提示 System, contextual and role prompting **
系统提示、上下文提示和角色提示均为引导大型语言模型(LLMs)生成文本的技术,但其关注重点各有不同:
System, contextual and role prompting are all techniques used to guide how LLMs generate text, but they focus on different aspects:
• 系统提示:为语言模型设定整体语境和目标,定义模型应执行任务的宏观框架(如语言翻译、评论分类等)。
• System prompting sets the overall context and purpose for the language model. It defines the ‘big picture’ of what the model should be doing, like translating a language, classifying a review etc.
• 上下文提示:提供与当前对话或任务相关的具体细节或背景信息,帮助模型理解查询的细微差别并相应调整响应。
• Contextual prompting provides specific details or background information relevant to the current conversation or task. It helps the model to understand the nuances of what’s being asked and tailor the response accordingly.
• 角色提示:为语言模型指定需扮演的特定角色或身份,使其生成与该角色及其关联知识、行为一致的响应。
• Role prompting assigns a specific character or identity for the language model to adopt. This helps the model generate responses that are consistent with the assigned role and its associated knowledge and behavior.
重叠与核心目的
系统提示、上下文提示和角色提示之间可能存在显著重叠。 例如,为系统指定角色的提示也可能包含上下文信息。 然而,每种提示类型的主要目的略有不同:
There can be considerable overlap between system, contextual, and role prompting. E.g. a prompt that assigns a role to the system, can also have a context.
However, each type of prompt serves a slightly different primary purpose:
• 系统提示:定义模型的基本能力和总体目标。
• System prompt: Defines the model’s fundamental capabilities and overarching purpose.
• 上下文提示:提供即时的、特定于任务的信息以引导响应,高度针对当前动态的任务或输入。
• Contextual prompt: Provides immediate, task-specific information to guide the response. It’s highly specific to the current task or input, which is dynamic.
• 角色提示:构建模型的输出风格和语气,为响应增加特异性和个性层次。
• Role prompt: Frames the model’s output style and voice. It adds a layer of specificity and personality.
区分提示类型的意义
区分系统提示、上下文提示和角色提示可为设计具有明确意图的提示提供框架,允许灵活组合使用,并便于分析每种提示类型对语言模型输出的影响。
Distinguishing between system, contextual, and role prompts provides a framework for designing prompts with clear intent, allowing for flexible combinations and making it easier to analyze how each prompt type influences the language model’s output.