Instructions to use google-t5/t5-large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google-t5/t5-large with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("translation", model="google-t5/t5-large")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("google-t5/t5-large") model = AutoModelForSeq2SeqLM.from_pretrained("google-t5/t5-large") - Inference
- Notebooks
- Google Colab
- Kaggle
Fix: Add missing sentencepiece installation in example code
Browse files## Description
The example code fails with `ModuleNotFoundError: No module named 'sentencepiece'` when run in a clean environment. This is due to the `sentencepiece` package not being pre-installed.
## Changes
Added the following line at the beginning of the script to ensure all required dependencies are available:
```python
!{sys.executable} -m pip install sentencepiece
```
## Testing
The code has been successfully tested and runs without error.
## Note
This contribution is part of an ongoing research initiative to systematically identify and correct faulty example code in Hugging Face Model Cards.
We would appreciate a timely review and integration of this patch to support code reliability and enhance reproducibility for downstream users.
|
@@ -171,6 +171,7 @@ Use the code below to get started with the model.
|
|
| 171 |
<summary> Click to expand </summary>
|
| 172 |
|
| 173 |
```python
|
|
|
|
| 174 |
from transformers import T5Tokenizer, T5Model
|
| 175 |
|
| 176 |
tokenizer = T5Tokenizer.from_pretrained("t5-large")
|
|
|
|
| 171 |
<summary> Click to expand </summary>
|
| 172 |
|
| 173 |
```python
|
| 174 |
+
!{sys.executable} -m pip install sentencepiece
|
| 175 |
from transformers import T5Tokenizer, T5Model
|
| 176 |
|
| 177 |
tokenizer = T5Tokenizer.from_pretrained("t5-large")
|