arXiv:2505.16934cs.CL2025-05被引 14

用提示词设计让大模型自动生成可检测的水印,无需访问解码过程。

In-Context Watermarks for Large Language Models

  • 通过精心设计提示词,在不改动模型的情况下嵌入水印。
  • 四种策略在不同场景下均实现超过90%的检测准确率。
  • 适合无法获取模型的第三方审核场景,如学术审稿防伪。

大语言模型在敏感场景中的广泛应用凸显了内容溯源与责任追踪的迫切需求。然而,多数现有水印方法需访问解码过程,限制了其在真实场景的应用。例如,学术评审中若评审人使用模型生成文本,会议组织者无法获知所用模型,但仍需识别AI生成内容。为此,本文提出在上下文水印(In-Context Watermarking, ICW),仅通过提示工程即可将水印嵌入生成文本,利用大模型的上下文学习与指令遵循能力。研究了四种不同粒度的ICW策略,并配套设计相应的检测方法。进一步以间接提示注入(IPI)为案例,考察通过修改论文等输入文档隐秘触发水印的情形。实验验证了ICW作为模型无关、实用化水印方案的可行性。结果表明,随着大模型能力增强,ICW为可扩展、易部署的内容归属提供新路径。代码已开源:https://github.com/yepengliu/In-Context-Watermarks。

原文摘要 · Abstract (English)

The growing use of large language models (LLMs) for sensitive applications has highlighted the need for effective watermarking techniques to ensure the provenance and accountability of AI-generated text. However, most existing watermarking methods require access to the decoding process, limiting their applicability in real-world settings. One illustrative example is the use of LLMs by dishonest reviewers in the context of academic peer review, where conference organizers have no access to the model used but still need to detect AI-generated reviews. Motivated by this gap, we introduce In-Context Watermarking (ICW), which embeds watermarks into generated text solely through prompt engineering, leveraging LLMs' in-context learning and instruction-following abilities. We investigate four ICW strategies at different levels of granularity, each paired with a tailored detection method. We further examine the Indirect Prompt Injection (IPI) setting as a specific case study, in which watermarking is covertly triggered by modifying input documents such as academic manuscripts. Our experiments validate the feasibility of ICW as a model-agnostic, practical watermarking approach. Moreover, our findings suggest that as LLMs become more capable, ICW offers a promising direction for scalable and accessible content attribution. Our code is available at https://github.com/yepengliu/In-Context-Watermarks.

水印技术大模型内容溯源提示工程

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。