# How to stop after generating "###" in transformers?

**URL:** <https://discuss.huggingface.co/t/how-to-stop-after-generating-in-transformers/38585>\
**Category:** Beginners\
**Created:** [May 3, 2023, 7:20pm UTC](https://discuss.huggingface.co/t/how-to-stop-after-generating-in-transformers/38585 "2023-05-03T19:20:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vedantroy](https://avatars.discourse-cdn.com/v4/letter/v/c77e96/32.png) [@vedantroy](https://discuss.huggingface.co/u/vedantroy)\
**Post date:** [May 3, 2023, 7:20pm UTC](https://discuss.huggingface.co/t/how-to-stop-after-generating-in-transformers/38585/1 "2023-05-03T19:20:57Z")

</div>

I’m trying to do something fairly basic. When my language model is generating tokens, I want to stop if the language model generates the token corresponding to “##”.

I’m not sure how to do this. Do I need to implement a custom stopping\_criteria?
