Transformers
PyTorch
TensorFlow
JAX
TensorBoard
Safetensors
Dutch
t5
text2text-generation
seq2seq
text-generation-inference
Instructions to use yhavinga/t5-base-dutch with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yhavinga/t5-base-dutch with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("yhavinga/t5-base-dutch") model = AutoModelForSeq2SeqLM.from_pretrained("yhavinga/t5-base-dutch", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download flax_to_pytorch.py from yhavinga/t5-base-dutch: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/yhavinga/t5-base-dutch/resolve/main/flax_to_pytorch.py
- Command line
-
hf download hf://yhavinga/t5-base-dutch/flax_to_pytorch.py
-
curl -L -o flax_to_pytorch.py https://huggingface.co/yhavinga/t5-base-dutch/resolve/main/flax_to_pytorch.py
1.24 kB
| import torch | |
| import numpy as np | |
| import jax.numpy as jnp | |
| from transformers import AutoTokenizer | |
| from transformers import FlaxT5ForConditionalGeneration | |
| from transformers import T5ForConditionalGeneration | |
| tokenizer = AutoTokenizer.from_pretrained(".") | |
| model_fx = FlaxT5ForConditionalGeneration.from_pretrained(".") | |
| model_pt = T5ForConditionalGeneration.from_pretrained(".", from_flax=True) | |
| model_pt.save_pretrained("./") | |
| text = "Hoe gaat het?" | |
| e_input_ids_fx = tokenizer(text, return_tensors="np", padding=True, max_length=128, truncation=True) | |
| d_input_ids_fx = jnp.ones((e_input_ids_fx.input_ids.shape[0], 1), dtype="i4") * model_fx.config.decoder_start_token_id | |
| e_input_ids_pt = tokenizer(text, return_tensors="pt", padding=True, max_length=128, truncation=True) | |
| d_input_ids_pt = np.ones((e_input_ids_pt.input_ids.shape[0], 1), dtype="i4") * model_pt.config.decoder_start_token_id | |
| print(e_input_ids_fx) | |
| print(d_input_ids_fx) | |
| print() | |
| encoder_pt = model_fx.encode(**e_input_ids_pt) | |
| decoder_pt = model_fx.decode(d_input_ids_pt, encoder_pt) | |
| logits_pt = decoder_pt.logits | |
| print(logits_pt) | |
| encoder_fx = model_fx.encode(**e_input_ids_fx) | |
| decoder_fx = model_fx.decode(d_input_ids_fx, encoder_fx) | |
| logits_fx = decoder_fx.logits | |
| print(logits_fx) | |