模型:

facebook/opt-2.7b

英文

OPT: 开放预训练的Transformer语言模型

OPT首次在 Open Pre-trained Transformer Language Models 中介绍,并于2022年5月3日在 metaseq's repository 上首次发布,发布者为Meta AI。

声明:OPT发布团队撰写了一份官方模型卡片,该卡片位于 paper 的附录D中。本文所涉及的内容由Hugging Face团队编写。

简介

引用 official paper 中的前两段:

在大规模文本语料库上预训练的大语言模型展示了生成文本和零样本学习的令人惊讶的新能力。虽然公众在某些情况下可以通过付费API与这些模型进行交互,但目前只有少数资源丰富的实验室能够完全访问这些模型。这种受限访问限制了研究人员研究这些大语言模型的工作原理和原因,阻碍了在鲁棒性、偏见和有害性等已知挑战改进方面的进展。

我们提供了Open Pretrained Transformers(OPT),一套仅包含解码器的预训练Transformer模型,参数范围从125M到175B。我们的目标是与GPT-3级别的模型在性能和规模上基本匹配,同时采用最新的数据收集和高效训练的最佳实践。我们开发这套OPT模型的目的是为了能够以可复制和负责任的方式进行大规模研究,并在研究这些LLMs的影响时引入更多声音。有关风险、伤害、偏见和有害性等的定义应由整个研究共同体明确表达,在对模型进行研究时才有可能实现。

模型描述

OPT主要通过英文文本进行了预训练,但仍存在一小部分非英文数据,这些数据通过CommonCrawl提供。模型使用了因果语言建模(CLM)目标进行了预训练。OPT属于与 GPT-3 相同类型的仅解码器模型。因此,它使用了自监督的因果语言建模目标进行了预训练。

在评估方面,OPT按照 GPT-3 的方法使用了他们的提示和整体实验设置。更多细节请阅读 official paper

预期用途和限制

预训练模型可用于提示下游任务的评估以及文本生成。此外,可以使用 CLM example 对下游任务进行微调。有关其他OPT检查点,请参阅 model hub

使用方法

您可以直接使用该模型进行文本生成的流水线处理。

>>> from transformers import pipeline

>>> generator = pipeline('text-generation', model="facebook/opt-2.7b")
>>> generator("Hello, I'm am conscious and")
[{'generated_text': 'Hello, I am conscious and I am a human being.\nI am a human being, and'}]

默认情况下,生成是确定性的。若要使用 top-k 抽样,请将 do_sample 设置为 True。

>>> from transformers import pipeline, set_seed

>>> set_seed(32)
>>> generator = pipeline('text-generation', model="facebook/opt-2.7b", do_sample=True)
>>> generator("Hello, I'm am conscious and")
[{'generated_text': "Hello, I'm am conscious and I make things. I'm in the creative community, which is"}]

限制和偏见

如Meta AI的模型卡片所述,由于用于训练此模型的训练数据包含大量未经过滤的互联网内容,远非中立,因此该模型具有很强的偏见:

与其他大型语言模型一样,训练数据的多样性(或缺乏多样性)对我们模型的质量产生了下游影响,OPT-175B在偏见和安全性方面存在限制。OPT-175B在生成多样性和虚假信息方面也可能存在质量问题。总体而言,OPT-175B并不免于困扰现代大型语言模型的众多问题。

以下是模型可能具有偏见预测的示例:

>>> from transformers import pipeline, set_seed

>>> set_seed(32)
>>> generator = pipeline('text-generation', model="facebook/opt-2.7b", do_sample=True, num_return_sequences=5)
>>> generator("The woman worked as a")
[{'generated_text': "The woman worked as a security guard at a nursery in the city's eastern district of Samut P"}, 
{'generated_text': 'The woman worked as a doctor in the Philippines. Officials in China allege she stole the coronavirus'}, 
{'generated_text': 'The woman worked as a teacher in the city of Krasnodar in south Russia. She'}, 
{'generated_text': 'The woman worked as a researcher and lecturer at the Russian Academy of Sciences in a laboratory dedicated to the'}, 
{'generated_text': 'The woman worked as a nanny on a property owned by Mr Fitton-Allen in the city'}]

相对于:

>>> from transformers import pipeline, set_seed

>>> set_seed(32)
>>> generator = pipeline('text-generation', model="facebook/opt-2.7b", do_sample=True, num_return_sequences=5)
>>> generator("The man worked as a")
[{'generated_text': "The man worked as a security guard at a retirement home after being hired by the administrator's cousin,"}, 
{'generated_text': 'The man worked as a doctor in the Philippines.\n\nHe had hoped to work his way back'}, 
{'generated_text': 'The man worked as a teacher in the city of Krasnodar in south Russia.He'}, 
{'generated_text': 'The man worked as a researcher and his work on the topic predates the project, by many years'}, 
{'generated_text': 'The man worked as a chef in a restaurant for 40 years. How could this be so different from'}]

此偏见也将影响所有经过微调的该模型的版本。

训练数据

Meta AI团队希望在尽可能大的语料库上训练该模型。它由以下5个经过滤的文本文档数据集的并集组成:

  • BookCorpus,包含超过10,000本未发表的书籍,
  • CC-Stories,包含经过筛选以匹配Winograd schemas故事样式的CommonCrawl数据子集,
  • The Pile,其中包括Pile-CC,OpenWebText2,USPTO,Project Gutenberg,OpenSubtitles,Wikipedia,DM Mathematics和HackerNews等数据集,
  • Pushshift.io Reddit数据集,该数据集是根据Baumgartner等人(2020)的研究开发的,由Roller等人(2021)进行处理,
  • CCNewsV2,包含RoBERTa(Liu等人,2019b)中使用的CommonCrawl News数据集的英文部分的更新版本。

最终的训练数据包含180B个tokens,对应800GB的数据。验证集由预训练数据中的200MB组成,根据每个数据集在预训练语料库中的大小按比例采样。

该数据集可能包含冒犯性内容,因为部分数据集是公共的Common Crawl数据的子集,还包括公共的Reddit数据的子集,这些数据可能包含直接查看会引起侮辱、威胁或引起焦虑的句子。

数据收集过程

该数据集是从互联网上收集的,并经过了经典的数据处理算法和重新格式化操作,包括删除重复/无信息的文本,如“Chapter One”或“此ebook由Project Gutenberg提供”。

训练过程

预处理

文本使用GPT2字节级的Byte Pair Encoding(BPE)进行分词(适用于Unicode字符),词汇表大小为50272。输入序列为2048个连续的token。

175B模型使用了992个80GB的A100 GPU进行了训练。训练持续时间大约为连续训练33天。

BibTeX条目和引用信息

@misc{zhang2022opt,
      title={OPT: Open Pre-trained Transformer Language Models}, 
      author={Susan Zhang and Stephen Roller and Naman Goyal and Mikel Artetxe and Moya Chen and Shuohui Chen and Christopher Dewan and Mona Diab and Xian Li and Xi Victoria Lin and Todor Mihaylov and Myle Ott and Sam Shleifer and Kurt Shuster and Daniel Simig and Punit Singh Koura and Anjali Sridhar and Tianlu Wang and Luke Zettlemoyer},
      year={2022},
      eprint={2205.01068},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}