Instructions to use google/umt5-xl with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/umt5-xl with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForSeq2SeqLM model = AutoModelForSeq2SeqLM.from_pretrained("google/umt5-xl", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Regenerate the tokenizer.json pipeline from spiece.model
Browse files`spiece.model` keeps whitespace (`remove_extra_whitespaces: false`) and uses byte fallback, but `tokenizer.json` collapses repeated spaces and has `byte_fallback: false`, and `transformers` v5 additionally rebuilds the T5 pipeline with a whitespace split. Tabs and newlines are lost:
| text | `spiece.model` | current (`transformers` v5) | with this PR |
|---|---|---|---|
| `a\tb` | `▁a`, `<0x09>`, `b` | `▁a`, `▁b` | `▁a`, `<0x09>`, `b` |
| `line one\nline two` | `▁line`, `▁one`, `<0x0A>`, `line`, `▁two` | `▁line`, `▁one`, `▁line`, `▁two` | `▁line`, `▁one`, `<0x0A>`, `line`, `▁two` |
| `two spaces` | `▁two`, `▁`, `▁spaces` | `▁two`, `▁spaces` | `▁two`, `▁`, `▁spaces` |
This PR replaces the normalizer, pre-tokenizer and decoder in `tokenizer.json` with the ones `transformers` generates from `spiece.model`, turns on `byte_fallback`, and sets `"tokenizer_class": "TokenizersBackend"` in `tokenizer_config.json`, as suggested by the transformers maintainers in huggingface/transformers#51269. The vocabulary, the `<extra_id_*>` tokens and the post-processor are unchanged, so token ids do not move.
One deliberate difference from `spiece.model`: text right after a special token such as `<extra_id_0>` gets no extra `▁`, which keeps today's behavior for span-corruption style inputs.
I checked it on 33,013 texts (FLORES-200 sentences in 205 languages, Hindi/Malayalam code-mixed text, and Unicode edge cases): the texts that tokenize differently from `spiece.model` go from 5,102 to 39 (the remaining ones mostly start with whitespace), and decoding matches SentencePiece on all of them. `</s>` is still appended, and the special tokens are unchanged.
- tokenizer.json +2 -2
- tokenizer_config.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c081db4f20202314f3336148e556cbadd32adc4a9649ce34a0415bcb48dbdffb
|
| 3 |
+
size 16853695
|
|
@@ -309,6 +309,6 @@
|
|
| 309 |
"pad_token": "<pad>",
|
| 310 |
"sp_model_kwargs": {},
|
| 311 |
"spaces_between_special_tokens": false,
|
| 312 |
-
"tokenizer_class": "
|
| 313 |
"unk_token": "<unk>"
|
| 314 |
}
|
|
|
|
| 309 |
"pad_token": "<pad>",
|
| 310 |
"sp_model_kwargs": {},
|
| 311 |
"spaces_between_special_tokens": false,
|
| 312 |
+
"tokenizer_class": "TokenizersBackend",
|
| 313 |
"unk_token": "<unk>"
|
| 314 |
}
|