# Using a custom GenerationMixin with T5ForConditionalGeneration

**URL:** <https://discuss.huggingface.co/t/using-a-custom-generationmixin-with-t5forconditionalgeneration/39803>\
**Category:** 🤗Transformers\
**Created:** [May 14, 2023, 10:36am UTC](https://discuss.huggingface.co/t/using-a-custom-generationmixin-with-t5forconditionalgeneration/39803 "2023-05-14T10:36:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![multitail](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@multitail](https://discuss.huggingface.co/u/multitail)\
**Post date:** [May 14, 2023, 10:36am UTC](https://discuss.huggingface.co/t/using-a-custom-generationmixin-with-t5forconditionalgeneration/39803/1 "2023-05-14T10:36:23Z")

</div>

I have cloned the code for` GenerationMixin` from `transformers/src/transformers/generation_utils.py` and have modified it.  
I have the following model and tokenizer.

```auto
tokenizer = AutoTokenizer.from_pretrained('t5-small')
model = T5ForConditionalGeneration.from_pretrained('t5-small').cuda().eval()

```

Now, while calling `model.generate`, how do I ensure that `.generate()` in my modified `GenerationMixin` is used?
