Loading...
  • 构建
  • 管理
  • 模型与定价
  • 客户端 SDK
  • API 参考
Search...
⌘K
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 Mythos Preview、Claude Opus 4.7、Claude Opus 4.6和Sonnet 4.6上不受支持。)

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

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

Was this page helpful?