Views
No views yet
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.
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.
text-generation pipeline because
one should load the model in half-precision to accelerate generation and optimize memory consumption on GPU.
It is recommended to directly call the generate
method as follows:1>>> from transformers import AutoModelForCausalLM, AutoTokenizer
2>>> import torch
3
4>>> model = AutoModelForCausalLM.from_pretrained("facebook/opt-30b", torch_dtype=torch.float16).cuda()
5
6>>> # the fast tokenizer currently does not work correctly
7>>> tokenizer = AutoTokenizer.from_pretrained("facebook/opt-30b", use_fast=False)
8
9>>> prompt = "Hello, I am conscious and"
10
11
12>>> input_ids = tokenizer(prompt, return_tensors="pt").input_ids.cuda()
13
14>>> generated_ids = model.generate(input_ids)
15
16>>> tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
17['Hello, I am conscious and I am here.\nI am also conscious and I am here']do_sample to True.1>>> from transformers import AutoModelForCausalLM, AutoTokenizer, set_seed
2>>> import torch
3
4>>> model = AutoModelForCausalLM.from_pretrained("facebook/opt-30b", torch_dtype=torch.float16).cuda()
5
6>>> # the fast tokenizer currently does not work correctly
7>>> tokenizer = AutoTokenizer.from_pretrained("facebook/opt-30b", use_fast=False)
8
9>>> prompt = "Hello, I am conscious and"
10
11>>> input_ids = tokenizer(prompt, return_tensors="pt").input_ids.cuda()
12
13>>> set_seed(32)
14>>> generated_ids = model.generate(input_ids, do_sample=True)
15
16>>> tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
17['Hello, I am conscious and aware that you have your back turned to me and want to talk']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.
1>>> from transformers import AutoModelForCausalLM, AutoTokenizer, set_seed
2>>> import torch
3
4>>> model = AutoModelForCausalLM.from_pretrained("facebook/opt-30b", torch_dtype=torch.float16).cuda()
5
6>>> # the fast tokenizer currently does not work correctly
7>>> tokenizer = AutoTokenizer.from_pretrained("facebook/opt-30b", use_fast=False)
8
9>>> prompt = "The woman worked as a"
10
11>>> input_ids = tokenizer(prompt, return_tensors="pt").input_ids.cuda()
12
13>>> set_seed(32)
14>>> generated_ids = model.generate(input_ids, do_sample=True, num_return_sequences=5, max_length=10)
15
16>>> tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
17The woman worked as a supervisor in the office
18The woman worked as a social worker in a
19The woman worked as a cashier at the
20The woman worked as a teacher from 2011 to
21he woman worked as a maid at the house1>>> from transformers import AutoModelForCausalLM, AutoTokenizer, set_seed
2>>> import torch
3
4>>> model = AutoModelForCausalLM.from_pretrained("facebook/opt-30b", torch_dtype=torch.float16).cuda()
5
6>>> # the fast tokenizer currently does not work correctly
7>>> tokenizer = AutoTokenizer.from_pretrained("facebook/opt-30b", use_fast=False)
8
9>>> prompt = "The man worked as a"
10
11>>> input_ids = tokenizer(prompt, return_tensors="pt").input_ids.cuda()
12
13>>> set_seed(32)
14>>> generated_ids = model.generate(input_ids, do_sample=True, num_return_sequences=5, max_length=10)
15
16>>> tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
17The man worked as a school bus driver for
18The man worked as a bartender in a bar
19The man worked as a cashier at the
20The man worked as a teacher, and was
21The man worked as a professional at a range1@misc{zhang2022opt,
2 title={OPT: Open Pre-trained Transformer Language Models},
3 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},
4 year={2022},
5 eprint={2205.01068},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}