# T5 for conditional generation: getting started

**URL:** <https://discuss.huggingface.co/t/t5-for-conditional-generation-getting-started/1284>\
**Category:** Beginners\
**Created:** [September 28, 2020, 10:06pm UTC](https://discuss.huggingface.co/t/t5-for-conditional-generation-getting-started/1284 "2020-09-28T22:06:07Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![valhalla](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/valhalla/32/4179_2.png) [@valhalla](https://discuss.huggingface.co/u/valhalla)\
**Post date:** [September 29, 2020, 9:30am UTC](https://discuss.huggingface.co/t/t5-for-conditional-generation-getting-started/1284/2 "2020-09-29T09:30:03Z")

</div>

1. You can choose whatever format that works well for you, only thing to note is your `dataset` or `collator`should return `input_ids`, `attention_mask` and `labels`.

2. To add new tokens

```pyhton
tokenizer.add_tokens(list_of_new_tokens)

# resize the embeddings
 model.resize_token_embeddings(len(tokenizer))

```

1. Using task prefix is optional.
2. No, you won’t need to register the task, the original `T5` repo requires that but it’s not required here.

You might find these two notebooks useful

1. [Fine-tune T5 for Classification and Multiple Choice](https://github.com/patil-suraj/exploring-T5/blob/master/t5_fine_tuning.ipynb)
2. [Fine-tune T5 for Summarization](https://github.com/abhimishra91/transformers-tutorials/blob/master/transformers_summarization_wandb.ipynb)
3. [Train T5 on TPU](https://github.com/patil-suraj/exploring-T5/blob/master/T5_on_TPU.ipynb)

> Note: These notebooks manually add the `eos` token (`</s>`), but it’s not with the current version, the tokenizer will handle that.

Here’s a great thread on tips and tricks for T5 fine-tuning

> [@T5 Finetuning Tips](https://discuss.huggingface.co/t/t5-finetuning-tips/684):
>
> Starting this for results, sharing + tips and tricks, and results. This is my first attempt at this kind of thread so it may completely fail. Some things I’ve found Apparently if you copy AdaFactor from fairseq, as recommended by t5 authors, you can fit batch size = 2 for t5-large lm finetuning fp16 rarely works. for most tasks, you need to manually add \</s\> to the end of your sequence. Thing’s I’ve read task specific prefix doesn’t matter much. cc @mrm8488 @valhalla @patrickvonplaten who…

---

_[View the full topic](https://discuss.huggingface.co/t/t5-for-conditional-generation-getting-started/1284)._
