[BidClub_]
Machine Learning Street Talk · · 99 分钟

探索统一文本到文本 Transformer 的迁移学习边界

Yi Ma

YouTube
TL;DR
  • T5 的实践意义,在于把众多 NLP 任务统一到一个“文本输入、文本输出”的接口之下。 翻译、摘要、分类、推理、回归和问答可以共享同一套损失函数与解码流程,从而简化下游迁移学习。但讨论中的保留意见至关重要:这条指令可能只是模型学到的任务标识符——“三明治很好吃”或许和“翻译成法语”一样有效——而不代表模型真正理解了请求。

  • 最不起眼的消融实验给出了最强结果:增加计算量和参数量,胜过巧妙的架构微调。 训练步数增加到4倍后,GLUE 基线从83.28升至85.33;通过扩大前馈层将模型规模翻倍、训练时间延长1倍,又增加了约3个点。只有“与规模结合”后才出现SOTA,这使计算资源、硬件和数据成为关键投入。

  • 数据经济仍是非线性的:质量和领域匹配有帮助,但多样性可以避免有害重复。 Google 将6.1 TB的 Common Crawl 压缩成745 GB的 C4 语料;在被引用的比较中,一个约35 GB的高质量 WebText 子集得分显著高于过滤后的 C4。领域内预训练提升了相关任务表现,但语料过窄、样本重复过多时,反而会造成伤害。

  • T5 的架构结论偏向原始 Transformer 编码器-解码器,而不是另造一种拓扑。 在计算成本相近的情况下,它的参数量约为仅编码器 BERT 或仅解码器 GPT 式模型的2倍;共享编码器与解码器参数后,参数量可减半,性能却没有明显损失。尚未解决的问题是:有用的“子程序”是否真的被共享,还是注意力头在悄悄按任务分区。

  • 大多数去噪目标的表现相近,因此优化目标转向更便宜的输出。 只重建被掩码的片段即可取得相近表现,同时缩短目标序列、降低训练成本;即便奇怪的目标“for inviting / last”,也能补回“Thank you … me to your party … week”中的两个空缺。不过 Connor 的反应值得重视:从约83升至84.4,显然不能直接视为无关紧要。

  • 模型压缩带来部署机会,也留下一个尚未解决的训练悖论。 DistilBERT 被描述为体积缩小40%、速度提升60%,同时保留教师模型约97%的性能;但同一个小网络直接训练时却无法达到这一水平。过参数化似乎让优化先行成功,之后才能压缩知识,“这是整件事中更诡异的方面之一”。

  • 基准赛道的领先,无法干净地区分算法优势与资源优势。 即使是严谨研究,语料、超参数、训练时间和硬件也各不相同;受限竞赛回答的是部署效率问题,而不设上限的竞赛则暴露出“只有在规模上来后才会出现的效应”。小组给实践者的规则是,把不同论文中反复出现的技术“结晶出来”,不要轻信任何单一排行榜结论。

  • C4 更偏好多样化的规模,而不是反复挖掘的纯度。 Google 的6.1 TB Common Crawl 数据清洗后变成745 GB,而在被引用的比较中,一个约35 GB的高质量 WebText 子集得分显著高于过滤后的 C4。私信或许能提供更好的文本数据,但大型 Transformer 可能会记住训练数据,并在其间做插值。

  • 领域暴露和原始规模主导迁移学习配方。 Wikipedia 预训练帮助了 SQuAD 式问答,却可能损害 CoLA 式可接受性判断,因为百科文本中几乎没有不可接受的句子。无监督预训练最终仍胜出,但小组认为,其大部分优势来自更多数据和更长训练时间。

  • 开放预训练模型让复杂语言能力民主化,但可靠性仍是另一个产品问题。 可下载的 T5 类系统让用户无需购买云端认知服务即可使用翻译和问答能力,但模型储存的事实仍可能来自记忆与插值,而非有依据的理解。对于生产级聊天机器人,小组更偏好边界明确的动作、意图识别和一致性测试,而不是令人印象深刻却难以测试的无限制文本生成。

摘要 · 为研究而整理的核心内容

1. 预训练让语言模型成为隐式知识库

  • Tim 的历史框架始于脆弱、手工编写的知识图谱:过去要回答“我们在哪一年赢得了第二次世界大战?”,需要先建立明确的本体。预训练 Transformer 则会“积累关于世界的知识”,让模型在 Wikipedia 等来源上训练后,无需工程师手动编码每一条关系,也能回答事实性问题。

  • 这条路径始于 Word2Vec 的2013年 skip-gram 模型:全连接网络、负采样,以及一个对比式问题——这个词是否属于那个词的上下文?它生成了有用的嵌入空间几何结构,但词仍是原子单位,无法表达语言中长距离、多尺度的依赖关系。

  • ELMo 的双向 LSTM 开始捕捉序列上下文;Jeremy Howard 和 Sebastian Ruder 的 ULMFiT 则明确提出迁移学习:先预训练一个下一个词预测模型,移除其最后几层,再接入情感分析或其他下游任务的分类器。预训练网络自带已经学到的概念,等于扩大了可用训练集。

  • Vaswani 在2017年的《Attention Is All You Need》中引入了一种不同的架构;2018年11月,BERT 随之出现,具备双向上下文、掩码语言模型、下一句预测,以及一个接近3.4亿参数的大型版本。GPT-2 约有15亿参数,使用40 GB的精选语料;约1年后,Microsoft 的后续模型被引用为约170-180亿参数,讨论中后来将其称为 Turing-NLG。

2. T5 让所有语言任务都变成文本续写

  • 这篇论文的核心工作是比较,而不只是提出架构。在 BERT 变体“海啸般涌现”——RoBERTa、ALBERT、DistilBERT、SpanBERT 等——之后,论文在同一套迁移学习流程中,分别隔离了目标函数、架构、数据集规模与构成、训练时长、多任务训练计划和模型规模等变量。

  • T5 将任务本身表达为文本:“translate from English to French:”置于源句之前;摘要、自然语言推理、分类、回归和问答也使用同一套损失函数与解码流程。这一框架无需针对不同任务类型更换架构,也能匹配任务专用架构;最终,在与规模结合后取得了SOTA结果。

  • Connor 从开发者角度的解读是,标准化的输入输出契约让迁移学习更容易。小组对“现在一切都是文本了”的兴奋,伴随着 Yi 对“魔法究竟在哪里”的不确定:目标函数、语料、架构,还是规模?统一训练的多任务版本表现出人意料地好,但最佳结果仍来自分别进行的下游微调。

3. 原始编码器-解码器在架构竞赛中胜出

  • 小组拆解了 Transformer 的3种形态。BERT 的编码器将输入序列映射为等长输出,适合分类或片段预测;GPT 式仅解码器模型使用因果掩码,以自回归方式生成;编码器-解码器则先表示源序列,再生成可能长度不同的输出,这正是翻译所需要的形式。

  • T5 发现,原始编码器-解码器最适合其文本到文本的设定。虽然参数量是仅编码器或仅解码器替代方案的2倍,但计算成本相近;在编码器与解码器之间共享参数后,总参数量减半,性能却没有明显下降。

  • Yi 推测,层可能实现某些共同的、类似程序的子程序——例如特征聚合或排序——并可以被反复调用。更广泛的直觉是,一个更大的共享模块,可能比两个更小、彼此隔离的权重集合更有用。

  • Tim 觉得反复应用同一变换很奇怪,并追问模型为什么不能直接跳过这一步。尚未解决的实证问题是:表示是否真的被共享,还是模型把不同任务分配给不同的注意力头。

4. 注意力移除了递归,但仍需要一把位置标尺

  • 递归网络必须让早期出现的主语穿过其间的每个词,才能解析之后“his friend”这类短语的指代关系。Transformer 则可以在一次注意力步骤中直接连接任意两个词,把信息路由到正确的序列位置,并在没有漫长递归路径的情况下建模长距离、多尺度关系。

  • 这种灵活性并非没有代价。Transformer 的输入长度有上限,而且“极其吃内存”;没有位置信息时,注意力知道内容,却不知道内容来自哪里。CNN 虽然易于并行化,但需要多层局部运算来传递远距离信息,因此长距离依赖可能逐步损失。

  • Tim 将正弦位置编码称为“给模型一把标尺”。快速波编码局部邻域,慢速波编码更宽的距离和尺度。3D 面部扫描仪的类比让这一点更直观:以逐渐精细的尺度投射黑白图案,让每个像素获得独特的多尺度位置编码。

  • Tim 的质疑集中在对称性:绝对位置是否可能意外地把某种语言模式绑定到输入开头?小组成员认为,重复波形仍能编码相对模式,例如相距2个位置的词,或更大尺度上的从句。对方还提到,T5 似乎用一种可学习的标量式位置方案取代了固定的正弦波。

5. 蒸馏暴露出优化悖论

  • DistilBERT 给出了部署端数据:学生模型体积缩小40%、推理速度提升60%,同时保留教师模型约97%的性能。训练大模型再进行压缩,早已是行业惯例,因为部署完整 Transformer 的成本很高。

  • 诡异之处在于,在相同数据上直接训练更小的架构,无法复现蒸馏模型的性能。过参数化似乎让优化过程“乐于接受训练数据”;大模型学会有用行为后,这些行为又以某种方式被转移到一个原本无法独立发现它们的容量中。

  • 彩票假设的类比进一步凸显了这一疑问。一个庞大网络包含组合数量极多的潜在子网络,因此其中某个子网络一开始就带有有用归纳偏置是合理的;随后随机梯度下降就像“从一块黏土上不断削去多余部分”。方法确实有效,但小组称其为“一种糟糕透顶的做法”。

  • Connor 持不同意见,认为蒸馏的收益可能更多来自标签平滑,而不是字面意义上的特征迁移:教师模型的软概率传递了类别关系和嵌入距离。小组提出了基于对比距离的蒸馏、跨架构迁移等开放问题。在 T5 自己的规模消融中,新增参数进入了前馈模块,而不是注意力头。

6. 便宜的去噪目标比奇特的破坏方式更重要

  • T5 发现,大多数重建受损文本的目标函数表现相近。因此,它的实际建议是从计算角度出发:选择目标序列更短的方案,只重建缺失内容,而不是根据原始输入重新生成所有未被掩码的词。

  • 一个引人注目的例子是:输入相当于“Thank you [gap] me to your party [gap] week”,目标只包含“for inviting”和“last”。尽管这句话有许多语法上合理的补全方式,模型仍能把多个输出片段对应到恰当的空缺位置。

  • 比较覆盖掩码词、连续片段、随机词替换和打乱文本;打乱文本的表现很差。讨论的重点是片段掩码相对于 BERT 式词级掩码的关键区别。Connor 认为,在 GLUE 式任务中从约83升到84.4,即使小于规模扩张带来的收益,也依然有意义。

  • ELECTRA 引发了真正的分歧。它的小型生成器填入被破坏的词,再由更大的判别器判断替换内容是真还是假;小组成员担心,这种二元目标所携带的信息少于语言生成。另一种观点是,标准目标错误地坚持语料中的唯一词,而实际可能有20种替代表达都合理;判别任务则可以容纳多种可能的补全。

7. 基准胜利无法干净地区分算法与资源

  • 小组成员的直白立场是:“我基本不相信任何论文里的任何数字。”一种新目标函数往往伴随着更多计算、更换语料,或某个未被明说的训练技巧。即使做了大规模消融,也很难让架构、优化器、超参数、数据和计算真正可比。

  • 仔细标准化后的复现同样可能失败。小组回忆了《All GANs Are Created Equal》的一次比较:其网格实验忽略了原作者的警告,即该方法在一个优化器上有效,在另一个上却无效。统一评估有时恰恰因为算法需要不同运行条件,反而变得不公平。

  • Tim 保留了 François Chollet 的反对意见:Kaggle 式优化可能产生针对基准量身定制的解,而不是解决真实问题。棋类系统的任务表现也不同于人类智能:人类的成就包含动态学习这项技能,而不只是执行一种固定能力。

  • 但如果必须二选一,小组成员仍偏好开放竞赛:“不管你必须做什么,都去做”,至少能揭示可达到的最高分。DAWNBench 这类受计算上限约束的竞赛,则回答另一个同样有用的部署问题。一位同事的反驳是,10亿参数模型和50 TB数据集可能揭示“只有在规模上来后才会出现的效应”。

8. C4 更偏好多样化规模,而非反复挖掘的纯度

  • Google 从 Common Crawl 构建了 Colossal Clean Crawled Corpus:约6.1 TB数据经过启发式清洗后变成约745 GB。小组特别提到删除 JavaScript、保留以句号结尾的句子,以及对内容去重;被丢弃的数据量说明原始互联网文本有多嘈杂。

  • 领域过滤数据提升了部分下游任务表现,但缩窄领域也会缩小语料规模。当预训练把一个小型无标签数据集重复过多次后,性能开始下降。这一结果推动 C4 采用广泛多样性,以服务通用语言理解,而不是对一个所谓更纯净的细分来源无休止地重复训练。

  • 一个约35 GB的高质量 WebText 子集,在被引用的比较中仍取得了显著高于过滤后 C4 的得分。它被描述为经过过滤的高质量新闻材料,看起来由 Reddit 链接、且至少获得3次赞的文章组成。这再次激活了质量与规模之间的张力,也引出了隐私担忧:私信或许能提供异常自然的对话文本,而大型 Transformer 可能是在记忆数据,而非抽象出数据背后的规律。

9. 领域暴露与原始规模主导迁移学习配方

  • 领域内暴露解释了通用预训练无法带来的部分收益。Wikipedia 预训练帮助了 SQuAD 式问答,却可能损害 CoLA 式可接受性判断,因为百科文本中几乎没有不可接受的句子。正如 Tim 所说,词义也会随领域变化:“default”在金融语境中尤其带有负面含义。

  • 无监督预训练最终仍胜出,但小组认为,其很大一部分优势来自更多数据和更长训练时间。监督式多任务预训练被描述为只比无监督结果落后约3个 GLUE 点;在分别微调每项任务之前,先对多个有标签任务进行联合训练,也能显著提升表现。

  • 最清晰的规模数据来自主消融实验:GLUE 基线83.28,在训练步数增加到4倍后升至85.33。通过前馈层将参数量翻倍、训练步数增加到2倍,带来了约3个点的提升,超过了大多数去噪目标变体的影响。

  • 多任务规模扩张也制造了新的失衡。统一采样任务会让部分任务训练不足、另一些训练过度,因此 T5 引入温度参数,根据任务贡献调整权重;无监督目标也可能压过监督任务。Connor 将这一问题与灾难性遗忘、持续学习、神经调制和稀疏条件路由联系起来,但这些机制仍停留在推测层面。

10. 没有落地依据的记忆仍是智能鸿沟的核心

  • 小组成员怀疑,大型 Transformer“只是记住了整个训练语料”,再对熟悉模式的混合结果做插值。因此,闭卷式事实回答可能更像一个存储知识库,而不是有依据的理解。GPT-2 在语言模型预训练后能够回答问题之所以令人印象深刻,正是因为答案很可能曾经出现在训练数据的某处。

  • 在这一框架下,落地依据意味着通过具身经验理解“拐角处有一辆车”意味着什么:车是物体,会占据道路,而房屋可能位于道路之间并遮住车辆。文字冒险游戏提供行动和后果,但扩展这类环境往往需要程序化生成器;其重复性语法会让模型利用模板,而不是学习世界。

  • Connor 反驳说,足够多的多模态经验——通过语言进行 Street View 导航、PointNav、RoboTHOR、“Read to Fight Monsters”、音频或游戏反馈——或许能让网络建立与人类相同的连接。人类同样只能通过输入信号接触世界;如果机器拥有足够多的模态,也许可以形成相当的连接,并且比人类更完整地记住这些连接。

  • Tim 回到了深度网络“不会外推,只会插值”的结果:一个在−5到5之间被训练来复现 f(x)=x 的网络,在多种激活函数下都无法处理范围之外的输入。小组成员追问,究竟是哪种先验允许一条直线永远延伸,而不是回归均值;生成模型和解耦编辑提供了更丰富、但仍未解决的泛化思路。

11. 开放模型让 NLP 民主化,但生产环境仍需要约束

  • Tim 的实践结论是,可下载的预训练模型已经让过去局限于 Microsoft 或 Google 云服务的能力实现了民主化。开发者可以收集一批深度学习论文,先进行自监督预训练,再完成标注,随后微调出复杂的翻译或问答系统,无需自行收集互联网规模的监督数据。

  • 语言能力可能比视觉能力更快实现民主化,因为高质量文本语料只需占用几十 GB;相比之下,被引用的 FaceNet 系统使用了约2600万张人脸,这是一个极具价值、却无法从 Google 直接下载的数据集。小组成员提出的另一种解释是表征压缩:词语能够高效编码声音与意义,而一种同样紧凑且可重建的自然图像表征仍未被发现。

  • 小组拒绝把自由生成等同于有用的聊天机器人。大多数生产级机器人都是由静态规则加意图识别构成的接口;对于“你感觉怎么样?”,GPT 的无限制回答几乎没有运营价值,也难以测试。自然语言的多样性还会使系统难以快速适应用户描述同一问题的不同方式。

  • 逻辑一致性测试或许能帮助治理这类系统:如果图像问答说有3只靴子,那么“有靴子吗?”就应得到肯定回答。但小组成员提醒,人类自己也会在换一种说法的性格问题上前后矛盾,讽刺和夸张也会破坏表面上的等价关系。因此,工程目标不是实现完美逻辑一致性,而是在部署前获得一个可衡量的理由,判断模型何时不可靠。

Tim Scarfe

Attention is just a way to route information between parts of the sequence, and that’s the genius behind a transformer. Layer by layer, it routes information to the correct place in the sequence such that it understands the entire thing at once.

Do you remember when GPT-2 was released—or, indeed, wasn’t released because it was considered too dangerous? It had about 1.5 billion parameters. It was a transformer language model trained on a corpus of about 40 gigabytes of highly curated text. Fast-forward 1 year, and Microsoft had released a new version of pretty much the same model that had 17 billion parameters. Eighteen billion—it doesn’t matter; it’s a lot.

In the olden days, we had these static, brittle knowledge graphs. They were incredibly onerous to create, but if we wanted to do something like question answering, they were the only way we could do it. If we wanted to ask, “What year did we win the Second World War?” then, without some kind of ontology of information, we couldn’t capture it.

With these transformer-based language models, you can pretrain them on a large corpus of text, let’s say Wikipedia, using a self-supervised task, and then fine-tune them on a downstream task. The incredible thing is that these models accrue information. They accrue knowledge about the world. You can ask one how old Obama is, and it will know the answer. It’s incredible.

The current revolution in neural representations for natural language originated with Mikolov’s word2vec skip-gram model in 2013. It was such a simple architecture. It used a contrastive loss, which we spoke about last week, and asked the simple question: does this word belong in the context of this other word? Using a fully connected architecture and a negative-sampling strategy with a contrastive loss, you could project these words into an embedding space that reflected their linguistic context.

The problem was that the words were atomic. They didn’t really take into account the structure of language, and language has this incredible structure. Words can modify each other from a long distance, and those relationships can be multiscale and complex.

The first evolution along the road was that we started to have language models like ELMo, which started to use bidirectional LSTMs to model the sequential dependencies between adjacent tokens. This was beginning to capture some of the meaning encoded in language.

Then ULMFiT came along, by Jeremy Howard and Sebastian Ruder, and this was when things really started to get interesting. It was the first model that essentially did transfer learning. You could build a language model that was just predicting the next word using a bidirectional LSTM, but then, exactly as happens in computer vision, you could do transfer learning. You could take off the last few layers, put a classifier on, and get the model to do something completely different.

You could pretrain a language model on Wikipedia, take the last layer off, turn it into a classifier, and do sentiment analysis. You had this transfer of knowledge between the self-supervised pretraining task and the downstream task. That essentially meant we had more training data, and the language model already knew loads and loads of concepts that would be useful for our downstream tasks.

In 2017, a chap called Ashish Vaswani came along from Google with a paper called “Attention Is All You Need.” This introduced transformers, and transformers are an entirely new architecture in neural-network design. We have densely connected networks, recurrent neural networks, and convolutional neural networks, but transformers are an entirely new paradigm—an entirely new type of network architecture.

RNNs and CNNs had been the flavor of the day for building language models. They had some interesting properties. They could support variable-length sequences, CNNs could easily be parallelized, and they had linear or logarithmic interaction lengths between tokens. The main issue was that they only modeled local dependencies between tokens. In CNNs, long-term dependencies required many layers and were lossy. Even GANs are now using self-attention because of its ability to model long-range, multiscale, complex dependencies, allowing us to capture more symmetries and patterns in the data within the input-size limit.

Myth 6 in “The Seven Myths of Machine Learning Research,” from early 2019, tried to dispel the idea that transformers were more parameter-efficient by discussing lightweight and dynamic convolutions as an alternative with similar results on machine-translation tasks.

Transformers have their own architectural challenges. They can only work within a bounded input length, they have nonlinear interaction distances between tokens, and they’re memory-intensive as hell.

People used to process sequences of text using recurrent neural networks, but that had a problem. If you have a long sentence such as “Dave shared beer with his friend,” then, to understand what “his friend” means, we need to know that Dave was at the beginning of the sentence. A recurrent neural network needs to store the fact that Dave was there until it processes the end of the sentence, and that can be very difficult to learn.

A transformer can do this in 1 step. It can go from anywhere to anywhere using an attention mechanism.

Fast-forward to November 2018, and Jacob Devlin released a paper called “BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding.” This was a game changer—not only because there had been a tsunami of NLP papers modifying or modulating certain aspects of it, but also because many of the paper titles punned on the word “BERT.” I think that’s testament, if nothing else, to the impact this paper has had.

BERT was a bidirectional encoder-only transformer with 12 encoder layers. It had a pretraining task consisting of a masked language model and next-sentence prediction, and it was then fine-tuned on downstream tasks. The larger version of the model had about 340 million parameters, which was quite large at the time.

Because of the bidirectional context, it did particularly well on certain downstream tasks. It was state-of-the-art on question answering.

Since BERT, there’s been a tsunami of papers modulating some of the key findings in it. These papers even mention BERT or pun on the name BERT in the title, so we had RoBERTa, ALBERT, “Still BERT,” and “BERT on Stilts.”

The problem for the average consumer, like ourselves, is that we want to understand the relative contribution of all these different papers. We want to categorize what their changes to the pretraining objective are doing, what performance gains come from increasing the dataset size, what comes from having more in-domain data, and what comes from increasing the size of the model itself.

That’s where this paper is so important. It takes apart all these different factors that can lead to performance gains and isolates them in a large-scale study of transfer learning in the pretraining and fine-tuning pipeline.

Today, we’re talking about “Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer” by Colin Raffel and his colleagues from Google. This paper is basically a huge ablation study. It asks what happens if we change all these different variables, and how those changes affect the performance of language models across a suite of tasks. It introduces a new type of language model, the T5 model, which is a text-to-text model. Its text-to-text framework provides a simple way to train a single model on a wide variety of text tasks using the same loss function and decoding procedure. It can be applied to generative tasks like summarization, classification tasks like natural-language inference, and regression tasks like STS-B. Despite its simplicity, the text-to-text framework obtained comparable performance to task-specific architectures and ultimately produced state-of-the-art results when combined with scale.

One of the cool innovations in this paper is that they created a text-to-text architecture. That means they didn’t need to change anything, even though they were testing against many different types of downstream tasks.

You might think this is a form of multitask learning, and it kind of is, but it isn’t. They still fine-tune the model on each of the downstream tasks, but they also did a version in which they trained it uniformly across all the tasks. After some tweaking, I was surprised to see that the performance wasn’t actually that bad.

By “text-to-text,” I mean that, in the input text, you actually define what the task is. You could say, “Translate this from English to German,” and then say, “Hello, my name is Tim.” The language model picks up which task you want to do and gives you the result. Incredibly, there’s no leakage between the tasks. It doesn’t seem to degrade performance in any way to have this text-to-text architecture.

Yannic Kilcher

One thing I think is so interesting about it, with respect to transfer learning, is that when you’re a developer trying to take this model for your application, it makes it much easier to figure out how to fit your input and output into this kind of pretraining and fine-tuning pipeline.

I’m curious about what you think about the text-to-text input and output for a specific application compared with BERT or these other approaches, where you have to be more careful about how you define your input and output. Also, the generality of the pretrained representation is decreased when you have to be more specific about the input and output.

Tim Scarfe

For that reason, I think the key benefit of the text-to-text framework is that it makes transfer learning easier.

Yannic Kilcher

They say that as well. Depending on how you do the pretraining, even in this text-to-text framework, it may be more or less effective. Maybe we should explain it for people who haven’t read the paper.

In this framework, if you want to translate from English to French, you don’t train a model specifically for that. You simply say, “Translate from English to French,” and then you put the text after that. The instruction itself is also text.

They define various pretraining tasks where the model is supposed to fill in parts of the text. I think performance really depends on how you do this pretraining, and that’s one of the things they show in the paper. What I love about it is that everything is text now.

Connor Shorten

I can also see this being useful in multimodal systems, such as an image-text model. Having this representation of text is super interesting to me because it means you don’t have to be so specific about how you define even the pretraining.

BERT has this masked-language-modeling objective, which fits nicely into sentiment classification because you do next-sentence prediction throughout pretraining. With this approach, you don’t have to be as careful about how the pretraining fits into the downstream task.

Yi Ma

It’s interesting. We’ve gone through the takeaways, and 1 or 2 of them say, “We can do this and this and this, and then we combine it with scale, and it becomes state of the art.” It’s unclear to me how much scale influences this and how much the actual objective influences it. There’s a lot of uncertainty with respect to all these transformer-family models.

For example, in the BERT paper, the next-sentence-prediction task was specifically presented as something that helped the model understand the relationship between sentences. But in subsequent papers, some people have claimed that it’s necessary, while others say that you should just do masked-language modeling and not worry about next-sentence prediction.

To me, it’s still somewhat unclear where the magic is in these things. I don’t know how you see that.

I definitely think the ELECTRA objective, with the generator, is an interesting way of doing this. I hadn’t read SpanBERT before reading this paper, and I thought the small modification it makes provided more benefits.

There’s a lot of opportunity for exploration in self-supervised objectives. I don’t think the space seems particularly explored. They’ve tried shuffling and XLNet’s sentence scrambling, but it seems like they’ve tried almost everything with the pretraining objective. It was interesting to see all these little things combined and compared on an apples-to-apples basis in this framework. I don’t think anything else has done that at this level.

Tim Scarfe

One thing that interests me is that, every time I look at transformers, there’s always a small part of me that worries I don’t completely grasp what’s going on.

Vaswani’s original paper on transformers was an encoder-decoder model. BERT is apparently an encoder, and the GPT variants—and the NVIDIA model, what was that large NVIDIA one called?

Yi Ma

Megatron.

Tim Scarfe

Megatron. That’s a good name. Microsoft, of course, also brought out Turing-NLG, which had an 18-billion-parameter model. Those models are causal, or autoregressive, language models, so they only have decoders.

Can you put a bit of detail on the difference between them?

Yi Ma

In an encoder-decoder framework, you do what people originally did with LSTMs. You have an input, and you encode it fully into a hidden representation. Then you decode from that hidden representation. You can have attention and so on going on there, but basically you have 2 separate modules: one is the encoder and one is the decoder.

With BERT, as you said, you only have the encoder. You put in a sequence and get out another sequence of exactly the same length. With pure BERT, you can’t technically do something like produce language. People do it, but technically it’s kind of shaky. What you can do is classify each location, do span prediction, and so on.

If you modify the BERT architecture such that you make the encoder wider, so that you can put the input and part of the output in as the input, and then you do masked attention such that each output token can only look at its predecessors, then all of a sudden you have a decoder. You can do language modeling or sequence-to-sequence tasks using that.

Tim Scarfe

Aside from translation models, when do you think it’s interesting to encode only the inputs and then decode only from the encoder’s representation? For summarization, I suppose you could take the original document, encode it, and then decode only from what the encoder produces. But I guess I’m wondering why you would have explicit encoders and decoders for most of these tasks.

Yi Ma

Even the original transformer in “Attention Is All You Need” was autoregressive in the sense that it had attention on what the decoder produced. It was just that there were 2 separate modules for that. Now there isn’t; it’s basically 1 set of parameters.

The main benefit might come from parameter sharing between all of these things. Generally, it seems to help to make your matrices larger but share them across the modules.

Tim Scarfe

What do you think about parameter sharing? It sounds like such an odd thing to me. Do they both get gradient updates? Is it like when you have a quantized codebook and take all the updates that came from every parameter sharing that weight, or is it just copying it?

Yi Ma

Parameter sharing definitely seems like a way to save memory when storing the model parameters, but it seems odd to share the encoder and decoder parameters. I don’t quite understand the idea behind that.

Tim Scarfe

It’s strange, isn’t it? It’s somewhat similar to the way Siamese networks work, but rather than happening in parallel, it’s happening in series. Why would doing the same thing many times be beneficial? Why couldn’t you shortcut it?

I suppose a neural network is like a computer program. The idea is that you’re successively making transformations that transform data from one manifold to another manifold and then to another manifold. But why would you need to do that the same way at many intermediate steps?

Yi Ma

It doesn’t make sense. It’s the same exact transformation applied again. But I guess it has something to do with the fact that, if you have such a complex series of transformations and copy and paste it across 8 layers, it will still make a significant difference.

Parameter sharing definitely seems like an efficiency thing. I don’t know if I’ve read anything that does a large study on parameter sharing other than neural architecture search.

What I meant when I said parameter sharing was more like this: why should I have 10 weights in my encoder and 10 weights in my decoder when I can have 20 weights in a module that does both at the same time? That seems to benefit more than simply sharing parameters.

You can make sense of it if you think of these layers as computing subroutines of a program—common subroutines, such as aggregating features in a certain way or sorting them. If you think of it like that, a subroutine in a program can be called all over the place. It’s kind of the same thing, but that is speculation.

Tim Scarfe

I like the concept that there’s overparameterization in these models as well. Several architectures have come out recently, and in particular I’m looking at DistilBERT, which has a teacher-and-student concept. It’s all about knowledge distillation.

The idea is that you train a normal-sized model, then create a student model that is 40% smaller and 60% faster at inference. You train the student to clone the teacher. The student model retains about 97% of the performance, but it’s a little bit like the lottery-ticket hypothesis: why do we need all this overparameterization during the training phase?

Yi Ma

This idea has been in production in many places. It’s common in industry that you train large models and then push them down because you want to serve them. The idea isn’t new, but it’s cool to see it applied to transformers, because they’re so large and demanding.

It’s still a mystery why any of this works. What’s surprising is that we can get a small model with such high performance, but if we train the small model from the beginning with the training data, we can never get that performance. We need to train the large model with the same data and then distill it into the small model.

There’s a strange interaction here. You have to argue that the large model’s overparameterization makes the optimization procedure happy to accept the training data into the model. Once the information is in the model, it seems that you can transfer the features it learned by distilling it. This is still one of the stranger aspects of all of this: the fact that distillation works.

Tim Scarfe

I think you just gave a plug for my video on the lottery-ticket hypothesis.

Yi Ma

You said it perfectly. In a way, it’s quite depressing that this is how it works. It’s a bit like having a block of clay and chipping away at it with stochastic gradient descent. Because most of these network architectures are so overparameterized, they contain n choose p subnetworks. There’s a combinatorial explosion of different subnetworks, and, probabilistically at least, one of those subnetworks is likely to provide a good inductive prior for the problem.

But this is a horrible way to go about it. How does pruning scale to transformers? Does it involve taking out the heads? How does transformer pruning work? How do you find a lottery ticket in a transformer?

One comment we can make is that Colin Raffel, in this paper, tried overparameterization as one of the tweaks we’ll come to later. He increased the model size, but his comment was that he did it only in the feed-forward section. He didn’t touch the attention.

Tim Scarfe

That’s really interesting, because the transformer thing isn’t obvious to prune. It’s an operation on a set, and you can’t just eliminate the attention in an obvious way as you could with a feed-forward layer.

Connor Shorten

I think distillation is more of a testimony to the power of label smoothing and label regularization. Even with naive label smoothing, where you put, say, 90% probability on the correct class and distribute the rest uniformly everywhere else, I don’t think distillation is really transferring the features from the teacher model. It’s a more clever way of doing label regularization.

Meta Pseudo Labels is a recent paper that shows something similar. It’s a more clever way of dynamically adjusting the labels, and that seems to be a really good way to train these neural networks.

Yi Ma

That makes sense, but is it known how this relationship works across architectures? By outputting not just the labels but the probabilities of the labels, you could implicitly transfer the features because the student has the same architectural inductive bias. It’s a transformer and the teacher is a transformer, so, given the same outputs, the same architecture should learn the same features.

Is it known how distillation works across architectures? For example, if I distill this into an LSTM or something?

Connor Shorten

I know there’s a paper that takes transformer labels and puts them into an LSTM, but I don’t remember the details.

The feature transformation is more about transferring the embedding distances. It’s almost like a metric-learning thing. The teacher is showing you that one thing is kind of like a dog but very far from a ship, whereas another cat is closer to a ship. It’s more a transfer of the distances between the examples in the dataset than a transfer of the features themselves.

Yannic Kilcher

That’s an interesting way to think about it. Could there be a distillation procedure that uses this distance-metric idea and does some sort of contrastive learning, where you say that these 2 things should be closer together than this other thing?

Connor Shorten

It seems like some combination of those approaches should be possible. It reminds me of how neural style transfer uses intermediate features. It’s definitely a tricky idea, but distillation with distances seems interesting.

Tim Scarfe

Let’s carry on reading a little bit of the paper. The second part starts to talk about the encoder-decoder architecture, which I didn’t completely understand, so let’s read this section.

There’s a real contribution around architectures. It says: “While some work on transfer learning for natural-language processing has considered architectural variants of the transformer, we found the original encoder-decoder form worked best in our text-to-text framework. Although an encoder-decoder model uses twice as many parameters as an encoder-only model, such as BERT, or a decoder-only language model, such as GPT, it has a similar computational cost. We also showed that sharing the parameters in the encoder and the decoder did not result in a substantial performance drop, while of course halving the total parameter count.”

Just to confirm, was the original Vaswani model an encoder-decoder model, or is it referring, as Yannic was saying earlier, to the original recurrent neural-network sequence-to-sequence models?

Yannic Kilcher

I think the original model was an encoder-decoder model. I made the connection because the original sequence-to-sequence frameworks also always talked about encoders and decoders.

Tim Scarfe

I think that’s because it makes intuitive sense. The RNNs were learning a sequential representation, and clearly there was an encoding phase where the model went from a sequence into a flat internal representation, followed by a decoding phase.

But transformers are a little bit different, aren’t they? They don’t flatten the data into a representation in the same way. The data still seems to remain in the original time domain.

Yannic Kilcher

You can’t completely wash out the differences once you introduce attention into LSTMs and things like that. I think it’s mainly about how you program the systems, rather than about actual ideological or mathematical differences.

Connor Shorten

What do you think about the positional embeddings? When I first read “Attention Is All You Need,” the way it handled positional embeddings looked bizarre. Now people are using relative embeddings, as in Transformer-XL, so I guess that’s how they give the model a notion of time.

Yannic Kilcher

It’s a very strange way to do it. A transformer by itself has no notion of position in the sequence. It doesn’t know where information is coming from. It can query information and address content by its content, but it can’t ask where that information came from.

I suppose the researchers realized that information about whether something is at the beginning or end of the sequence, or 2 positions away from another token, is useful. It seems strange to put positional information in, but the original paper wouldn’t have included it if it wasn’t needed.

Tim Scarfe

I find the use of sine waves for positional encoding quite smart. You overlay sine waves, where one is very slow and the next is faster. By indexing a point across those waves, you can measure distance at different scales.

The large sine wave gives you a large-scale distance. It encodes your position without requiring the model to do arithmetic. The model can ask what is in its close neighborhood and use the fastest sine wave, or it can ask what is around it in a larger sense and use the slower sine wave.

Connor Shorten

Transformer-XL introduced recurrence into the model, and then you need a relative positional encoding for all the chunks. Coming back to transformers, in contrast to an RNN, where you’re learning a sequential representation and therefore have some concept of time built in, it seems somewhat similar to the way reinforcement-learning algorithms work.

Everything about the past is compressed into the present, but transformers have this wonderful capability to model long-term representations. You can attend from any token to any other token, so you can learn these long-term relationships. Does the model use the positional encodings as a ruler to measure how far away those things are?

Yannic Kilcher

I would guess that 95% of why these things help has a much simpler explanation. It’s just that the model knows that a token is at the start of the sentence. That gives it a hard attention to the beginning of the sentence. If the beginning says “what” or “who,” that is an extreme bias that helps the model understand what the sentence means.

A lot of what positional encodings provide is very simple. Some of it does have to do with which words are my neighbors, which words are far away, and which words come before or after me, because that is very important.

Tim Scarfe

One thing this brings to mind is that I’m interested in the concept of symmetries. A CNN can capture translational symmetry, but can a transformer capture the same symmetry? I don’t like the notion that positional embeddings hard-code the pattern so that a particular pattern of text has to start at the beginning of the sentence or at the beginning of the input.

Wouldn’t it be better if the model could learn the pattern in such a way that it was translationally invariant, or even invariant to different scales? It might be a pattern that occurs at different scales of language.

Yannic Kilcher

In some sense, it already can. If it pays attention to the correct frequency of the sine wave, it can learn that a phrase such as “My Little Pony” occurs at different positions. At one point on the sine wave, you have one value, then another value, and then another. Elsewhere in the sentence, the sine wave repeats, so the model can recognize the same pattern at both locations.

It can learn that if “Pony” follows “My” by 2 words, then it assigns a certain meaning. At a higher level, it could learn that if there is a relative clause after a person’s name, it assigns a particular meaning. You can learn these larger patterns at higher scales in the layers.

I think this encoding of overlapping waves is very cool for that reason.

Tim Scarfe

It’s beautiful. I don’t know whether they did an ablation study in which they removed the positional encodings, but if you think about it, the model has no concept of the relationships between the tokens without them. It can only be using the positional encoding.

Does that mean it’s only looking at relative distances between the tokens? Is it not looking at the immediate context of the words surrounding the token it’s attending to?

Yannic Kilcher

Who knows? If you introduce relative encodings, you have direct access to the immediate context. But I can almost guarantee that the model doesn’t work without positional encodings, because that’s why they’re there in the first place.

In T5, I think they use a learned scalar encoding, so they get away from the sine encoding.

Connor Shorten

The sine encoding seems to say that the word “eat” is more similar to word position 15 than to word position 1. It’s arbitrarily putting words near one another in that sense.

Yannic Kilcher

I think of it like a system I saw during my bachelor’s degree. A group was working on 3D face modeling. They had a machine that 3D-scanned your face by projecting patterns onto your skin.

First it projected black and white. Then it projected black, white, black, white. Then it projected black, white, black, white, black, white, and so on. In the end, every pixel on your face had a unique encoding of black and white across those different scales. Each pixel was unique, but neighboring pixels didn’t necessarily share the largest part of their encoding.

You could capture the fact that the 2 cheeks are equal in their bit encodings, except that one is black where the other is white in the first position. Beyond that, there’s a symmetry in the higher layers.

Tim Scarfe

I think that, of course, it does mean that some words are more similar than others, but if you do this across the layers, the lower layer can say that its neighbors are important, while the higher layers can say that things farther away are important. That might do the trick.

Let’s read a little more of the takeaways. The next section is about unsupervised objectives. In these self-supervised language models, the general approach is that there’s a pretraining task, which might involve next-sentence prediction, a masked-language model, or something else, and then you fine-tune the model afterward.

The paper says: “Overall, we found that most denoising objectives, which train the model to reconstruct randomly corrupted text, performed similarly in the text-to-text setup. As a result, we suggest using objectives that produce short target sequences so that unsupervised pretraining is more computationally efficient.”

Connor Shorten

I thought that was really cool. Instead of reconstructing the entire target, you only reconstruct what has been masked out. I think that speeds up training enormously. Rather than reproducing the entire original sequence, you only ask the model to fill in the missing spans.

Tim Scarfe

They’re saying it’s more efficient because the output space is smaller. I find it fascinating that it works at all. You give the model an input such as “Thank you me to your party week,” and the target is “for inviting last,” and somehow it manages to do that.

Yannic Kilcher

Especially because there are so many different ways to fill in the missing text that would make sense.

Tim Scarfe

It’s fascinating to look at the evolution of the different pretraining objectives in self-supervised tasks. In the BERT-style model, you had a random number of tokens masked out and the target was the original text, so that’s quite a large output space.

Then there was word shuffling, which didn’t get particularly good results. There’s also masking tokens. Is that the same as BERT? What’s the difference?

Yannic Kilcher

I think the key difference is the span. In BERT, there were also 2 objectives. Some of the input tokens were randomly swapped, which is why you might have something like “Thank you to your party Apple week.” The BERT model was asked to correct those tokens as well.

Here, with span masking, the model is just asked to fill in the masked tokens. I think this is the objective introduced in the paper called MASS.

Connor Shorten

Do you think switching “last” for “Apple” is useful? It looks like it doesn’t help much.

Yannic Kilcher

As they say, most of these tasks perform similarly, but it still seems important to do something like this. If you take a BERT model and train it directly on question answering or sentiment classification, sentiment might work, but question answering may not. Even though these objectives perform similarly, it’s still important to do some kind of denoising task.

I was impressed by the variety of tasks they came up with. It even looks like a pretty big gain to go from 83 to 84.4 on the GLUE tasks.

Tim Scarfe

We’ve been thinking about the ELECTRA pretraining objective, where there’s a generator in a different configuration. What do you predict would happen if they had put that into this pipeline? Would it be as good, or would it also perform similarly to the others?

Connor Shorten

You have a generator that corrupts the text. It’s a discriminator objective rather than a masked-token-prediction objective. You have a low-parameter generator that fills in the masked tokens, and then the larger model sees what the smaller generator thought should fill in those tokens.

The larger model isn’t reproducing the sequence. It’s making a binary real-or-fake prediction for each token. It’s somewhat like the GAN framework.

Yannic Kilcher

I don’t know what to think of that. GANs for text are still pretty far away. It might work, but a GAN objective seems like a much lower-information task than the actual language-production task.

Tim Scarfe

You have to weigh that against the fact that, for any given gap in a sentence, you could fill it with 20 different words and they could all make perfect sense. Here you have a training corpus telling the transformer, “No, this is the one I want.” That’s where a discriminator that assigns high probability to all those 20 words might benefit you.

Yannic Kilcher

I have no guess about whether it’s ultimately good or bad. I mostly don’t believe numbers in papers, because researchers come up with a new idea and then throw more resources at it, use a larger corpus, or apply some other trick. It’s very difficult to compare these things, even when they go to extreme lengths to perform ablations.

Connor Shorten

What do you think about competitions as a way to evaluate these models? Do they do a better job of decoupling the easy things to add? In a Kaggle competition, everyone augments the data, ensembles the models, and gives the problem as much compute as they have.

Maybe competitions are a better way to tease apart algorithms, but the benchmarks don’t seem to do that.

Tim Scarfe

That’s one of the key points François Chollet makes in his paper “On the Measure of Intelligence.” We’ve centered on the idea that benchmarking and competitions are the best way to get the best result, but competitions can produce perverse outcomes because we become so fixated on the benchmark that the winning solution doesn’t generalize to the real-world version of the problem.

Yannic Kilcher

There are 2 arguments here, or 2 modes. One is that a benchmark or competition is how we evaluate things. The other is that someone reads all the papers, implements them carefully, uses the same hyperparameters, and gives every model the same amount of compute.

Both are flawed in their own ways. If I had to choose, I’m more on the side of competitions. If you say, “Whatever the highest number you can get is, do it,” then you may not be able to interpret exactly where the gains come from, but at least you get an absolute number. You learn how far you can push the system with everything you have.

If someone implements every approach we’ve seen, however, you can run into problems. There was a famous paper called “All GANs Are Created Equal,” where the authors implemented all these GANs. Then the authors of the Wasserstein GAN came along and said, “We stated clearly in our paper that our algorithm only works with RMSProp, not Adam.” But in that paper, the hyperparameter grid included those algorithms, even though the original paper said it didn’t work that way.

All the options are bad, but if push comes to shove, I’m more on the side of competitions. Ultimately, as a practitioner, the best thing you can do is look at all these papers and try to crystallize what they have in common. Don’t necessarily believe any individual paper, but if you see the same tricks and architecture types over and over again, those are probably the things that work.

Tim Scarfe

It makes me think of some of Chollet’s other comments. He used the example that, in the 1980s, people such as Marvin Minsky had quite narrow definitions of AI, centered on how well a system could perform a task.

That’s a different metric for humans and algorithms. If an algorithm can beat the world chess champion, that doesn’t seem particularly impressive, whereas if a human can do it, it’s very impressive. That’s because the human is learning how to become highly skilled.

It reminds me of when we talked about Uber’s POET, because that was all about a system that learns and produces its own curriculum. These competitions and benchmarks are so narrow-minded that they stop us from making progress toward what artificial intelligence should be: the ability to learn things dynamically.

Yannic Kilcher

Is that even the question we need to ask to make progress in artificial intelligence? For a company such as Google, if its translation model is better than everyone else’s, then it makes money. That’s the practical objective.

With respect to intelligence, though, if you give a human the same amount of raw compute time—say, neuron firings versus GPU cycles—and the same amount of memory, where it can write down everything, I wouldn’t be surprised if the human became much better at chess. We have the impression that humans are so good because we have limited time and develop a feeling for how hard the task is.

Tim Scarfe

I think we’ll be doing a “Measure of Intelligence” talk very soon.

Connor Shorten

What do you think about the DAWNBench idea of limiting the computational resources for a task or competition? It seems that you can’t have a fair computational budget for everyone and still do something interesting with models on the same scale as when the budget is unbounded.

For machine translation and similar tasks, the best effort may not be to develop a cleverer algorithm. It may be to figure out how to train a 100-billion-parameter transformer, or even a trillion-parameter transformer. The differences between TPUs and GPUs, and the way they enable larger-scale matrix multiplications, seem like a more promising direction for these kinds of problems.

Yannic Kilcher

I had an interesting conversation with a friend about this. I was arguing that systems should receive equal resources, but his point was that some effects only emerge at scale. There are effects these models capture only because they have 1 billion parameters and 50 terabytes of training data.

The only real objective number you have is how well you can perform with unbounded computation and unbounded resources. It’s an entirely different task to say that you get a fixed number of CPU cycles. If I’m engineering something for a mobile phone, I care about that, but it’s a narrower field.

Tim Scarfe

That’s a nice segue into the dataset section of the paper. Some papers in this area, such as RoBERTa, discovered that BERT simply wasn’t trained for long enough. It was undertrained. As we’ll find out in this T5 paper, training for longer is one of the most effective strategies.

The paper says: “We introduced the Colossal Clean Crawled Corpus, or C4, which comprises heuristically cleaned text from the Common Crawl web dump. When comparing C4 to datasets that use additional filtering, we found that training on in-domain unlabeled data could boost performance on a few downstream tasks. However, constraining training to a single domain typically results in a smaller dataset. We separately showed that performance can degrade when an unlabeled dataset is small enough that it is repeated many times over the course of training. This motivates using a large and diverse dataset like C4 for generic language-understanding tasks.”

They started with this huge dataset. It was 6.1 terabytes, and after filtering it was reduced to 745 gigabytes. They removed JavaScript, kept sentences that ended in a period, and did some deduplication. It’s surprising how much they could filter away.

Connor Shorten

I thought another interesting point was that, although the current pipeline has an enormous amount of unlabeled text available, natural-language processing seems to benefit particularly well from unsupervised pretraining followed by fine-tuning.

They were able to get about 750 gigabytes of text from the entire internet, while they had roughly 20 gigabytes of Wikipedia, plus the BooksCorpus. But if you look at Table 12, the supervised multitask pretraining result is already only about 3 points behind the unsupervised result on GLUE.

That makes me wonder whether supervised multitask pretraining will be more scalable in the future. People are producing supervised natural-language-processing datasets every day. I would actually predict that supervised multitask pretraining may become more scalable, because you can’t get an unlimited amount of unsupervised data.

In images, it might be the other way around. You can drive a self-driving car around and collect more images than you could ever store in a labeled dataset. Maybe images will be the domain where we think of unsupervised pretraining as the most scalable approach.

Tim Scarfe

The takeaway from this paper was that unsupervised pretraining is still better, but it does seem to indicate that the magic of unsupervised training is simply that you get more data. You train for longer with more data, and that allows you to learn better.

They did some interesting experiments. They tried not doing unsupervised pretraining at all, and then they did something similar to Microsoft’s MT-DNN. They used multitask learning, training uniformly across all the tasks, and then separately fine-tuned the model on each downstream task. That significantly improved performance.

Yannic Kilcher

I definitely think multistage training is useful. You can do unsupervised masked-language modeling and then, even if you use the same self-supervised task, continue training on in-domain data.

That’s another major characteristic of the ablation. If you pretrain on Wikipedia, you’ll do better on something like SQuAD and worse on something like CoLA, because the model has never seen an unacceptable sentence before in Wikipedia. It has no sense of that distinction.

Tim Scarfe

Maybe a large part of the effect comes from the fact that the model has never seen the kind of text it will encounter in these tasks.

Yannic Kilcher

With images, the inputs are natural images all the way through. It isn’t as though a visual-question-answering task suddenly has a large arrow on the image saying, “What is this thing called?” If the model has never seen that during training, it can’t make sense of it.

That may be the real distinction here. Language has structures such as unacceptable sentences that the model may never have seen during training. In-domain pretraining may provide the model with a sense of the type of data it will receive during the actual fine-tuning stage.

That also somewhat undercuts the idea of huge general pretraining. If the explanation is ultimately that you still need to see the type of data your task uses, and once you do, you aren’t much worse than the huge pretrained model, then how much are you really gaining from the massive pretraining?

Connor Shorten

How interested are you in meta-learning, where the definition is domain adaptation or rapidly changing to a new environment? MAML, for example, tries to find a good set of initial parameters so that, when you shift domains, the model quickly adapts.

If you moved from Wikipedia to one of the book corpora, could meta-learning give you an unsupervised representation that works for every domain, or do you necessarily need another mechanism that performs domain adaptation?

Yannic Kilcher

One way of describing it is that there are more similarities between language corpora than there are dissimilarities. By doing unsupervised training, you capture as much useful, generalizable information as possible.

But there are words that mean different things in different domains. In the financial world, “default” is a very bad word.

With meta-learning, I’m always a bit skeptical of these papers. We don’t have that many tasks, even in NLP. Although people are producing new datasets all the time, there’s still a limited number of tasks and a limited number of ways in which they’re diverse.

To claim that you’ve found an initialization that works for general language seems like an overclaim. I’ve seen the same thing with Google’s Visual Task Adaptation Benchmark. You pretrain on something like ImageNet, but then you only have 1,000 samples for all these other tasks. The tasks are too similar to establish that you’ve found something truly general.

It’s a very cool field, and if it works, it will be game-changing for practitioners. But I’m skeptical about the claims.

Tim Scarfe

With respect to the dataset, it’s called the Colossal Clean Crawled Corpus, and I think the community may be running out of words to describe large things. There’s Megatron, XLNet, and Transformer-XL. I wonder how high they can push this word game.

They released C4, which means that someone at OpenAI must have been having a heart attack. How can you release something so dangerous? It’s 10 times as dangerous as the OpenAI corpus would have been.

Yannic Kilcher

One comment I wanted to make is that the dataset isn’t actually that big. The dataset they called WebText—their equivalent of what they did with GPT-2—was filtered to include high-quality news articles. I think that meant articles linked from Reddit that had been upvoted at least 3 times.

That dataset is only about 35 gigabytes, but its score is significantly higher than the filtered C4 score. How can that be? C4 is only 20 times larger than the filtered internet text. Isn’t that interesting?

Connor Leahy

It also raises a privacy issue. If you went through everyone’s Facebook messages, Twitter direct messages, and private conversations, you could get much better text data. Of course, you can’t do that because of privacy concerns, but it’s an enticing possibility.

Yannic Kilcher

These systems are especially worrying because the transformers are getting so large that, in essence, they may be remembering the training data and interpolating between it.

I’ve always had the impression that, to make the next step in NLP, you need to ground the knowledge. I think of Chollet’s example from the Abstraction and Reasoning Corpus, where you have an image with black pixels, 3 blue pixels, and 2 orange pixels going away from them. It’s clearly something bouncing off a wall, but we understand that because we live in the physical world, where things bounce off other things.

The next step needs to involve grounding. These models don’t have that. All they can do is interpolate patterns that they see in the training data. They’re becoming so large that they may simply remember the entire training corpus and figure out how to mix and match it.

They see a noun, observe that a sentence starts with certain words, and finish it with an example from the training data, or with a mixture of 2 examples. I’m not convinced they learn very sophisticated things; they learn how to mix and match the training data.

Tim Scarfe

There was an XKCD comic where the model starts writing an email with “The next meeting of the rebellion leaders…”

Connor Leahy

How would you ground language? You could have text-based adventure games, where you receive a text prompt such as, “You’re in a dungeon. You see this thing on the table. What do you want to do?” You navigate the world through text.

Chatbots are grounded in a similar way, because you receive a reaction to what you say. There’s also PointNav, where you navigate a visual world based on language cues, or the Allen Institute’s RoboTHOR. There’s another benchmark called “Read to Fight Monsters,” where you receive a description of a game in language and then play the game.

To ground language, you need the context around it. It’s unclear how you would define that context.

Yannic Kilcher

These text-adventure games and related environments are a nice idea, but if you want to make them useful for machine learning, you need a lot of data. You can only get that if someone writes a procedural generator for the text.

Then you’re no longer really dealing with language. You’re dealing with a procedurally generated grammar, where you look for the same patterns of words that the simulator writer included.

By grounding, I mean that if I say, “There is a car around the corner,” and I live in the physical world, I know that cars are objects, that they’re on roads, and that “a corner” in this case means the corner of a house. There’s a road here and a road there, with a house in between. I can’t see the car, but it’s around the corner.

Tim Scarfe

I love Chollet’s concept that intelligence is closely linked to the world and the environment in which we live. That’s his major argument for why there can be no explosion of intelligence.

But I also like what you were saying about neural networks being memorization machines. Philosophically speaking, you could argue that we’re the same. If we could remember everything, perhaps this conversation would simply be us regurgitating things we’d picked up from random places, without thinking fluidly or intelligently.

Of course, that isn’t true. What Chollet would say is that deep learning has a problem with minimal generalization. To learn anything, we have to memorize it.

There was a wonderful paper a few years ago saying that deep-learning algorithms don’t extrapolate; they only interpolate. The example was the identity function, f(x) = x, which is one of the simplest functions in the world to learn.

The researchers trained a neural network between –5 and 5 and then tested it outside the training range using several different activation functions. None of them could extrapolate. Isn’t that tragic?

Connor Leahy

How important is extrapolation? Going back to language grounding and the idea of looking at a car around the corner, Google recently released a Street View dataset where you navigate through street-view images based on language.

With enough data, you can probably interpolate between vision and language and navigate very well using language. Is extrapolation really necessary? Can we even define it?

You might say that a system can combine vision and language, but it’s still not intelligence. What else do you want to add? Audio? Touch?

Yannic Kilcher

Embodied cognition is essentially what I’m talking about. We live in the world through our senses. There are our senses and then our brains, which have been optimized to make sense of the inputs.

We interact with the world through input signals. You could argue that, if you give a neural network enough different modalities, it might be able to make the same connections.

Connor Leahy

It could do that in a superhuman way, because, as Tim said, it could instantly recall everything it had ever experienced.

Tim Scarfe

That would be a curse. It wouldn’t necessarily be a good thing.

Yannick Kilcher

I also don’t know how to think about this idea of generalization. If you consider the identity function, who’s to say that we don’t want the network to learn a function that rises and then returns to the mean?

It’s only because we tell the human, or the human somehow does this extrapolation, that we assume the pattern should continue. Based on what? Do we have an intrinsic notion that the pattern must continue as an identity function? How do we do this?

That’s the big question to answer.

Tim Scarfe

It’s interesting because, as you say, in the real world we have some useful inductive bias that allows us to reason about how things relate to one another. But in mathematics, if it’s such a simple function, why would it be so difficult for a neural network to extrapolate it?

Connor Shorten

One reason I became interested in generative adversarial networks is that studying a generator, which produces a high-dimensional output rather than a classification label, is a more interesting way to look at generalization.

You can give a generator a dataset of cats and ask it to design a new cat. Then you can ask whether it designed that cat according to your sense of what a cat is. I think it’s more interesting to think about generalization in terms of models that create things rather than simply label them.

Yannick Kilcher

That’s interesting, but is it generalization?

Connor Shorten

Disentangled representations are another thing I want to understand. If you can learn how to take the hat off a person, put sunglasses on them, or manipulate the separate factors of variation, that’s extremely interesting.

Tim Scarfe

Let’s continue with the paper. We keep digressing, but that’s no bad thing. This is what the channel is about. It’s called Machine Learning Street Talk for a reason.

The paper talks about training strategies. What struck me is that, if it truly were a multitask model, that would be wonderful. They got the best results by fine-tuning on the respective tasks, but imagine if you had a language model that was genuinely multitask.

You could say to the model, “Translate something from English to German,” and then give it the text. The model would give you the result without leakage between the tasks. They got pretty good results with that, and it blows my mind.

Yannick Kilcher

You have to remember that the model probably isn’t understanding the meaning of the sentence “I want you to translate this.” They probably prepend that exact sentence to all the translation tasks. The model simply learns that the particular combination of tokens indicates the language. It isn’t understanding the instruction.

Tim Scarfe

I agree, but a neural network is a computer program. It’s partitioning the model and delegating responsibility. Some parts of the model become responsible for translation, but the interesting part is the interconnected and shared nature.

It isn’t as though the top part of the model is responsible for translation. It’s reusing representations.

The MT-DNN paper from Microsoft does multitask learning as part of pretraining, before fine-tuning. The takeaway seems to be that training on multiple tasks at the same time gives you a kind of regularization, because you’re learning representations that are useful across all the tasks.

Yannick Kilcher

That’s very believable. It would be extremely interesting to have better introspection into these text models to see what’s really going on.

How far up are the representations shared? Is it only the word embeddings that are shared, with the model then dividing itself? Do the attention heads learn that, whenever there’s a translation task, they should do one thing while the others do something else?

It would be interesting to perform introspective analyses on these models to see how much the representations are shared and where the subroutines are reused across tasks. Maybe we’d find something very interesting.

There was a paper a while ago that did zero-shot translation. I don’t remember the exact procedure, but you pretrained on English and then fine-tuned the word embeddings for French. You could input English and output French, without having trained on that particular language pair.

Tim Scarfe

Recent neural-translation models do something similar. If they’re trained multilingual, they translate different languages into a common intermediate representation. In that sense, they can translate between almost anything.

Yannick Kilcher

It wasn’t exactly the same thing, but I’m going to find the paper because it was interesting. It suggested that there was something like an abstract language understanding—not grounding or intelligence, but an abstract notion of language.

It would be fascinating to see how multiple tasks and objectives are handled in the representations throughout the transformer layers.

Tim Scarfe

When you started explaining the possibility that the model is partitioned across attention heads, that was convincing. Maybe it does work that way. If this were simply a horrible fully connected neural network, it would be very difficult to understand what was happening. But clean partitioning across attention heads seems more likely.

Yannick Kilcher

It’s somewhat like a conditional-computation model, because of how the information is routed to the attention heads.

Connor Shorten

I had misunderstood the text-to-text setup. I thought the model actually understood “summarize” and then summarized the text. I thought that was one of the cool things about the approach: if you had a new task, such as “which pronoun does this refer to?”, you could prefix the example with that instruction and the model would learn it faster than if you used an arbitrary code such as “0 0 0 1 0 0,” where the code indicated pronoun disambiguation.

Yannick Kilcher

It’s possible, but the model represents tokens using word vectors, so you aren’t really giving it a one-hot vector. It’s in a much higher-dimensional space.

If you replaced “Translate from English to French” with meaningless text, such as “Sandwiches are nice,” and always used that phrase for the same task, it would still work. The model might have seen the phrase “translate” in that context somewhere in the training data, but if you always use the same arbitrary phrase, the model can learn that the phrase indicates the task.

Connor Shorten

It might make the training curve a little faster because the model still takes the word “summarize,” looks it up in the embedding table, and gets some sense of what it means. Hopefully the embedding has some representation of “summarize.”

Yannick Kilcher

That’s less exciting to me. Unfortunately, these things are never as exciting as they initially sound.

Tim Scarfe

Let’s talk about the loss, because the paper is almost depressing in showing that scale and the amount of training made the largest difference.

The baseline on GLUE was 83.28. When they used 4 times as many training steps, it went up to about 85.33, so that’s roughly a 2-point improvement.

The biggest improvement came from increasing the size of the network. They doubled the number of parameters, not by changing the attention heads but by increasing the number of parameters in the feed-forward layers. They also used twice as many training steps, and that produced about a 3-point improvement, which is huge.

Connor Shorten

I think what will happen is that we’ll train a very large model and then make only one pass through the available text. We’ll figure out how to train a 100-billion-parameter transformer before we figure out how to obtain the corresponding amount of data.

The model size is going to scale better than the number of training steps, because the 2 need to go together in these scaling relationships.

Tim Scarfe

It’s also interesting that, when they did multitask learning with a uniform prior over the tasks, some tasks performed quite badly. That’s a balancing issue. You’re undertraining some tasks and overtraining others.

They came up with a temperature parameter to weight the relevant tasks according to their contribution. But it isn’t only the differences between tasks. There’s also the problem of the unsupervised objective dominating the downstream tasks.

There’s quite a delicate balance. I think the most important thing is the transfer rate between all the different training objectives.

Connor Shorten

It’s similar to class imbalance. You might have many more examples of dogs than cats. In this framework, you also have task imbalance. It’s interesting to see the same phenomenon at the task level.

The text prefix might help with task imbalance, but conditional computation is interesting too. If you had sparse routing based on the task embedding, that might be the best way to overcome task imbalance.

It could also be related to catastrophic forgetting and continual learning. The latest solution from the Neuromodulation paper seems to involve another kind of sparse routing. I’m not exactly sure what happens in that paper, but it’s interesting to consider the composition and size of the multitask datasets.

Tim Scarfe

That’s pretty much the paper. It was really useful to explore what happens when you change each of these variables. Clearly, when you look at the history of papers on question answering over the last few years, BERT gave us a significant boost.

Since then, we’ve probably gained another 10 points, but the gains are beginning to level off. Over a 2-year time horizon, though, transfer learning—and perhaps transfer learning simply means training for longer on more data—gave us the biggest improvement.

Another point worth making is how democratizing this is. It’s now easy to download a pretrained model. You can download the unified T5 model we’ve been discussing, or you can train it yourself. You can perform sophisticated translation with it.

A few years ago, if you wanted to do high-quality speech recognition or translation, you couldn’t do it yourself. You had to use Microsoft or Google’s cloud platform—Cognitive Services on Azure—because you didn’t have enough data or a good enough model.

You had to pay for those services. Now it’s becoming quite democratized.

Yannic Kilcher

You can also form your own dataset, ask the model questions about it, and use that as a starting point.

The MT-DNN multistage approach is important too. If you want to collect all the deep-learning papers into a dataset, before labeling them you can perform self-supervised learning on the text. That gives you another useful stage in the pipeline.

Tim Scarfe

Why is language different? A high-quality language dataset can apparently be 35 gigabytes, which is nothing compared with vision. Google’s FaceNet paper trained on about 26 million faces, and that’s why it works so well. A facial-recognition dataset of that size would be incredibly valuable, and I wouldn’t be able to download it from Google.

It’s almost as if language is becoming more democratized than vision.

Yannic Kilcher

Language is a more compressed representation. We simply haven’t figured out how to compress images in a way that allows us to reconstruct the useful information.

Ultimately, you care about what ends up in your brain. For language, we found a good representation that encapsulates sound waves as words. For images, we haven’t found the equivalent representation yet. Maybe, once we figure that out, image datasets will become smaller.

Tim Scarfe

Another way to look at it is that language and vision are both unstructured data, but vision is much more unstructured than language. Language is actually very structured. You have atomic tokens, clear relationships between where they appear, and a 1-dimensional sequence.

Maybe that’s why you need much less pretraining data for language than for vision.

Connor Shorten

Possibly. You only have to learn the grammar of a language to make sentences, whereas, with natural images, you have to learn correlations between all the pixels. Nobody tells you which images are good and which aren’t.

Yannic Kilcher

It may also be that vision is almost a 2D image of the actual 3D world, with objects and spatial relationships. It’s a representation of something with position.

Tim Scarfe

I have another question. How far do you think this approach of encoding everything as text will go? If I were producing a chatbot or an assistant like Alexa, I would still hard-code all the individual commands. For now, that would work much better.

Connor Shorten

That’s an interesting point. If we had a model pretrained on chatbot conversations, could we fine-tune it somehow on all the deep-learning papers and then ask it questions about them? That would be interesting.

Yannic Kilcher

I find the notion of formulating the task as text interesting. What this paper doesn’t address is whether you can throw a task at the model that it has never seen before, given only textual instructions.

I saw a presentation by Richard Socher from Salesforce where he proposed that all NLP should be formulated as question answering. You always have a question and a context, and the model outputs text to answer the question.

You could frame next-sentence prediction or sentiment analysis as text generation. He also discussed pointer networks, where the model can either output text or point to something in the context or in the question as the answer.

Pointer networks seem to have disappeared. I don’t know whether they don’t work or simply aren’t fashionable, but they were used to formulate NLP as one general task structure. It’s a very similar idea to this, and perhaps we’re ready for a resurrection of pointer networks.

Connor Shorten

It reminds me of multihop question answering. You ask a question, but to answer it you need to ask 2 more questions first, and then use those answers to answer the original question.

Yannic Kilcher

Closed-book question answering is one of the things people claim T5 does well. You can ask, “When was the Second World War?” and it knows the answer because it has memorized it.

Tim Scarfe

GPT-2 did that too. You didn’t fine-tune it; you simply pretrained the language model, posed the question, and the answer magically came out because it was somewhere in the training data.

It’s a parallel with the old knowledge graphs. We used to explicitly compute knowledge graphs and say, for example, that Barack Obama was 45 years old. The problem was that building the knowledge graphs was extremely onerous, and the information was often conflicting.

People used to write unit tests to check for logical equivalence. That’s happening in language models too. My friend Marco Ribeiro has worked on the idea of creating semantically equivalent adversarial examples or logical tests.

For example, you might ask, “How many boots are there in this image?” and the answer is 3. Then you ask the logically consistent question, “Are there any boots in this image?” and you expect the answer to be yes.

You could use these examples to generate adversarial data for pretraining or fine-tuning, or as a way of deciding that a model isn’t reliable enough to put into production. I’m interested in this engineering reality, because when we have unstructured models, it’s useful to have a noninteractive way to reason about their behavior.

Yannic Kilcher

Humans would fail these unit tests too. There’s a personality test called the Big Five, which is statistically derived and self-reported. It asks the same question in different ways.

It might ask, “I often feel sad,” and then later ask the inverse in a slightly different form. The number of times the answers don’t correspond is astounding. It’s as though the test says, “You said you always feel sad, but here you said you’re mostly happy. What’s going on?”

Tim Scarfe

What’s even worse is that, when I applied for my current job, they gave me one of those silly psychometric profiles. They said I was only at a particular level on one dimension, and I asked why. They told me I had taken 10 milliseconds too long to answer a question.

Yannic Kilcher

Maybe these tests are going in the right direction, but at some point it becomes more a question of the tester and how well the tester has constructed the logically equivalent questions.

Language is subtle. The boundaries of sarcasm and hyperbole can be extremely narrow. It’s very difficult to write these tests procedurally. If we could write them procedurally, we could solve the problem.

Tim Scarfe

This is another area where we have potential. WordNet, for example, was also a knowledge graph. It was brittle, wasn’t updated very often, and didn’t understand colloquialisms or the way words change meaning with context.

But the composability and distributed nature of deep-learning architectures might allow us to start with a pretrained base model and then have a high-velocity model that learns the colloquialisms relevant to us.

Connor Shorten

Definitely. If we’re talking about Lyft customer service, and the map has made an error, you and I might describe our problems very differently in natural language. That’s the difficulty.

The system needs to adapt quickly to how Connor describes his frustration with the map, and then quickly adapt to how Yannic describes his frustration with customer service. Domain adaptation and rapid adaptation to a new domain are going to be key to making this applicable.

Tim Scarfe

There’s something interesting here. People think chatbots are all about AI, but they really aren’t. They’re a user interface, and they’re best constructed with static rules.

The natural-language processing you need is things such as intent recognition: what does the user want to do? If you had an unstructured output, imagine plugging a GPT model into your chatbot and asking, “How are you feeling today?” The GPT model might say, “I’m feeling great,” but what value does that have? It’s completely useless and unquantifiable.

If I wanted to test that system before releasing it into production, I’d need to write tests and understand what it was doing. With an unconstrained generative model, it’s completely useless. I have no idea what it’s doing.

Yannic Kilcher

That’s why I find this task formulation interesting. Could you pretrain a model on chatbot interactions and then fine-tune it? Could you give it a textual task and have it rapidly adapt to the new domain?

It would be interesting to know whether a textual task instruction actually helps it learn a new task faster than an arbitrary task identifier.

Tim Scarfe

That’s the end of the show. We were trying different formats. Last week we had an author on, so that was more of an interview style. The week before, we had several people in a field none of us was really well versed in. Someone would simply have something to say at some point.

We don’t yet know what’s best or most interesting, so we’re looking for feedback about what people like and what they find interesting. Should we be highly prepared and very technical for people who already know everything, or should we introduce the concepts first for people who don’t understand them?

探索统一文本到文本 Transformer 的迁移学习边界 — 文字稿与摘要 | BidClub