Is ‘Attention’ the Essence of Intelligence?
E verything that’s swept the world since the 2022 release of ChatGPT — “the AI economy”; data centers; chatbots acting as best friends, doctors, and mathematicians; talk of existential risk — it all starts, in some sense, with an intern in a University of Montreal lab named Dzmitry Bahdanau.
自 2022 年 ChatGPT 发布以来,席卷全球的一切——“人工智能经济”;数据中心;聊天机器人充当最好的朋友、医生和数学家;谈论存在风险——从某种意义上说,这一切都始于蒙特利尔大学实验室的一名实习生,名叫德兹米特里·巴德瑙 (Dzmitry Bahdanau)。
It was 2014.
那是2014年。
The 23-year-old Belarusian, who had been coding competitively since he was a kid but hadn’t done academic research before, was asked to help figure out how to get a computer to translate sentences from English to French.
这位 23 岁的白俄罗斯人从小就开始参加编程比赛,但之前从未做过学术研究,他被要求帮助弄清楚如何让计算机将句子从英语翻译成法语。
Bahdanau was working with artificial neural networks, which had already shown promise in pattern-recognition tasks such as deciphering handwriting and identifying objects in photos.
巴德瑙正在研究人工神经网络,该网络已经在模式识别任务中显示出前景,例如破译笔迹和识别照片中的物体。
The networks learn to recognize patterns by strengthening and weakening connections between nodes in response to training data.
网络通过响应训练数据加强和削弱节点之间的连接来学习识别模式。
Bahdanau quietly doubted their potential to achieve anything like human-level intelligence, but his adviser, the computer scientist Yoshua Bengio, and the postdoc on the project, Kyunghyun Cho, were believers.
Bahdanau 悄悄地怀疑它们实现人类智能水平的潜力,但他的顾问、计算机科学家 Yoshua Bengio 和该项目的博士后 Kyunghyun Cho 都是信徒。
And translation was widely seen as a formidable and interesting problem for neural networks to try to solve.
翻译被广泛认为是神经网络需要解决的一个艰巨而有趣的问题。
I n philosophy, “qualia” refers to the subjective qualities of our experience: what it’s like for Alice to see blue or for Bob to feel delighted.
在哲学中,“感受性”指的是我们体验的主观品质:爱丽丝看到蓝色或鲍勃感到高兴是什么感觉。
Qualia are “the ways things seem to us,” as the late philosopher Daniel Dennett put it.
正如已故哲学家丹尼尔·丹尼特所说,感受性是“事物在我们看来的方式”。
In these essays, our columnists follow their curiosity, and explore important but not necessarily answerable scientific questions.
在这些文章中,我们的专栏作家追随他们的好奇心,探索重要但不一定可以回答的科学问题。
Translation is not as simple as swapping each English word for a French one.
翻译并不像将每个英语单词替换为法语单词那么简单。
Languages have different grammatical structures and are riddled with idioms and connotations, all of which had long stymied attempts to automate the process.
语言具有不同的语法结构,并且充满了习语和内涵,所有这些都长期以来阻碍了自动化过程的尝试。
You can’t simply implement rules of translation because there are none.
你不能简单地实施翻译规则,因为根本不存在翻译规则。
But neural networks seemed promising because they learn by example.
但神经网络似乎很有前途,因为它们通过实例进行学习。
They can be trained on huge databases of paired English and French sentences to, eventually, absorb the quasi-rules, exceptions, and subtleties.
他们可以接受包含英语和法语配对句子的庞大数据库的训练,最终吸收准规则、例外和微妙之处。
Results had been mediocre, though; the longer the sentence, the worse neural networks performed.
但结果却很平庸。句子越长,神经网络的表现就越差。
That’s because researchers were trying to cram each sentence’s data into a fixed amount of memory before decoding the sentence in the target language.
这是因为研究人员试图在用目标语言解码句子之前将每个句子的数据塞进固定数量的内存中。
It was a bottleneck that limited how complex and sophisticated translations could be.
这是限制翻译复杂程度的瓶颈。
The network architecture just wasn’t right.
网络架构不正确。
So Bahdanau tried something different.
所以巴达瑙尝试了一些不同的东西。
“It was just obviously the right thing to do — one of these things that happens once in a while in science where it’s just very clear to someone who is not very experienced in the field,” he recalled, speaking to me from Montreal, where he still works in AI.
“这显然是正确的做法——科学界偶尔会发生这样的事情,对于在该领域不太有经验的人来说,这一点非常清楚,”他在蒙特利尔对我回忆道,他仍在蒙特利尔从事人工智能工作。
“And it just worked.
“而且它确实奏效了。
From the very first attempt.”
从第一次尝试开始。”
Bahdanau’s trick, a mathematical operation that he, Cho, and Bengio referred to as “attention,” enabled their neural network to translate long sentences just as well as short ones.
Bahdanau 的技巧是一种被他、Cho 和 Bengio 称为“注意力”的数学运算,使他们的神经网络能够翻译长句子和短句子。
That meant the approach was scalable.
这意味着该方法是可扩展的。
Other AI researchers at the time quickly integrated attention into their neural network designs.
当时的其他人工智能研究人员很快将注意力融入到他们的神经网络设计中。
Then, in 2017, a team at Google devised a new kind of neural network architecture called a transformer that supercharged the attention method and stripped away everything else.
然后,在 2017 年,谷歌的一个团队设计了一种称为 Transformer 的新型神经网络架构,它增强了注意力方法并剥离了其他一切。
The team’s paper, “ Attention Is All You Need ,” reported that transformers achieved state-of-the-art translation while requiring a fraction of the computation needed to train prior models.
该团队的论文《Attention Is All You Need》报道称,Transformers 实现了最先进的翻译,同时只需要训练先前模型所需的一小部分计算量。
The paper, which has since been cited more than 250,000 times, was a watershed moment in AI.
这篇论文已被引用超过 25 万次,是人工智能领域的一个分水岭。
Large language models such as ChatGPT and Claude followed.
ChatGPT 和 Claude 等大型语言模型紧随其后。
Given the staggering power that’s been unleashed, it’s worth asking what this attention mechanism is exactly, why it is “all you need,” and why machine translation was the task that unlocked it all.
考虑到所释放的惊人力量,我们有必要问一下这种注意力机制到底是什么,为什么它是“你所需要的一切”,以及为什么机器翻译是解锁这一切的任务。
Attention is a way for us to understand how a single AI model can converse with us, diagnose diseases, generate realistic videos, solve long-standing math problems , and more.
注意力是我们理解单个人工智能模型如何与我们对话、诊断疾病、生成真实视频、解决长期存在的数学问题等的一种方式。
Is it somehow at the heart of intelligence — artificial and otherwise?
它是否在某种程度上处于智能的核心——人工智能还是其他智能?
Sentences with pronouns such as “it” in them illustrate the challenge that attention overcomes.
含有“it”等代词的句子说明了注意力所克服的挑战。
Consider: “The animal didn’t cross the street because it was too tired.” And: “The animal didn’t cross the street because it was too wide.” To translate these sentences correctly into French, an AI model must determine that, in the first one, “it” refers to the animal, which is a masculine word in French, so the translation should use that form of the pronoun, il .
想一想:“动物没有过马路,因为它太累了。”并且:“这只动物没有过马路,因为它太宽了。”为了将这些句子正确翻译成法语,人工智能模型必须确定第一个句子中的“it”指的是动物,这是法语中的男性词,因此翻译应该使用代词 il 的这种形式。
But in the second sentence, “it” refers to the street, a feminine word that requires a different pronoun, elle .
但在第二句话中,“it”指的是街道,这是一个阴性词,需要不同的代词 elle 。
How can the machine figure this out?
机器如何解决这个问题呢?
And it just worked.
它就奏效了。
From the very first attempt.
从第一次尝试开始。
Bahdanau remembered doing translation exercises when he was learning English in school.
巴达瑙记得他在学校学习英语时做过翻译练习。
To write each next word of his translated sentence, he’d have to glance all around the source text to figure out what should come next.
为了写出翻译句子的每个下一个单词,他必须浏览一下源文本才能弄清楚接下来应该写什么。
“Literally you have your source sentence on the left and your writing on the right, and you’ll be, like, turning your head, left-right, left-right,” he said.
“从字面上看,你的源句子在左边,你的文字在右边,你会像左转右转,左转右转,”他说。
“That process is what I expressed as a neural mechanism.” The tool of attention that he gave to his neural network was a mathematical way for the network to identify the word or words anywhere in a sentence that would most inform the next word of the translation.
“这个过程就是我所说的神经机制。”他为神经网络提供的注意力工具是一种数学方法,让网络能够识别句子中任何位置的一个或多个单词,这些单词最能告知翻译的下一个单词。
In the case of our ambiguous pronoun, “it,” the system navigates the rest of the sentence to determine which words affect its meaning the most.
对于模棱两可的代词“it”,系统会导航句子的其余部分,以确定哪些单词对其含义影响最大。
A transformer consists of many layers of nodes connected to nodes in adjacent layers.
变压器由许多层节点组成,这些节点连接到相邻层中的节点。
When a sentence is fed into a transformer, each word is first converted into a numerical representation called a vector, which we can imagine as an arrow pointing in a certain direction.
当一个句子被输入到变压器中时,每个单词首先被转换为称为向量的数字表示,我们可以将其想象为指向某个方向的箭头。
These vectors pass through the network, and numbers called weights (determined by the model’s training) dictate how they are transformed in each layer.
这些向量穿过网络,称为权重的数字(由模型的训练决定)决定它们在每一层中的转换方式。
The weights turn each word’s current vector representation into three new vectors specific to that word — a “query,” “key,” and “value” — that each serve a different purpose in the attention operation.
权重将每个单词的当前向量表示转换为特定于该单词的三个新向量——“查询”、“键”和“值”——每个向量在注意力操作中都有不同的目的。
The network performs this operation several times in parallel through systems called attention heads.
网络通过称为注意力头的系统并行执行此操作多次。
An attention head compares each word’s query with the keys of all the other words in the sentence.
注意力头将每个单词的查询与句子中所有其他单词的键进行比较。
How well these vectors match up — how much they point in the same direction — determines how strongly the value of each other word contributes to a new, updated vector for the word at hand.
这些向量的匹配程度(它们指向同一方向的程度)决定了每个其他单词的值对当前单词的新的、更新的向量的贡献程度。
Information about other words in the sentence literally becomes incorporated into each word’s representation.
句子中其他单词的信息字面上会合并到每个单词的表示中。
The system is converting context into math.
系统正在将上下文转换为数学。
When “The animal didn’t cross the street because it was too tired” enters a transformer, the first stack of layers in the network, known as the encoder, uses the attention operation to build up a contextual understanding of the sentence.
当“动物没有过马路,因为它太累了”进入变压器时,网络中的第一层堆栈(称为编码器)使用注意力操作来建立对句子的上下文理解。
In each layer, each attention head generates a query (along with a key and value) for “it.” This query vector can be thought of as a request for information that exists elsewhere in the sentence.
在每一层中,每个注意力头都会生成一个针对“it”的查询(以及键和值)。这个查询向量可以被认为是对句子中其他地方存在的信息的请求。
For instance, in a deep layer (after the network has already accumulated information about words), the query for “it” might be interpretable as: “I need an earlier noun that could plausibly be the thing that is tired.” Meanwhile, the key associated with “animal” might effectively advertise itself as a noun that’s capable of being tired, among many other features.
例如,在深层(在网络已经积累了有关单词的信息之后),对“it”的查询可能会被解释为:“我需要一个较早的名词,它可能是那个累了的东西。”与此同时,与“动物”相关的键可能会有效地将自己宣传为一个能够疲倦的名词,以及许多其他功能。
Its key therefore matches the query better than the key for “street.” And that causes the value associated with “animal” to contribute more heavily to the updated representation of “it.”
因此,它的键比“street”的键更匹配查询。这导致与“动物”相关的价值对“它”的更新表示做出更大的贡献。
That new, context-enriched representation of “it” passes into the next layer.
这种新的、上下文丰富的“它”表示传递到下一层。
There, the network performs attention all over again.
在那里,网络再次进行注意力处理。
Successive rounds give the words increasingly rich representations of themselves.
连续的回合赋予单词越来越丰富的表现形式。
Experts say it’s often hard to interpret what any given attention head is doing, but collectively they pick up on many kinds of relationships, from the partnership between nouns and verbs to the association between living beings and feelings.
专家表示,通常很难解释任何特定的注意力头在做什么,但他们总的来说会发现多种关系,从名词和动词之间的伙伴关系到生物和情感之间的关联。
Later layers build on associations established by earlier layers, so that by the time the sentence emerges from the encoder, “it” is imbued with something resembling meaning.
后面的层建立在前面层建立的关联的基础上,因此当句子从编码器中出现时,“它”就充满了类似含义的东西。
After that, the second part of the transformer, the decoder, produces the French translation one word at a time, using attention to draw on the encoder’s numerical representations of the English words as it decides which French word to spit out next.
之后,转换器的第二部分,即解码器,一次一个单词地生成法语翻译,在决定接下来要吐出哪个法语单词时,利用注意力吸引编码器对英语单词的数字表示。
The contextual information encoded in the English sentence helps translate “it” as the masculine il .
英语句子中编码的上下文信息有助于将“it”翻译为阳性 il 。
Crucially, no one had to tell a transformer that animals get tired and streets may be wide.
至关重要的是,没有人必须告诉变形金刚动物会累,街道可能会很宽。
The neural network discovers such associations during training, by learning from huge numbers of English sentences paired with their French translations.
神经网络在训练过程中通过学习大量英语句子及其法语翻译来发现这种关联。
These associations get built into the weights.
这些关联被内置到权重中。
The network starts out with random weights that produce unhelpful queries, keys, and values, and thus poor translations.
网络从随机权重开始,这些权重会产生无用的查询、键和值,从而产生较差的翻译。
But each translation error sends a correction signal backward through the network that slightly alters the weights that produced it.
但每个翻译错误都会通过网络向后发送一个校正信号,稍微改变产生它的权重。
Through trillions of these adjustments, the network eventually generates useful vectors that yield correct translations, even when it processes sentences it has never seen before.
通过数万亿次的调整,网络最终会生成有用的向量,从而产生正确的翻译,即使它处理以前从未见过的句子。
Attention turned out to be the right mathematical operation for linking words and building context — the fundamentals of translation.
事实证明,注意力是连接单词和构建上下文的正确数学运算——这是翻译的基础。
And when you can translate blocks of text of unlimited size, it seems you can do anything.
当您可以翻译无限大小的文本块时,似乎您可以做任何事情。
A neural network that has learned enough about language to translate sentences from English into French can also complete sentences in either language.
一个对语言有足够了解的神经网络可以将英语句子翻译成法语,也可以用任何一种语言完成句子。
Predicting the next word of a translation is, in other words, a subtask of the more general task of “predicting the next word,” period.
换句话说,预测翻译的下一个单词是“预测下一个单词”这一更一般任务的子任务。
And that’s what large language models do.
这就是大型语言模型的作用。
They’re trained on the contents of the entire internet, learning which words should attend to which other words in all sorts of contexts.
他们接受了整个互联网内容的培训,学习在各种上下文中哪些单词应该关注哪些其他单词。
They process and reprocess the whole dataset and try trillions of times to predict the next word in whatever part of the web they happen to be in at any point during training.
他们处理并重新处理整个数据集,并尝试数万亿次来预测训练期间任何时候他们恰好位于网络任何部分的下一个单词。
The connections between neurons in these models are gradually tweaked in a way that produces patterns of attention between words that are ever more useful for predicting the next word in any context — or for producing an appropriate response to a prompt from a human.
这些模型中神经元之间的连接会逐渐调整,从而产生单词之间的注意力模式,这对于预测任何上下文中的下一个单词或对人类的提示产生适当的反应更加有用。
From the ability to translate the word “it,” we somehow got a revolution.
从翻译“it”这个词的能力来看,我们不知何故发生了一场革命。
“That’s quite a leap, isn’t it?” said Llion Jones, one of the authors of “Attention Is All You Need,” who is now the chief technology officer of Sakana AI.
“这真是一个飞跃,不是吗?” 《Attention Is All You Need》的作者之一、现任 Sakana AI 首席技术官的 Llion Jones 说道。
Jones and others suspect that predicting the next word, which is known as language modeling, is “AI-complete”: a task so difficult that solving it means you have arguably solved AI in general.
琼斯和其他人怀疑预测下一个单词(即所谓的语言建模)是“人工智能完成的”:这项任务如此困难,以至于解决它意味着你可以说已经解决了一般的人工智能问题。
The reason it may be AI-complete is that this task includes, as a subtask, virtually anything humans do in written form.
它可能是人工智能完成的原因是,作为子任务,该任务几乎包括人类以书面形式所做的任何事情。
“The internet has translations,” Jones notes.
“互联网上有翻译,”琼斯指出。
“So if I said ‘“The animal didn’t cross the street because it was too tired” in French is [blank],’ then in order to complete that sentence, the transformer needs to be able to translate into French.
“因此,如果我用法语说‘‘动物没有过马路,因为它太累了’,那么为了完成这句话,变压器需要能够翻译成法语。
If I say ‘2 + 3 is [blank],’ it needs to do arithmetic.
如果我说“2 + 3 是[空白]”,它需要进行算术运算。
If it sees a bunch of mathematical symbols in a row and wants to know what comes next, it needs to understand high-level mathematics.
如果它看到一堆连续的数学符号并想知道接下来会发生什么,那么它需要理解高级数学。
If I say ‘The president of the United States is [blank],’ it needs to know facts.
如果我说“美国总统是[空白]”,它需要了解事实。
So being able to predict the next word requires you to be able to do all these things.
因此,要能够预测下一个单词,就需要您能够完成所有这些事情。
And because it’s AI-complete, language modeling is kind of the closest definition that we have to intelligence.”
而且因为它是人工智能完整的,所以语言建模是我们对智能最接近的定义。”
The current paradigm won’t solve this [efficiency] problem.
当前的范式无法解决这个[效率]问题。
You seem to have to jump to something very, very different.
你似乎必须跳到一些非常非常不同的事情上。
It might not be apt to say that an LLM “knows” or “understands” anything — not in the way that a human does — but that’s just how we’re accustomed to talking about the abilities they display.
说法学硕士“知道”或“理解”任何东西可能不太恰当——不像人类那样——但这正是我们习惯于谈论他们所表现出的能力的方式。
Regardless, attention is the tool by which artificial neural networks access and convey meaning, association, and context, often well enough to astonish us with their fluency.
无论如何,注意力是人工神经网络获取和传达意义、关联和上下文的工具,其流畅性常常足以让我们感到惊讶。
(For tasks such as advanced mathematics, today’s frontier AI models often have more explicit formal reasoning and proof verification systems layered on top of their language modeling to check their work.)
(对于高等数学等任务,当今的前沿人工智能模型通常在其语言模型之上有更明确的形式推理和证明验证系统来检查其工作。)
But what about human intelligence?
但人类的智力又如何呢?
Might our brains employ a mechanism similar to the mathematical operation Bahdanau invented?
我们的大脑可能采用类似于巴达瑙发明的数学运算的机制吗?
After all, we, too, do something akin to “producing the best possible next word” when we speak, write, and even think.
毕竟,当我们说话、写作甚至思考时,我们也会做一些类似于“说出最好的下一个单词”的事情。
Perhaps our form of intelligence is tantamount to language modeling, too?
也许我们的智能形式也相当于语言建模?
Cognitive scientists have begun to study this question — a new version of the ancient question of how language relates to thought.
认知科学家已经开始研究这个问题——语言与思想如何关联这一古老问题的新版本。
To be sure, the success of LLMs shows how much information about the world is encoded in the statistical patterns of language alone.
可以肯定的是,法学硕士的成功表明,有多少关于世界的信息被编码在语言的统计模式中。
The question is: When we master language, does intelligence come for free?
问题是:当我们掌握语言时,智力是免费的吗?
Recent research persuades me that human thought is not purely linguistic (and most other animals’ intelligence is not linguistic at all): When we are thinking, more brain regions light up than just the specialized networks in the cerebral cortex that are associated with language.
最近的研究让我相信,人类思维并非纯粹是语言性的(大多数其他动物的智力根本不是语言性的):当我们思考时,更多的大脑区域会被点亮,而不仅仅是大脑皮层中与语言相关的专门网络。
Language is how we communicate about the world, but our thoughts seem to draw on sensory impressions, physical and social experiences, memories, and reasoning abilities that exist at least partly outside the brain’s language networks .
语言是我们交流世界的方式,但我们的思想似乎利用了至少部分存在于大脑语言网络之外的感官印象、身体和社会经验、记忆和推理能力。
So language modeling seems to be merely a powerful component of human cognition, not its equivalent or source.
因此,语言建模似乎只是人类认知的一个强大组成部分,而不是其等价物或来源。
As for how we do “it” — how I instantly understand that it’s the animal rather than the street that is tired — no one yet knows.
至于我们如何做到“它”——我如何立即明白是动物而不是街道累了——目前还没有人知道。
Jones, for his part, now thinks that attention is not all you need to truly master language modeling.
就琼斯而言,他现在认为注意力并不是真正掌握语言建模所需的全部。
After all, the brain evidently accomplishes this task far more efficiently than transformers do.
毕竟,大脑显然比变形金刚更有效地完成这项任务。
We converse fluently without having read the whole internet even once, and without burning as much energy.
我们甚至不需要阅读整个互联网就可以流利地交谈,也不会消耗太多的能量。
“The current paradigm won’t solve this [efficiency] problem,” Jones said.
“当前的模式无法解决这个[效率]问题,”琼斯说。
“You seem to have to jump to something very, very different.”
“你似乎必须跳到一些非常非常不同的事情上。”
Regardless of what our own neural mechanisms might be, it makes sense to me in hindsight that solving translation unlocked AI.
不管我们自己的神经机制是什么,事后看来,解决翻译问题解锁了人工智能,这对我来说是有意义的。
Whether you’re human or machine, the ability to translate effectively means you have understood, in some sense.
无论你是人类还是机器,有效翻译的能力意味着你在某种意义上已经理解了。
Now the machines understand so much — effectively, at least — that we hardly know what to think anymore.
现在,机器理解得如此之多——至少是有效的——以至于我们几乎不知道该想什么了。
Get highlights of the most important news delivered to your email inbox
获取发送到您的电子邮件收件箱的最重要新闻的摘要
Quanta Magazine moderates comments to facilitate an informed, substantive, civil conversation.
《Quanta》杂志对评论进行审核,以促进知情、实质性、文明的对话。
Abusive, profane, self-promotional, misleading, incoherent or off-topic comments will be rejected.
辱骂、亵渎、自我推销、误导、语无伦次或偏离主题的评论将被拒绝。
Moderators are staffed during regular business hours (New York time) and can only accept comments written in English.
版主在正常工作时间(纽约时间)有工作人员,并且只能接受英文评论。