# Beam search error

**URL:** <https://discuss.huggingface.co/t/beam-search-error/5773>\
**Category:** 🤗Transformers\
**Created:** [April 26, 2021, 1:30pm UTC](https://discuss.huggingface.co/t/beam-search-error/5773 "2021-04-26T13:30:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Felipehonorato](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/felipehonorato/32/48418_2.png) [@Felipehonorato](https://discuss.huggingface.co/u/Felipehonorato)\
**Post date:** [April 26, 2021, 1:30pm UTC](https://discuss.huggingface.co/t/beam-search-error/5773/1 "2021-04-26T13:30:37Z")

</div>

Well, i’ve trained a new model on GPT2 and added some tokens to control my generation. It all worked fine while i was using greedy search algorithm, but when i tried to switch for beam search algorithm it started to mess up my tokens, mixing it with regular words. Does anyone have a clue about why is that happening? And how can i solve it?

---

<div class="post-metadata">

**Author:** ![brando](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/brando/32/30114_2.png) [@brando](https://discuss.huggingface.co/u/brando)\
**Post date:** [May 12, 2024, 12:17am UTC](https://discuss.huggingface.co/t/beam-search-error/5773/2 "2024-05-12T00:17:27Z")

</div>

related: [How to generate multiple text completions per prompt (like vLLM) using HuggingFace Transformers Pipeline without triggering an error?](https://discuss.huggingface.co/t/how-to-generate-multiple-text-completions-per-prompt-like-vllm-using-huggingface-transformers-pipeline-without-triggering-an-error/86297)

related: [machine learning - How to generate multiple text completions per prompt (like vLLM) using HuggingFace Transformers Pipeline without triggering an error? - Stack Overflow](https://stackoverflow.com/questions/78466376/how-to-generate-multiple-text-completions-per-prompt-like-vllm-using-huggingfa)

---

<div class="post-metadata">

**Author:** ![brando](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/brando/32/30114_2.png) [@brando](https://discuss.huggingface.co/u/brando)\
**Post date:** [May 12, 2024, 12:17am UTC](https://discuss.huggingface.co/t/beam-search-error/5773/3 "2024-05-12T00:17:34Z")

</div>

did you find an answer?
