Chapter 9. Attention第九章 注意力
A manga for grown-ups. Read it in English or Chinese.给大人看的漫画。可以用中文或英文读。































































































This chapter left a lot to the pictures, so the stone table could stay quiet. Here is the idea in words.
On page 4 Grandpa says "Put it by her." Xiaoyu is holding two things, so "it" could be either. The word "glass" later in his sentence tells her it is the tea, and only the whole room tells her who "her" is. The meaning of one word depends on other words, sometimes far away from it. Every language model has to solve this, all the time.
On page 6 Haoran tries "The cup didn't fit in the box because it was too big", then changes "big" to "small". One word at the end changes what "it" means. Older networks read a sentence one word at a time and carried what they had read along with them, like a person who keeps a running note in their head. In a long sentence the beginning faded, the way Grandpa loses the top of a comic page by the bottom. Better designs, such as the LSTM, held on longer, but they still had to read in order.
On page 7 Haoran's program does something different. Every word looks at every other word, all at once, and asks how much each one matters to it. "It" looks hard at "cup", a little at "box", hardly at all at "the". Haoran's numbers are made up for the story, but real models work this way. Each word ends up as a mix of the words it paid attention to. The shares always add up to one, so a word cannot give more to "cup" without giving less to something else. Nobody tells the model where to look. It learns that while practising its one job, guessing words.
On page 10 Haoran says his program reads every word at the same time. That sounds like showing off, as Grandpa says, but it is the reason transformers took over. A network that reads in order has to wait for word one before it can start on word two. A transformer works on all the words together, which is the kind of sum a computer's graphics chips are built to do very fast. So it can practise on a mountain of books in days instead of years.
On page 14 Haoran says real models have many heads. Each head is a separate set of attention, with its own idea of what matters. One may learn to match "it" to the thing it stands for, while another watches the word just before. A large model stacks dozens of layers, each with many heads, so the words look at each other again and again and understand a little more each time.
Attention began in translation. In 2014 Dzmitry Bahdanau, Kyunghyun Cho and Yoshua Bengio let a translating network, as it wrote each word, look back over the whole sentence it was translating and pick out the words that mattered most. The paper was published in 2015. Three years later the trick had become the whole machine.
In 2017 a team at Google published a paper with that title. They dropped the old read-in-order network entirely and built one from attention alone, which they called the transformer. Their larger model trained in three and a half days on eight graphics chips and beat the best translation systems of the time. Almost every large language model since has been a transformer.
Haoran's little program looks both ways, so "it" can see "big" at the end of the sentence. A model called BERT, from Google in 2018, worked like that, by filling in hidden words using the words on both sides. The chat assistants that write messages, like the one in the last chapter, only look back. Each word can see itself and the words before it, because when the model is choosing the next word, the words after it have not been written yet.
The next step was to give a transformer an enormous pile of ordinary writing and let it practise guessing the next word, with no one marking the answers, because the text marks itself. GPT-2 in 2019 had one and a half billion numbers to tune. GPT-3 in 2020 had 175 billion. Researchers found the guessing gets better smoothly and predictably as models, data and computing grow together, and in 2022 a team at DeepMind showed that many big models had been trained on too little text for their size.
The word "attention" makes it sound as if the model is paying attention the way a person does. It isn't. It is a sum, a weighted average with weights it has learned. Nobody inside is looking. The weights also don't fully explain why a model said what it said. They show where information was mixed from, in one layer and one head, which is only part of the story. When Grandpa says Xiaoyu's name right, that is a person paying attention, and it is a different thing.
Bridge City, Xiaoyu, Grandpa Chen, Haoran, Lili, Uncle Wu, Auntie Zhang and Mr Chen are made up. So are Haoran's reading program and its percentages, the river boat, the canal town and the 1975 game. The story is set a few years from now. Grandpa's memory is drawn from no one in particular, and the story makes no medical claim. People whose memory comes and goes really do have clearer days and harder ones, and many families find the evenings harder. Nobody can say when a clear day will come, which is why it is worth being there.
Yingying Fu created this manga. She chose the story and its people, directed every page, and edited every word and picture. The words were drafted with Claude, an AI by Anthropic. The pictures are made with AI image generation, painted panel by panel from her direction and checked and corrected by hand.
这一章不少话交给了画面,好让石桌边那几页安安静静的。这里再用文字讲一遍。
第4页,外公说“给她端过去”。小雨手里端着两样东西,说哪样都通。后面那句“头一杯”,才让她知道是茶;至于“她”是谁,得把整间屋子看一圈才明白。一个词是什么意思,要看它周围的词,有时那个词还离得挺远。语言模型每时每刻都要解这道题。
第6页,浩然先打了“杯子放不进盒子,因为它太大了”,又把“大”改成“小”。只改了句末一个字,“它”指的就换了。早先的网络一次只读一个字,边读边把读过的内容带着往下走,好比人一边读一边在心里记账。句子一长,开头就淡了,跟外公看小人书一样,看到下面,忘了上面。后来出现了更好的设计,比如LSTM(长短期记忆网络),记得更久,但仍然只能按顺序一个字一个字地读。
第7页,浩然的程序换了个思路。每个字同时看向其他所有的字,掂量每个字对自己有多重要。“它”重点看“杯子”,稍微看看“盒子”,别的字几乎不看。浩然那几个百分比是编的,但真实的模型确实这样工作。每个字最后都变成它所关注的那些字按比例混合的结果。分出去的注意力加起来总是等于一,所以给“杯子”多一点,别处就得少一点。该看哪里,没有人教。模型只练一件事,就是猜字,看哪里是它在练习中自己学会的。
第10页,浩然说他的程序是所有字一起读的。外公说他显摆,可变换器能后来居上,靠的正是这一点。按顺序读的网络,必须等第一个字处理完,才能处理第二个。变换器把所有的字放在一起算,这种计算恰好是显卡最擅长的。所以它几天就能练完堆成山的书,不必花上好几年。
第14页,浩然说真正的模型有很多个“头”。每个头是一套独立的注意力,各有各的侧重。一个头也许学会了把“它”和它指代的东西对上,另一个头则专门盯着前一个字。大模型叠了几十层,每层又有很多个头,字与字之间一遍遍地互相看,每看一遍,理解就深一层。
注意力最早用在机器翻译上。2014年,巴赫达瑙、赵庆贤和本吉奥让翻译网络每译出一个词,都回头把原句整个看一遍,挑出最相关的几个词。论文在2015年正式发表。不到三年,这个小技巧就撑起了整台机器。
2017年,谷歌的一个团队发表了一篇论文,题目就是这句话。他们彻底抛开按顺序读的老式网络,只用注意力搭了一种新网络,取名“变换器”。其中较大的那个模型在8块显卡上训练了三天半,就超过了当时最好的翻译系统。此后,几乎所有的大语言模型都是变换器。
浩然的小程序两头都看,所以“它”能看到句末的“大”。谷歌2018年推出的BERT就是这样,它练的是填空,遮住几个字,让它看着两边的字去猜。会写消息的聊天助手,比如上一章那个,只看前文。每个字只能看到自己和前面的字,因为模型挑下一个字的时候,后面的字还没写出来。
下一步,是把海量的普通文字交给变换器,让它练习猜下一个字。不需要人来批改,因为答案就在文字本身里。2019年的GPT-2有15亿个参数要调,2020年的GPT-3有1750亿个。研究者发现,模型、数据和算力一起增长,猜字的本事就会平稳提高,提高多少事先也算得出来。2022年,DeepMind的一个团队又指出,许多大模型就其规模而言,训练用的文字太少了。
“注意力”这个词,听起来好像模型像人一样在用心看。其实不是。它只是一道算术,一个用学来的权重求的加权平均,里面没有谁在看。这些权重也不能完全解释模型为什么那样回答。它们只说明在某一层、某一个头里,信息是从哪些字混合过来的,这只是原因的一部分。外公把小雨的名字叫对,那才是一个人在用心,是另一回事。
桥城、小雨、陈外公、浩然、丽丽、吴爷爷、张阿姨和浩然的爸爸,都是虚构的。浩然的读句子程序和那几个百分比、那条船、那个古镇,还有1975年那盘棋,也都是编的。故事发生在几年以后。外公的记性不是照着哪个真人写的,故事也不做任何医学判断。记性时好时坏的人,确实有清醒的日子,也有糊涂的日子,许多家庭也觉得傍晚更难熬。清醒的日子哪天来,谁也说不准,所以能陪,就多陪陪。
这本漫画由 Yingying Fu 创作。故事和人物由她决定,每一页由她导演,每一句话、每一幅画由她修改。文字是和 Anthropic 的人工智能 Claude 一起起草的。画面由人工智能生成,按她的要求一格一格地画,再逐张检查、修正。
© 2026 Yingying Fu. All rights reserved.© 2026 傅颖盈。保留所有权利。