阅读笔记:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer

Contributions

先放贡献:最近谷歌发布的T5预训练模型在Glue,SuperGlue以及Squad任务上都超越了BERT,好不风光。在小编看来,它最主要的贡献是:

  1. 提出一个通用框架 – T5
  2. 公开的C4数据集
  3. 各种预训练的试验,对比结果,给出推荐参数

Text-to-Text Transfer Transformer (T5)

  • 它依然是基于Transformer的预训练模型

  • 将主流NLP任务(MT, QA, 摘要,分类)都转换为Text-to-Text的任务
    (Text-to-Text:Where the model is fed some text for contex or conditioning and is then asked to produce some output text),如下图:
    阅读笔记:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer
    注:为了帮助区分不同任务,在数据之前加prefix,如:阅读笔记:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer
    变为:阅读笔记:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer
    分类任务则为分类的label,比如“negative”;Regression任务,拿STS-B(相似任务)来说:1-5分,每0.2分为一个度量,则输出四舍五入到最近的0.2的整数倍,如:2.57→2.60,输出为String。

    通过这样的方式将不同的NLP 任务都转换成统一格式,就可以用同样的模型,同样的损失函数,同样的训练过程,同样的解码过程来完成不同 NLP 任务。其实这个idea在GPT-2论文中就曾提及,在这篇论文中终于实现了。

Colossal Clean Crawled Corpus (C4)

  • 源自Common Crawl (一个公开的网页存档数据集,每个月抓取约20TB 文本数据)
  • 目前只有英语
  • 进行清洗,最后大小为750G
  • 清洗过程简介如下:
    – 只保留结尾是正常符号的行;
    – 删除任何包含不好的词的页面,具体词表参考https://github.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words库;
    – 包含 Javascript 词的行全去掉;
    – 包含编程语言中常用大括号的页面;
    – 任何包含用于排版测试符号的页面;
    – 连续三句话重复出现情况,只保留一个。

Experiments & Results

本文中作者做了很多实验,包括但不限于model structure,model architecture,pre-training objectives,datasets 等等。

Baseline:

  • Model:实验发现用标准的encoder-decoder结构在生成任务与分类任务上的表现都更好。模型采用标准的transformer,具体参数参考BERT base;由于是encoder-decoder结构因此参数数量是BERT base的两倍。
  • Training:训练模式是标准的maximum likelihood,loss是cross-entropy,优化方法是AdaFactor,解码机制是greedy decoding(而不是beam search)。
  • Vocabulary:用SentencePiece生成了一个大约32000大小的词表,由于翻译任务的存在因此词表中存在非英语单词。
  • Unsupervised Objective:采用了Denoising objective(BERT-styple)代替传统的language modeling objective。灵感来自BERT的mask方式,并在基础上作出改进:阅读笔记:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer

Architecture:

  • Model structure:作者对三种预训练模型架构进行了比对,结果是Encoder-Decoder结构效果最好,如下图:阅读笔记:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer
    Encoder-Decoder型,即 Seq2Seq 常用模型,分成 Encoder 和 Decoder 两部分,对于 Encoder 部分,输入可以看到全体,之后结果输给 Decoder,而 Decoder 因为输出方式只能看到之前的。。
    第二种,相当于上面的 Decoder 部分,当前时间步只能看到之前时间步信息,典型代表是GPT2。
    第三种,Prefix LM型,可看作是上面 Encoder 和 Decoder 的融合体,一部分如 Encoder 一样能看到全体信息,一部分如 Decoder 一样只能看到过去信息。

  • 以上三种结构都是有Transformer构成,主要的区别是注意力机制的不同:阅读笔记:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer

  • 三种架构在不同任务上的结果展示如下,由于Encoder-Decoder结构效果最好,因此T5的模型结构即选为由Transformer组成的Encoder-Decoder模型:阅读笔记:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer

Objectives

  • 类别共三种:
    Prefix Language Modeling:类似于GPT2,由左到右依次预测;
    BERT-style:将一部分token mask掉,然后还原;
    Deshuffling:将顺序打乱,然后还原文本;
    区别如下图:阅读笔记:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer
     实验结果显示是BERT-Style最好,实验结果如下:阅读笔记:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer
     BERT-styple中的corruption rate为15%最好,结果如下:阅读笔记:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer
     Corruption Span长度为3时效果最好:阅读笔记:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer 
    综上,整个探索Objective的实验可由如下流程图展示:阅读笔记:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer

Others

  • 数据:1. C4完整数据由于数据来源众多,导致在一些领域内的下游任务的表现不如C4细分下的领域内的预训练数据表现好;2. 不同数据量对比,发现当数据少时模型会记住数据所以之后表现会差,因此数据越多模型预训练效果越好。
  • 训练策略:
    Fine-tuning methods:主要比较了两种方法,adapter layer和gradual unfreezing。adapter layer的参数量是跟fine-tuning tasks的数据规模正相关的。如果能仔细调调参数,其实还是更新所有参数表现最好。阅读笔记:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer
    Multi-task learning:单纯用multi task learning不如pre-train-then-fine-tune效果好。阅读笔记:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer
    Combining multi-task learning with fine-tuning:效果不如Unsupervised pre-training+ Fine-tuning。阅读笔记:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer
  • Scaling:更长的训练时间和更大的模型会带来更好的结果。阅读笔记:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer

Conclusion & Reflection

  • The inconvenience of large models:谷歌说:“我们也知道大模型表现好,但是一味把事情搞大不行,建议看看distillation、parameter sharing和conditional computation。”
  • More efficient knowledge extraction:我们需要一个更有效的方法来学到通用的知识,BERT-style loss的效率也许不是最优解。
  • Formalizing the similarity between tasks:我们需要一个衡量pre-training和下游任务相似性的方法 so that we could make more principled choices about what source of unlabeled data to use.
  • Language-agnostic models:English-only pre-training没能在翻译任务上达到SOTA的表现(因为没有Beam Search?),说明单一语言还是有局限性。