SAVRN
Search Contact SAVRN

Open-weight model

byt5-small

by Google google/byt5-small

ByT5 is a tokenizer-free version of Google's T5 and generally follows the architecture of MT5. ByT5 was only pre-trained on mC4 excluding any supervised training with an average span-mask of 20 UTF-8 characters.

Parameters
Context
Weights3.6 GB
Licenseapache-2.0
AccessOpen weights
Monthly Downloads367.7k

Model Card

By Google, published under apache-2.0, revision 68377bdc18a2.

ByT5 is a tokenizer-free version of Google's T5 and generally follows the architecture of MT5. ByT5 was only pre-trained on mC4 excluding any supervised training with an average span-mask of 20 UTF-8 characters. Therefore, this model has to be fine-tuned before it is useable on a downstream task. ByT5 works especially well on noisy text data,e.g., google/byt5-small significantly outperforms mt5-small on TweetQA. Paper: ByT5: Towards a token-free future with pre-trained byte-to-byte models Authors: Linting Xue, Aditya Barua, Noah Constant, Rami Al-Rfou, Sharan Narang, Mihir Kale, Adam Roberts, Colin Raffel ByT5 works on raw UTF-8 bytes and can be used without a tokenizer: For batched…

Read Google's full model card

ByT5 is a tokenizer-free version of Google's T5 and generally follows the architecture of MT5.

ByT5 was only pre-trained on mC4 excluding any supervised training with an average span-mask of 20 UTF-8 characters. Therefore, this model has to be fine-tuned before it is useable on a downstream task.

ByT5 works especially well on noisy text data,e.g., google/byt5-small significantly outperforms mt5-small on TweetQA.

Paper: ByT5: Towards a token-free future with pre-trained byte-to-byte models

Authors: Linting Xue, Aditya Barua, Noah Constant, Rami Al-Rfou, Sharan Narang, Mihir Kale, Adam Roberts, Colin Raffel

Example Inference

ByT5 works on raw UTF-8 bytes and can be used without a tokenizer:

from transformers import T5ForConditionalGeneration
import torch

model = T5ForConditionalGeneration.from_pretrained('google/byt5-small')

input_ids = torch.tensor([list("Life is like a box of chocolates.".encode("utf-8"))]) + 3  # add 3 for special tokens
labels = torch.tensor([list("La vie est comme une boîte de chocolat.".encode("utf-8"))]) + 3  # add 3 for special tokens

loss = model(input_ids, labels=labels).loss # forward pass

For batched inference & training it is however recommended using a tokenizer class for padding:

from transformers import T5ForConditionalGeneration, AutoTokenizer

model = T5ForConditionalGeneration.from_pretrained('google/byt5-small')
tokenizer = AutoTokenizer.from_pretrained('google/byt5-small')

model_inputs = tokenizer(["Life is like a box of chocolates.", "Today is Monday."], padding="longest", return_tensors="pt")
labels = tokenizer(["La vie est comme une boîte de chocolat.", "Aujourd'hui c'est lundi."], padding="longest", return_tensors="pt").input_ids

loss = model(**model_inputs, labels=labels).loss # forward pass

Abstract

Most widely-used pre-trained language models operate on sequences of tokens corresponding to word or subword units. Encoding text as a sequence of tokens requires a tokenizer, which is typically created as an independent artifact from the model. Token-free models that instead operate directly on raw text (bytes or characters) have many benefits: they can process text in any language out of the box, they are more robust to noise, and they minimize technical debt by removing complex and error-prone text preprocessing pipelines. Since byte or character sequences are longer than token sequences, past work on token-free models has often introduced new model architectures designed to amortize the cost of operating directly on raw text. In this paper, we show that a standard Transformer architecture can be used with minimal modifications to process byte sequences. We carefully characterize the trade-offs in terms of parameter count, training FLOPs, and inference speed, and show that byte-level models are competitive with their token-level counterparts. We also demonstrate that byte-level models are significantly more robust to noise and perform better on tasks that are sensitive to spelling and pronunciation. As part of our contribution, we release a new set of pre-trained byte-level Transformer models based on the T5 architecture, as well as all code and data used in our experiments.

Configuration

Architecture
T5ForConditionalGeneration
Vocabulary size
384
Model type
t5

Identity and Version

Repository
google/byt5-small
Publisher
Google
Task
Not stated by the source
Modality
Other
Library
transformers
Parameters
Not stated by the source
Languages
af, am, ar, az, be, bg, bn, ca
Revision
68377bdc18a2ffec8a0533fef03b1c513a4dd49d
First published
2022-03-02
Last updated
2023-01-24

Files and Weights

9 files, 3.6 GB in total. The weights are 3 files totalling 3.6 GB in bin, h5, msgpack.

Weights3 files · 3.6 GB
Configuration3 files · 3.3 KB
Tokenizer1 file · 2.6 KB
Documentation1 file · 4.2 KB
Repository1 file · 736 B
Every file
FileTypeSizeSHA-256
flax_model.msgpackWeights1.2 GB b3aafee96d60
pytorch_model.binWeights1.2 GB 5c5aaf56299d
tf_model.h5Weights1.2 GB f97320dd5eb4
config.jsonConfiguration698 B
generation_config.jsonConfiguration147 B
special_tokens_map.jsonConfiguration2.5 KB
README.mdDocumentation4.2 KB
.gitattributesRepository736 B
tokenizer_config.jsonTokenizer2.6 KB

License and Download

License
apache-2.0
Access
Open weights, no gate
Download size
3.6 GB
Download from Google

Released by Google through its official repository on Hugging Face. Read the license.

Built From

  • Described by arXiv:1907.06292
  • Described by arXiv:2105.13626
  • Trained on (disclosed) mc4

Memory Requirements

PrecisionWeights in memory
As published3.6 GB

Weights only, from the published parameter count; the key-value cache and runtime add to this.

Questions About byt5-small

Can I use byt5-small commercially?

Yes. byt5-small is released under Apache License 2.0. The Apache License 2.0 is a permissive open-source license. It permits commercial use, modification and redistribution. It requires keeping the license and copyright notices and any NOTICE file, stating significant changes, and it includes an express patent grant from contributors.