
---license: Apache License 2.0 tasks:- Large Language Models---#### Clone with HTTP在个人中心->模型->我的模型,查询访问令牌。可以通过令牌进行git仓库的使用。```bash git clone http://git.aistudio.baidu.com/aistudio/opt-2.7b.git```- [OPT介绍](#opt介绍)- [模型描述](#模型描述)- [期望模型使用方式以及适用范围](#期望模型使用方式以及适用范围) - [如何使用](#如何使用) - [代码范例](#代码范例) - [模型局限性以及可能的偏差](#模型局限性以及可能的偏差) - [训练数据介绍](#训练数据介绍) - [收集过程](#收集过程)- [模型训练流程](#模型训练流程) - [预处理](#预处理)- [相关论文以及引用信息](#相关论文以及引用信息)- [训压推全流程](#训压推全流程)## OPT介绍OPT首次在[Open Pre-trained Transformer Language Models](https://arxiv.org/abs/2205.01068)中提出,并于2022年5月3日由Meta AI在[metaseq's repository](https://github.com/facebookresearch/metaseq)存储库中首次发布。引用[官方论文](https://arxiv.org/abs/2205.01068)介绍:> "Large language models trained on massive text collections have shown surprising emergent capabilities to generate text and perform zero- and few-shot learning. While in some cases the public can interact with these models through paid APIs, full model access is currently limited to only a few highly resourced labs. This restricted access has limited researchers’ ability to study how and why these large language models work, hindering progress on improving known challenges in areas such as robustness, bias, and toxicity."> 通过训练海量文本,大型语言模型具有生成文本和进行零码和少码学习的惊人能力。虽然公众有时可以通过付费API与这些模型进行交互,但完全访问这些模型目前仅限于少数高度资源的实验室。这种访问限制限制了研究人员研究这些大型语言模型工作方式的能力,阻碍了在提高强健性、缓解偏见和毒性方面已知挑战方面的进展。> "We present Open Pretrained Transformers (OPT), a suite of decoder-only pre-trained transformers ranging from 125M to 175B parameters, which we aim to fully and responsibly share with interested researchers. We train the OPT models to roughly match the performance and sizes of the GPT-3 class of models, while also applying the latest best practices in data collection and efficient training. Our aim in developing this suite of OPT models is to enable reproducible and responsible research at scale, and to bring more voices to the table in studying the impact of these LLMs. Definitions of risk, harm, bias, and toxicity, etc., should be articulated by the collective research community as a whole, which is only possible when models are available for study.">我们提出了Open Pretrained Transformers (OPT),一套包括解码器的预训练变压器模型,参数范围从1.25亿到1750亿。我们旨在以全面负责的方式与感兴趣的研究者分享这些模型。我们训练OPT模型以大致匹配GPT-3模型类别的性能和大小,同时应用最新的数据采集和高效训练的最佳实践。我们开发这套OPT模型的目的是为了能够以大规模开展可复现和负责任的研究,并在研究这些LLM的影响时引入更多声音。对于风险、伤害、偏见和有害性等概念进行定义。应该由整个学术研究界明确表述,这仅在研究模型可供研究时才有可能。## 模型描述OPT大部分使用英文文本进行预训练,但是仍有少量非英文数据通过CommonCrawl出现在训练语料库中。该模型使用因果语言建模(CLM)目标进行预训练,并且和[GPT-3](https://arxiv.org/abs/2005.14165)一样属于仅解码器模型系列。因此,它也使用自我监督的因果语言建模目标进行预训练。在评估方面,OPT沿用了[GPT-3](https://arxiv.org/abs/2005.14165)的提示和整体实验设置。## 期望模型使用方式以及适用范围预训练模型可用于提示下游任务的评估以及文本生成。此外,模型可以使用CLM示例进行下游任务的微调。### 如何使用直接通过AIStudio 模型库下载使用。### 代码范例```pythonimport paddlefrom paddlenlp.transformers import AutoModelForCausalLM, AutoTokenizerpaddle.seed(37)model = AutoModelForCausalLM.from_pretrained( "aistudio/opt-2.7b", from_aistudio=True)tokenizer = AutoTokenizer.from_pretrained( "aistudio/opt-2.7b", from_aistudio=True)query = "What are we having for dinner?"prompt = f"### Instruction:{query.strip()} ### Response:"inputs = tokenizer(prompt, return_tensors="pd")generate_ids = model.generate( **inputs, do_sample=True, max_new_tokens=10, top_k=10, top_p=0.85, temperature=1, repetition_penalty=1.15, eos_token_id=2, bos_token_id=2, pad_token_id=1,)[0]print(generate_ids)response = tokenizer.batch_decode(generate_ids)[0]print(response)```### 模型局限性以及可能的偏差根据Meta AI所述,由于该模型的训练数据包含了大量来自互联网的未经过滤内容,远离中立,故该模型具有强烈的偏见:> "Like other large language models for which the diversity (or lack thereof) of training data induces downstream impact on the quality of our model, OPT-175B has limitations in terms of bias and safety. OPT-175B can also have quality issues in terms of generation diversity and hallucination. In general, OPT-175B is not immune from the plethora of issues that plague modern large language models. "> 与其他大型语言模型一样,训练数据的多样性(或其缺乏)对于我们模型的质量会产生下游影响。OPT-175B 在偏见和安全方面存在一定的局限性。在生成多样性和虚构方面,OPT-175B 也会存在质量问题。总体而言,OPT-175B并不免除现代大型语言模型所面临的众多问题。这种偏差也会影响该模型的所有微调版本。### 训练数据介绍Meta AI 团队希望在尽可能大的语料库上训练这个模型。它由以下 5 个经过筛选的文本文档数据集的联合组成:* BookCorpus,包含超过 10,000 本未公开发表的书籍;* CC-Stories,是 CommonCrawl 数据的子集,该数据集筛选出了匹配 Winograd 故事式风格的数据;* The Pile,其中包括 Pile-CC、OpenWebText2、USPTO、Project Gutenberg、OpenSubtitles、Wikipedia、DM Mathematics 和 HackerNews;* Pushshift.io Reddit数据集,由Baumgartner et al.(2020)开发并由Roller等人(2021)处理;* CCNewsV2,包含英文部分更新版本的CommonCrawl News数据集,该数据集在RoBERTa(Liu et al., 2019b)中使用。最终的训练数据包含了180B的token,相应的数据量为800GB。验证集是由预训练数据中的200MB样本按照预训练语料库中每个数据集的大小比例抽样而成。该数据集可能包含攻击性内容,因为数据集是公共的Common Crawl数据和Reddit的子集,可能包含极具侮辱性、威胁性或带来其他焦虑的句子。### 收集过程该数据集来自于互联网,使用经典数据处理算法和重新格式化的技术进行清洗,包括删除像“Chapter One” 和 “This ebook by Project Gutenberg”等重复无用的文本信息。## 模型训练流程### 预处理文本使用GPT2字节级版本的字节对编码(BPE)(用于Unicode字符)进行分词处理,并采用50272个词汇大小。输入是由2048个连续令牌构成的序列。175B模型在992个80GB的A100 GPU上进行训练。训练持续时间大约为连续训练33天。## 相关论文以及引用信息```tex@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}}```## 训压推全流程请参考[飞桨大语言模型工具链](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/llm)以及其中的[OPT[类LLaMA]模型文档](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/llm/opt)