-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Beam search decoding during inference doesn't generate good text. #265
Comments
Hi, |
That is in fact a feature of beam search, see this discussion, this implementation and this paper! Temperature-based random sampling and/or top_p (nucleus) sampling are in my experience always preferable to beam search. The root cause of the failure of beam search is that 1) a repetitive sequence will have a higher probability than any other, since the more you repeat, the more likely the next token will be (from the perspective of the network), and so will be chosen by beam search; 2) if you ask a network to assign probabilities to human text the distribution is actually highly irregular (not the most likely sentence, but a stream where some steps are extremely likely, others extremely random). Lovely graphs and explanations in the paper! |
@jchwenger Thanks for you reply. I understand and I agree that sampling methods works much better. But this performance that I reported here is not accepted from beam search, it didn't even generate anything meaningful. Beside, for any input it generates the same thing. |
My pleasure! From the network's perspective meaningful is not particularly relevant. If it's a character-level or bpe model this repetition of characters over and over might still be the one with the highest probability from the model's perspective, and that is, out of all possible outputs of the network, what beam search will attempt to pick. Beyond that, however, and how beam search is successfully used in other papers, I'm afraid I can't help you. |
Hi,
I have trained a model using Reinforcement learning.
When I use "beam search" to generate text, it generates all
However, when I use greedy or topk sampling the generation is like:
I used the
tx.utils.strip_eos
to strip anything after <|endoftext|>.1- I am not sure why beam search is performing this way? I would appreciate your help. following is my piece of code for doing decoding using beam search:
2- Is it better to use beam search for a model which is trained in a self-critical fashion, right?
I would appreciate if you can help me with these.
The text was updated successfully, but these errors were encountered: