# Beam Search: Why do some beams begin with the same token?

**URL:** <https://discuss.huggingface.co/t/beam-search-why-do-some-beams-begin-with-the-same-token/5234>\
**Category:** Beginners\
**Created:** [March 31, 2021, 12:02pm UTC](https://discuss.huggingface.co/t/beam-search-why-do-some-beams-begin-with-the-same-token/5234 "2021-03-31T12:02:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ComfortEagle](https://avatars.discourse-cdn.com/v4/letter/c/dfb087/32.png) [@ComfortEagle](https://discuss.huggingface.co/u/ComfortEagle)\
**Post date:** [March 31, 2021, 12:02pm UTC](https://discuss.huggingface.co/t/beam-search-why-do-some-beams-begin-with-the-same-token/5234/1 "2021-03-31T12:02:03Z")

</div>

I am confused about two observations regarding beam search:

1. From reading @patrickvonplaten [How to generate text: using different decoding methods for language generation with Transformers](https://huggingface.co/blog/how-to-generate)]([https://How](https://How) to generate text: using different decoding methods for language generation with Transformers), it is my understanding that each beam in `BeamSearchEncoderDecoderOutput` should begin with a different token, or am I wrong in that assertion?

2. The [documentation](https://huggingface.co/transformers/internal/generation_utils.html#transformers.generation_utils.BeamSearchEncoderDecoderOutput) for `BeamSearchEncoderDecoderOutput` for the `sequences ` parameter states that “_The second dimension (sequence\_length) is either equal to `max_length` or shorter if all batches finished early due to the `eos_token_id` ._”. In my observations it’s always been longer than `max_length`. How come?

Thanks 🙂
