跳到主内容
精选88Ahead of AI(RSS)技巧与观点

Anthropic Claude文本水印技术原理深度解析

How Claude Watermarks AI-Generated Text

原文
推荐理由

深入拆解Claude水印底层逻辑,适合想了解AI内容溯源技术与LLM采样机制的研究者收藏学习。

I recently posted a Substack note about Claude’s new watermarking process and implementation. Since it’s such a popular topic and sparked such a lively discussion, I thought it might be interesting to go into a bit more detail when explaining how it works.

我最近发布了一篇关于 Claude 新水印处理及其实现的 Substack 笔记。由于这是一个非常热门的话题,并引发了热烈的讨论,我认为在解释其工作原理时深入探讨一些细节可能会很有趣。

Instead of the usual text article, I recorded a little lecture on the topic (to change it up a bit from my usual articles). So, below is the video along with a transcript.

这次我没有像往常一样写文章,而是录制了一段关于该主题的小讲座(以与我平时的文章形式有所区别)。因此,下面是视频以及相应的文字稿。

Originally, I planned to make 10 slides and record a short 10-min video. However, while putting it together, I added some crucial details here and there, resulting in >50 slides and a 48 min recording.

最初,我计划制作 10 张幻灯片并录制一段简短的 10 分钟视频。然而,在整理过程中,我在各处添加了一些关键细节,最终导致幻灯片超过 50 张,录音时长达到 48 分钟。

I hope that this now explains it well, though! Happy watching!

希望现在这能把它解释清楚了!观看愉快!

  • I also have a YouTube version if you prefer using the YouTube player.
  • And here is a link to the slides
  • 如果你更喜欢使用 YouTube 播放器,我也提供了 YouTube 版本。
  • 这是幻灯片的链接

Subscribe now

立即订阅

Video Transcript

视频文字稿

Note: The transcript below is slightly edited and cleaned up for readability but preserves the overall order and flow of the video lecture above.

注:下面的文字稿经过轻微编辑和整理以提高可读性,但保留了上述视频讲座的整体顺序和流程。

0:00

0:00

How Claude’s Text Watermarking Works

Claude 文本水印的工作原理

Slide 2 of 52, time stamp 0:00

第 2 张幻灯片,时间戳 0:00

Hi everyone. So, a few days ago, Anthropic announced that they will watermark the text outputs of their Claude models. I then did a social media post briefly explaining how that works. And yeah, this was quite the popular post. So not the watermarking itself was popular, but I guess the explanation or the mechanism behind it. Then, it might be worthwhile expanding this a bit to explain it in more detail, because this post only had one figure, and there were a lot of questions and discussions.

大家好。几天前,Anthropic 宣布将对他们的 Claude 模型的文本输出进行水印标记。随后我做了一篇社交媒体帖子,简要解释了这是如何工作的。是的,这篇帖子相当受欢迎。不过受欢迎的不是水印本身,而是我的解释或背后的机制。因此,也许值得对此稍作扩展,以便更详细地解释它,因为那篇帖子只有一张图,而且有很多问题和讨论。

So, I thought, well, let’s make a few more figures. I actually originally planned to do like 10 slides and walk you through it. It ended up being 50 slides, but I hope this really explains how this watermarking technique works well, how watermarking itself can fail or be removed, and so forth. So I think it might be an interesting topic because a lot of people use LLMs these days and also consume a lot of text on the Internet that might be generated by LLMs.

所以我想,好吧,让我们多画几张图。我实际上原本计划做大约 10 张幻灯片来带你过一遍。结果最后变成了 50 张幻灯片,但我希望这能很好地解释这种水印技术是如何工作的、水印本身可能失败或被移除的情况等等。我认为这可能是一个有趣的话题,因为如今很多人都在使用大语言模型(LLMs),并且消费大量可能由 LLMs 生成的互联网文本。

And now there’s going to be this watermarking, and there’s this, I guess, fear of watermarking making text worse, or what’s actually the benefit of this watermarking? And so what does it mean? And I think if we understand a bit better what watermarking is, that goes a long way, and then we can make up our own minds about whether that’s a good thing or not, and so forth, like the pros and cons.

而现在将出现这种水印,我猜大家有一种担心,即水印会使文本质量变差,或者这种水印的实际好处是什么?这意味着什么?我认为如果我们能更好地理解什么是水印,那就迈出了重要的一步,然后我们可以自行判断这究竟是好事还是坏事,以及利弊得失等。

So, my goal here is really to explain how the underlying mechanism works and how they are going to implement this type of watermarking, text watermarking.

所以,我这里的真正目标是解释底层机制是如何工作的,以及他们将如何实施这种类型的水印技术——文本水印。

Slide 2 of 52, time stamp 1:41

第2张幻灯片(共52张),时间戳 1:41

It’s also a great example to illustrate why understanding things from scratch is actually quite useful. This watermarking technique is also a nice way to explain how conventional models or LLMs in general work under the hood. So yeah, you may know I like doing things from scratch. Like, I have my books: Build a Large Language Model From Scratch, Build a Reasoning Model From Scratch. I have some articles labeled from scratch.

这也是一个很好的例子,用来说明从头开始理解事物实际上非常有用。这种水印技术也是解释传统模型或大型语言模型(LLMs)内部工作原理的好方法。是的,你可能知道我喜欢从头开始做事。比如,我有我的书:《从零构建大语言模型》、《从零构建推理模型》。我还有一些以“从零开始”为标签的文章。

So, for me, “ from scratch often includes coding. So this one will not be coding-related, but coding from scratch is actually a very, very useful technique because it really helps you understand how something is implemented. And then from that we can derive our understanding, figures, concepts, because if we don’t really implement things, if there’s no code, it’s really sometimes ambiguous. And of course, you know, as I realized, not everyone is coding from scratch anymore.

对我来说,“从零开始”通常包括编码。所以这次不会涉及编码,但从零开始编码实际上是一种非常非常有用的技巧,因为它确实能帮助你理解某物是如何实现的。然后我们可以由此推导出我们的理解、图表和概念,因为如果我们不真正实现这些东西,如果没有代码,有时真的很模糊。当然,你知道,正如我所意识到的,并不是每个人都在从零开始编码了。

Like back in the day, coding something from scratch was all we had. I mean, there were only humans coding. Nowadays, coding can be done by LLMs. However, that doesn’t mean reading code is no longer useful, because it carries a lot of information. So in this case here with this watermarking, spending some time coding an LLM from scratch really makes you realize how this sampling inside is implemented. We still have some relevant code snippets.

就像过去一样,从零开始编码是我们唯一拥有的方式。我的意思是,当时只有人类在编码。如今,编码可以由大型语言模型完成。然而,这并不意味着阅读代码不再有用,因为它携带了大量信息。所以在这种情况下,通过从零开始编码一个大型语言模型来研究这种水印,真的会让你意识到内部的采样是如何实现的。我们仍然有一些相关的代码片段。

And then that really, in turn, helps us understand, oh, the watermarking is applied at this position, and this has so-and-so consequences and so forth. So I think even though people may not be coding from scratch, at least not all the time anymore, it is still useful being able to, let’s say, build something from scratch for educational purposes to understand something deeply and then also for research purposes to manipulate this in a transparent way that is not hidden away in tons of layers of abstraction.

然后反过来,这有助于我们理解,哦,水印应用在这个位置,并且会产生这样的后果等等。所以我认为,即使人们可能不再总是从零开始编码,至少不像以前那样频繁,能够为了教育目的而从头构建某些东西以深入理解某些内容,以及为了研究目的以透明且不被隐藏在大量抽象层中的方式来操作它,仍然是有用的。

But that aside, I think it’s just a coincidental nice relationship here because, for this slide deck, I actually used a lot of figures from my from-scratch coding materials.

但除此之外,我认为这里只是一个巧合的良好关系,因为对于这个演示文稿,我实际上使用了我从零开始编码材料中的许多图表。

Slide 3 of 52, time stamp 3:58

第3张幻灯片(共52张),时间戳 3:58

So a few days ago (this is August 14), there was this article, How Claude’s Text Watermark Works, and there was this article here; it’s just like a screen recording, so it can have everything in the slides, but there’s plenty of detail. They updated it actually a couple of times, so originally when I read this, it was a way shorter. Still, it is very, I guess, conceptual; there’s like this overview, and there’s, I mean, there’s not a single figure in there.

所以几天前(今天是8月14日),有一篇文章叫《Claude 文本水印的工作原理》,还有一篇在这里;它就像屏幕录像一样,所以幻灯片里的所有内容都有,但细节非常丰富。他们实际上更新了几次,所以最初我读到的时候,篇幅要短得多。尽管如此,我觉得它非常概念化;有一个概述,我的意思是,里面没有任何图表。

And so it’s kind of still hard to understand what they’re trying to do. So they explain a lot about why they’re going to do it, but they don’t explain how. They’re linking to one paper somewhere there, which is very technical also. So I do think it makes sense maybe to take a step back and start at the beginning to kind of understand what they’re trying to implement here with this watermarking technique.

因此,理解他们到底想做什么仍然有点困难。所以他们解释了很多为什么要这么做的原因,但没有解释具体怎么做。他们在某处链接了一篇论文,那篇论文也非常技术化。所以我确实认为,也许应该退一步,从头开始,以便更好地理解他们试图用这种水印技术实现什么。

And so the motivation, by the way, of watermarking is for them to identify if someone posts some text that they can say, oh, this text was generated by our Claude Opus 4.8 model, for example, so that they have a way to tell, OK, this text is AI-generated because it carries this watermark. And this watermark is invisible to users, so only they can decode it and find out whether the text has their watermark.

顺便说一下,水印的动机是为了让他们能够识别是否有人发布了某些文本,他们可以声称“哦,这段文本是由我们的 Claude Opus 4.8 模型生成的”,例如,这样他们就有一种方法来表明:好的,这段文本是 AI 生成的,因为它带有这种水印。这种水印对用户是不可见的,所以只有他们才能解码并找出文本是否带有他们的水印。

Why can only they do it? We will get to that later in this (hopefully not too long a video), but one thing at a time.

为什么只有他们能做到这一点?我们将在本视频(希望不会太长)的后面部分讲到这一点,但一次只做一件事。

5:38

5:38

How LLM Text Generation Works

LLM 文本生成是如何工作的

Slide 4 of 52, time stamp 5:35

第 52 张幻灯片的第 4 张,时间戳 5:35

So I wanted to start with a brief prelude to explain how text generation works in LLMs, because based on that we can then more easily understand how the watermarking works and that this is actually not a huge, expensive thing on top of it. It’s really just like a minor, I guess, tweak inside the regular text generation process.

所以我打算先做一个简短的前奏,解释 LLM 中的文本生成是如何工作的,因为基于此,我们可以更容易地理解水印是如何工作的,以及这实际上并不是在上面增加一个巨大且昂贵的东西。它真的只是像常规文本生成过程中的一个微小的调整,我想。

Slide 5 of 52, time stamp 6:01

第 52 张幻灯片的第 5 张,时间戳 6:01

So when we are using something like ChatGPT, for example, let’s say I ask the question, the capital of Germany is, and yeah, ChatGPT or other LLMs, so this is just like an example would, for example, answer “Berlin”. So here, in this case, it’s generating two tokens, like “Berlin” and the period. But for simplicity, let’s assume it’s generating one token. So the next token is the “Berlin” token. How is this token generated internally?

所以当我们使用类似 ChatGPT 的东西时,例如,假设我问一个问题:德国的首都是,是的,ChatGPT 或其他 LLMs,比如这个例子会回答“柏林”。所以在这种情况下,它生成了两个 token,比如“Berlin”和句号。但为了简单起见,让我们假设它只生成了一个 token。所以下一个 token 是“Berlin”token。这个 token 在内部是如何生成的?

What is happening under the hood when we type something here like the capital of Germany is and receive a token like “Berlin” back? What is actually going on there behind the scenes?

当我们在上面输入类似“德国的首都是”这样的内容并收到“Berlin”这样的 token 返回时,幕后发生了什么?实际上背后在进行着什么操作?

Slide 6 of 52, time stamp 6:41

第 52 张幻灯片的第 6 张,时间戳 6:41

So in the next couple of slides, I want to briefly talk about what happens under the hood when this next token is generated.

因此,在接下来的几张幻灯片中,我想简要谈谈在生成下一个 token 时底层发生了什么。

Slide 7 of 52, time stamp 6:50

第 7 张幻灯片(共 52 张),时间戳 6:50

So assume again that our prompt is the capital of Germany is. And the first step here is to convert this into token IDs. So tokenizing it and converting it into token IDs is one of the main steps at the beginning. This is outside. It’s not inside the LLM; it’s outside of the LLM. So we are simply converting the text into token IDs. It’s just a format that embedding layers can work with.

因此,假设我们的提示词是“德国首都是”。这里的第一步是将其转换为 token ID。因此,分词并将其转换为 token ID 是初始阶段的主要步骤之一。这一步是在外部进行的,不在 LLM 内部;它位于 LLM 之外。我们只是简单地将文本转换为 token ID。这仅仅是一种嵌入层可以处理的格式。

Slide 8 of 52, time stamp 7:22

第 8 张幻灯片(共 52 张),时间戳 7:22

And then this passes through the LLM. And the LLM gives us a score distribution for the next token.

然后,这些数据通过 LLM。LLM 为我们提供下一个 token 的得分分布。

Slide 9 of 52, time stamp 7:31

第 9 张幻灯片(共 52 张),时间戳 7:31

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

另一事件,读法相近