mlx-examples/t5
2023-12-18 11:25:14 -05:00
..
.gitignore Add gitignore 2023-12-18 08:42:45 -05:00
convert.py Load config from HF to support any model 2023-12-18 08:42:06 -05:00
hf_t5.py Run hf_t5 with any model 2023-12-18 11:25:14 -05:00
README.md Add readme.md for t5 2023-12-18 08:50:36 -05:00
requirements.txt Add skeleton 2023-12-14 15:21:36 -05:00
t5.py Fix --encode-only 2023-12-18 11:19:44 -05:00

T5

T5 are encoder-decoder models pre-trained on a multi-task mixture of unsupervised and supervised tasks. T5 works well on a variety of tasks out-of-the-box by prepending a different prefix to the input corresponding to each task, e.g.: translate English to German: …, summarize: ….

Setup

Download and convert the model:

python convert.py --model t5-small

This will make the {model}.npz file which MLX can read.

Generate

To run the model, use the t5.py script:

python t5.py --model t5-small --prompt "translate English to German: A tasty apple"

Should give the output: Ein schmackhafter Apfel

To see a list of options run:

python t5.py --help