Video Sensei.
How it worksAboutChangelog
Enter learning space
More free lessons

Free lesson, no sign-in needed: bilingual captions, highlights, outline and key ideas are ready. Translations and explanations are in Simplified Chinese for now.

Large Language Models explained brieflyExample
Captions receivedReading ready · 60 sentencesOutline readyTranslations and highlights load as you read. Completed work is kept.
01 / READ

Transcript

Imagine you happen across a short movie script that describes a scene between a person and their AI assistant.

想象一下你偶然发现一个简短的电影剧本,描述一个人和他们的AI助手之间的场景。

The script has what the person asks the AI, but the AI's response has been torn off.

剧本中有这个人向AI提出的请求,但AI的回应部分被撕掉了。

Suppose you also have this powerful magical machine that can take any text and provide a sensible prediction of what word comes next.

假设你还有这台强大的魔法机器,可以接受任何文本并提供下一个单词的合理预测。

You could then finish the script by feeding in what you have to the machine, seeing what it would predict to start the AI's answer, and then repeating this over and over with a growing script completing the dialogue.

然后你可以通过将你所拥有的输入机器来完成剧本,查看它预测的AI答案的开始,然后一遍又一遍地重复这个过程,逐步完成对话。

When you interact with a chatbot, this is exactly what's happening.

当你与聊天机器人交互时,这正是所发生的事情。

A large language model is a sophisticated mathematical function that predicts what word comes next for any piece of text.

大型语言模型是一个复杂的数学函数,用于预测任何文本的下一个单词。

Instead of predicting one word with certainty, though, what it does is assign a probability to all possible next words.

然而,它不是以确定性的方式预测一个单词,而是为所有可能的下一个单词分配一个概率。

To build a chatbot, what you do is lay out some text that describes an interaction between a user and a hypothetical AI assistant.

要构建一个聊天机器人,你所做的就是铺陈一段描述用户与假想AI助手之间互动的文本。

You add on whatever the user types in as the first part of that interaction, and then you have the model repeatedly predict the next word that such a hypothetical AI assistant would say in response, and that's what's presented to the user.

你将用户输入的内容添加为该互动的第一部分,然后让模型反复预测假想AI助手在回应中会说的下一个单词,这就是呈现给用户的内容。

In doing this, the output tends to look a lot more natural if you allow it to select less likely words along the way at random.

在此过程中,如果允许它随机选择不太可能的单词,输出往往看起来更自然。

So, what this means is even though the model itself is deterministic, a given prompt typically gives a different answer each time it's run.

所以,这意味着尽管模型本身是确定性的,但给定的提示通常会在每次运行时给出不同的答案。

Models learn how to make these predictions by processing an enormous amount of text, typically pulled from the internet.

模型通过处理大量文本来学习如何进行这些预测,这些文本通常来自互联网。

For a standard human to read the amount of text that was used to train GPT-3, for example, if they read non-stop 24/7, it would take over 2,600 years.

例如,对于一个普通人来说,阅读用于训练GPT-3的文本量,如果他们不停地阅读,24小时不间断,所需时间将超过2600年。

Larger models since then train on much, much more.

自那时以来,更大的模型训练的文本量是更大的。

You can think of training a little bit like tuning the dials on a big machine.

你可以把训练想象成调节大机器上的旋钮。

The way that a language model behaves is entirely determined by these many different continuous values, usually called parameters or weights.

语言模型的行为完全由这些不同的连续值决定,通常称为参数或权重。

Changing those parameters will change the probabilities that the model gives for the next word on a given input.

改变这些参数将改变模型在给定输入下为下一个单词提供的概率。

What puts the large in large language model is how they can have hundreds of billions of these parameters.

大型语言模型的“大”在于它们可以拥有数百亿个这样的参数。

No human ever deliberately sets those parameters.

没有人故意设置这些参数。

Instead, they begin at random, meaning the model just outputs gibberish, but they're repeatedly refined based on many example pieces of text.

相反,它们是随机开始的,这意味着模型一开始输出的只是乱码,但它们会根据许多示例文本反复进行精炼。

One of these training examples could be just a handful of words, or it could be thousands, but in either case, the way this works is to pass in all but the last word from that example into the model and compare the prediction that it makes with the true last word from the example.

这些训练示例之一可以只是零星的几个单词,或者可以是成千上万的单词,但无论哪种情况,其工作的方式是将该示例中的所有单词(除了最后一个)传入模型,并将其生成的预测与示例中的真实最后一个单词进行比较。

An algorithm called backpropagation is used to tweak all of the parameters in such a way that it makes the model a little more likely to choose the true last word and a little less likely to choose all the others.

一种叫做反向传播的算法用于调整所有参数,使得模型更可能选择真实的最后一个单词,而不太可能选择其他所有单词。

When you do this for many, many trillions of examples, not only does the model start to give more accurate predictions on the training data, but it also starts to make more reasonable predictions on text that it's never seen before.

当你对成千上万的万亿示例执行这个操作时,模型不仅开始对训练数据给出更准确的预测,而且还开始对从未见过的文本进行更合理的预测。

Given the huge number of parameters and the enormous amount of training data, the scale of computation involved in training a large language model is mind-boggling.

考虑到参数的巨大数量和庞大的训练数据,训练大型语言模型所涉及的计算规模令人震惊。

To illustrate, imagine that you could perform 1 billion additions and multiplications every single second.

举个例子,想象一下你每秒可以执行10亿次加法和乘法。

How long do you think that it would take for you to do all of the operations involved in training the largest language models?

你认为训练最大的语言模型需要多长时间来完成所有操作?

Do you think it would take a year?

你认为这需要一年吗?

Maybe something like 10,000 years?

也许需要大约10,000年?

The answer is actually much more than that.

答案实际上远远超过这个。

It's well over 100 million years.

这超出了1亿年。

This is only part of the story, though.

不过,这只是故事的一部分。

This whole process is called pre-training.

这个整个过程称为预训练。

The goal of autocompleting a random passage of text from the internet is very different from the goal of being a good AI assistant.

从互联网自动完成随机文本段落的目标与成为一个优秀的人工智能助手的目标是非常不同的。

To address this, chatbots undergo another type of training, just as important, called reinforcement learning with human feedback.

为了应对这一点,聊天机器人接受了另一种类型的训练,这同样重要,称为带有人类反馈的强化学习。

Workers flag unhelpful or problematic predictions, and their corrections further change the model's parameters, making them more likely to give predictions that users prefer.

工作人员会标记不有帮助或有问题的预测,他们的更正进一步改变模型的参数,使其更可能给出用户喜欢的预测。

Looking back at the pre-training though, this staggering amount of computation is only made possible by using special computer chips that are optimized for running many, many operations in parallel, known as GPUs.

回顾预训练,这惊人的计算量仅通过使用专门优化以并行运行许多操作的计算机芯片(称为GPU)成为可能。

However, not all language models can be easily parallelized.

然而,并非所有语言模型都能轻松并行化。

Prior to 2017, most language models would process text one word at a time.

在2017年之前,大多数语言模型是一次处理一个单词的。

But then, a team of researchers at Google introduced a new model known as the Transformer.

但随后,谷歌的一组研究人员介绍了一种新的模型,称为Transformer。

Transformers don't read text from the start to the finish.

Transformers不会从头到尾读取文本。

They soak it all in at once, in parallel.

他们一下子全部吸收,都是并行进行的。

The very first step a transformer, and most other language models for that matter, is to associate each word with a long list of numbers.

变压器和大多数其他语言模型的第一步是将每个单词与一个长长的数字列表关联起来。

The reason for this is that the training process only works with continuous values, so you have to somehow encode language using numbers.

这样做的原因是训练过程只处理连续值,因此必须通过某种方式使用数字对语言进行编码。

And each of these list of numbers may somehow encode the meaning of the corresponding word.

这些数字列表中的每一个可能以某种方式编码对应单词的含义。

What makes Transformers unique is their reliance on a special operation known as attention.

变压器独特之处在于它们依赖于一种称为注意力的特殊操作。

This operation gives all of these lists of numbers a chance to talk to one another, and refine the meanings that they encode based on the context around, all done in parallel.

这个操作使得所有这些数字列表都有机会相互交流,并根据周围的上下文精炼它们编码的含义,全部都是并行进行的。

For example, the numbers encoding the word bank might be changed based on the context surrounding it to somehow encode the more specific notion of a river bank.

例如,编码单词 bank 的数字可能基于其周围的上下文而变化,以某种方式编码更具体的河岸概念。

Transformers typically also include a second type of operation known as a feedforward neural network, and this gives the model extra capacity to store more patterns about language learned during training.

变压器通常还包括第二种类型的操作,称为前馈神经网络,这为模型提供了额外的能力,以存储训练过程中学习到的更多语言模式。

All of this data repeatedly flows through many different iterations of these two fundamental operations.

所有这些数据在这两种基本操作的多次迭代中反复流动。

And as it does so, the hope is that each list of numbers is enriched to encode whatever information might be needed to make an accurate prediction of what word follows in the passage.

随着这一过程的进行,希望每个数字列表都得到丰富,以编码预测在文本中接下来应该出现的单词所需的信息。

At the end, one final function is performed on the last vector in this sequence, which now has had a chance to be influenced by all the other context from the input as well as everything the model learned during training to produce a prediction of the next word.

最后,在这个序列中的最后一个向量上执行一个最终功能,现在这个向量有机会受到输入中所有其他上下文以及模型在训练期间学习到的所有内容的影响,以生成对下一个单词的预测。

Again, the model's prediction looks like a probability for every possible next word.

同样,模型的预测看起来像是每个可能的下一个单词的概率。

Although researchers design the framework for how each of these steps work, it's important to understand that the specific behavior is an emergent phenomenon based on how those hundreds of billions of parameters are tuned during training.

尽管研究人员设计了每个步骤的框架,但重要的是要理解,特定行为是基于数百亿个参数在训练期间如何调整而形成的涌现现象。

This makes it incredibly challenging to determine why the model makes the exact predictions that it does.

这使得确定模型为何做出确切预测变得极具挑战性。

What you can see is that when you use large language model predictions to auto complete a prompt, the words that it generates are uncannily fluent, fascinating, and even useful.

你可以看到,当使用大型语言模型的预测来自动完成一个提示时,它生成的词汇无比流畅、迷人,甚至有用。

If you're a new viewer and you're curious about more details on how transformers and attention work, boy do I have some material for you.

如果你是一个新观众,对变压器和注意力如何工作感到好奇,那么我有一些相关的材料给你。

One option is to jump into a series I made about deep learning where we visualize and motivate the details of attention and all the other steps in a transformer.

一个选择是跳入我制作的关于深度学习的系列,在那里我们可视化和阐述注意力以及变压器中的所有其他步骤的细节。

But also, on my second channel, I just posted a talk that I gave a couple months ago about this topic for the company TNG in Munich.

此外,在我的第二个频道上,我最近发布了一场我在几个月前为慕尼黑公司TNG所做的关于这个主题的讲座。

Sometimes I actually prefer the content that I make as a casual talk rather than a produced video, but I leave it up to you which one of these feels like the better follow on.

有时我其实更喜欢我作为随意讲座而非制作的视频所制作的内容,但我留给你选择哪一个感觉更适合后续。

Mhm.

嗯。

Click a word · drag to select a phrase1 / 60
02 / UNDERSTAND

A closer look

IN THIS CONTEXT ·0:01

Imagine you happen across a short movie script that describes a scene between a person and their AI assistant.

想象一下你偶然发现一个简短的电影剧本,描述一个人和他们的AI助手之间的场景。

Write your understanding, then save it.

Select a whole sentence or an expression to get grammar and usage analysis.