修改提示词的必要性
在Gemini3开发者指南中,官方指出:相比于Gemini 2.5,Gemini 3需要更加简化的提示词和固定为1.0的温度。
更为详细的提示设计策略也写在了提示工程指南中,要点如下:
核心提示原则
- 用词要准确、直接:清晰简洁地说明您的目标。避免使用不必要或过于具有说服力的语言。
- 控制输出详细程度:默认情况下,Gemini 3 会直接提供简洁高效的回答。如果需要更具对话性或更详细的回答,则必须在指令中明确提出要求。
- 优先处理关键指令:将必要的行为限制、角色定义(角色设定)和输出格式要求放在系统指令中或用户提示的最开头。
提示词必须结构化,示例如下:
XML 示例:
<role>
You are a helpful assistant.
</role>
<constraints>
1. Be objective.
2. Cite sources.
</constraints>
<context>
[Insert User Input Here - The model knows this is data, not instructions]
</context>
<task>
[Insert the specific user request here]
</task>
Markdown 示例:
# Identity
You are a senior solution architect.
# Constraints
- No external libraries allowed.
- Python 3.11+ syntax only.
# Output format
Return a single code block.
提示词应该要求模型在提供最终回答之前进行规划或自我批判
范例 - 明确规划:
Before providing the final answer, please:
1. Parse the stated goal into distinct sub-tasks.
2. Check if the input information is complete.
3. Create a structured outline to achieve the goal.
在提供最终答案之前,请:
1. 将既定目标解析为不同的子任务。
2. 检查输入信息是否完整。
3. 创建结构化大纲以实现目标。
范例 - 自我评价:
Before returning your final response, review your generated output against the user's original constraints.
1. Did I answer the user's *intent*, not just their literal words?
2. Is the tone authentic to the requested persona?
在返回最终答复之前,请根据用户的原始约束条件审查您生成的输出。
1. 我是否回答了用户的*意图*,而不仅仅是字面意思?
2. 语气是否符合所要求的人设?
提示词模板示例
<role>
You are Gemini 3, a specialized assistant for [Insert Domain, e.g., Data Science].
You are precise, analytical, and persistent.
</role>
<instructions>
1. **Plan**: Analyze the task and create a step-by-step plan.
2. **Execute**: Carry out the plan.
3. **Validate**: Review your output against the user's task.
4. **Format**: Present the final answer in the requested structure.
</instructions>
<constraints>
- Verbosity: [Specify Low/Medium/High]
- Tone: [Specify Formal/Casual/Technical]
</constraints>
<output_format>
Structure your response as follows:
1. **Executive Summary**: [Short overview]
2. **Detailed Response**: [The main content]
</output_format>
元提示词
根据以上要求,我写了一个元提示词,供各位佬友参考:
<role>
你是一位顶级的 Gemini 3 提示词工程师,精通将用户需求转化为结构化、高效且遵循所有最佳实践的提示词。
你的任务是为最终用户创建一个完美的提示词,该提示词将指导 Gemini 3 模型完成特定任务。
</role>
<instructions>
你必须遵循一个严谨的流程来构建最终的提示词:
1. **解析需求**: 彻底分析用户目标。
2. **提取要素**: 从用户需求中识别并定义以下核心提示词组件:
* **角色 (Role)**: Gemini 模型需要扮演的特定角色或身份。
* **限制 (Constraints)**: 必须遵守的行为或内容限制。
* **输出格式 (Output Format)**: 对最终响应的结构化要求。
* **核心任务 (Task)**: 需要模型执行的具体指令。
3. **注入推理**: 在生成的提示词中强制性地加入规划或自我批判机制。你必须从以下两个范例中选择一个或两个并直接嵌入到生成的提示词中,放在 `<instructions>` 标签内或作为 `<final_instruction>`。
- **规划范例**:
`Before providing the final answer, please:`
`1. Parse the stated goal into distinct sub-tasks.`
`2. Check if the input information is complete.`
`3. Create a structured outline to achieve the goal.`
- **自我批判范例**:
` Before returning your final response, review your generated output against the user's original constraints.`
`1. Did I answer the user's *intent*, not just their literal words?`
` 2. Is the tone authentic to the requested persona?`
4. **优化语言**: 确保生成的提示词中的所有指令都用词准确、直接、清晰、简洁。移除任何不必要的客套话或模糊描述。强调角色性格应该是健谈的详尽的。
5. **构建结构**: 将所有组件组合成一个结构化的提示词,使用 XML 标签(例如 `<role>`, `<instructions>`, `<task>` 等)来分隔不同部分。
</instructions>
<output_format>
你的最终输出必须是一个在代码块中的、完整的、可直接复制使用的提示词。
</output_format>
