# Customizing T5 tokenizer for finetuning

**URL:** <https://discuss.huggingface.co/t/customizing-t5-tokenizer-for-finetuning/16084>\
**Category:** 🤗Transformers\
**Created:** [March 25, 2022, 4:54pm UTC](https://discuss.huggingface.co/t/customizing-t5-tokenizer-for-finetuning/16084 "2022-03-25T16:54:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![phade160](https://avatars.discourse-cdn.com/v4/letter/p/bb73d2/32.png) [@phade160](https://discuss.huggingface.co/u/phade160)\
**Post date:** [March 25, 2022, 4:54pm UTC](https://discuss.huggingface.co/t/customizing-t5-tokenizer-for-finetuning/16084/1 "2022-03-25T16:54:11Z")

</div>

Hi,  
I am finetuning a T5 model for QA on my dataset but the vocab is so different than the tokenizer’s, which results in an excessive length of token\_ids/tokens. can I train a new tokenizer from the existing one and use it for finetuning? if yes, any tips/resources to aid?  
Thanks

---

<div class="post-metadata">

**Author:** ![0bzrv3](https://avatars.discourse-cdn.com/v4/letter/0/87869e/32.png) [@0bzrv3](https://discuss.huggingface.co/u/0bzrv3)\
**Post date:** [May 2, 2024, 7:16pm UTC](https://discuss.huggingface.co/t/customizing-t5-tokenizer-for-finetuning/16084/2 "2024-05-02T19:16:16Z")

</div>

what i did was make a set of words i want to be tokenized and used `tokenizer.add_tokens(new_tokens)`.  
remember to resize embedding weights in the model as well: `model.resize_token_embeddings(len(tokenizer))`
