• 消息
  • 托管智能体
  • 管理

Search...
⌘K
用例
概览工单路由客户支持智能体内容审核法律摘要
提示工程
概览提示最佳实践Claude Fable 5 提示技巧Claude Opus 4.8 提示技巧控制台提示工具
测试与评估
定义成功标准并构建评估在控制台中使用评估工具降低延迟
加强防护措施
减少幻觉提高输出一致性缓解越狱攻击减少提示泄露
参考
术语表

Log in
减少提示泄露
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Solutions

  • AI agents
  • Code modernization
  • Coding
  • Customer support
  • Education
  • Financial services
  • Government
  • Life sciences

Partners

  • Amazon Bedrock
  • Google Cloud's Vertex AI

Learn

  • Blog
  • Courses
  • Use cases
  • Connectors
  • Customer stories
  • Engineering at Anthropic
  • Events
  • Powered by Claude
  • Service partners
  • Startups program

Company

  • Anthropic
  • Careers
  • Economic Futures
  • Research
  • News
  • Responsible Scaling Policy
  • Security and compliance
  • Transparency

Learn

  • Blog
  • Courses
  • Use cases
  • Connectors
  • Customer stories
  • Engineering at Anthropic
  • Events
  • Powered by Claude
  • Service partners
  • Startups program

Help and security

  • Availability
  • Status
  • Support
  • Discord

Terms and policies

  • Privacy policy
  • Responsible disclosure policy
  • Terms of service: Commercial
  • Terms of service: Consumer
  • Usage policy
最佳实践/加强防护措施

减少提示泄露

提示泄露可能会暴露您希望在提示中"隐藏"的敏感信息。虽然没有任何方法是万无一失的,但以下策略可以显著降低风险。

在尝试减少提示泄露之前

请仅在绝对必要时才考虑使用防泄露的提示工程策略。尝试对提示进行防泄露处理可能会增加复杂性,由于增加了 LLM 整体任务的复杂度,这可能会降低任务其他部分的性能。

如果您决定实施防泄露技术,请务必彻底测试您的提示,以确保增加的复杂性不会对模型的性能或其输出质量产生负面影响。


请先尝试监控技术,例如输出筛查和后处理,以尝试捕获提示泄露的情况。

减少提示泄露的策略

  • 将上下文与查询分离: 您可以尝试使用系统提示将关键信息和上下文与用户查询隔离开来。您可以在 User 轮次中强调关键指令,然后通过预填充 Assistant 轮次来再次强调这些指令。(注意:Claude Fable 5、Claude Mythos 5、Claude Mythos Preview、Claude Opus 4.8、Claude Opus 4.7、Claude Opus 4.6 和 Claude Sonnet 4.6 不支持预填充。)

  • 使用后处理:过滤 Claude 的输出,查找可能表明泄露的关键词。相关技术包括使用正则表达式、关键词过滤或其他文本处理方法。
    
    您还可以使用经过提示的 LLM 来过滤输出,以捕获更细微的泄露。
  • 避免不必要的专有细节:如果 Claude 执行任务时不需要某些信息,就不要包含它。额外的内容会分散 Claude 对"不泄露"指令的注意力。
  • 定期审计:定期审查您的提示和 Claude 的输出,以发现潜在的泄露。

请记住,目标不仅仅是防止泄露,还要保持 Claude 的性能。过于复杂的防泄露措施可能会降低结果质量。关键在于平衡。

Was this page helpful?

  • 在尝试减少提示泄露之前
  • 减少提示泄露的策略