What does adjust_logits_during_generation (formerly prepare_logits_for_generation) do?
https://github.com/huggingface/transformers/blob/49c5202522bdaf66e45df505b3a3c566e56134c3/src/transformers/modeling_utils.py#L794

Hi. Anyone can share why there is this method here?
Pro Sam @sshleifer, Can you help here. Many thx.<|||||>I think it helps to force the model generate a token such as `bos_token` or `eos_token` by setting the probability of generation of all other tokens to 0 <|||||>It is only used by `MarianMTModel` and `BartForConditionalGeneration`.
For Bart, what @mariamabarham said is exactly correct
> it helps to force the model generate a token such as bos_token or eos_token by setting the probability of generation of all other tokens to 0.

For Marian, it does that and one extra job, it prevents the model from ever predicting `pad_token_id`. In Marian, it's important that that logic happens before the softmax so that the probabilities of other "legal" tokens are not super low.

Great Q!


<|||||>> It is only used by `MarianMTModel` and `BartForConditionalGeneration`.
> For Bart, what @mariamabarham said is exactly correct
> 
> > it helps to force the model generate a token such as bos_token or eos_token by setting the probability of generation of all other tokens to 0.
> 
> For Marian, it does that and one extra job, it prevents the model from ever predicting `pad_token_id`. In Marian, it's important that that logic happens before the softmax so that the probabilities of other "legal" tokens are not super low.
> 
> Great Q!

@mariamabarham @sshleifer  Many thanx for your response!
Actually, I am learning the code https://github.com/huggingface/transformers/blob/49c5202522bdaf66e45df505b3a3c566e56134c3/src/transformers/modeling_utils.py#L816 
I am still don't understand how https://github.com/huggingface/transformers/blob/49c5202522bdaf66e45df505b3a3c566e56134c3/src/transformers/modeling_utils.py#L794 can do this. It just returns the same logits back right? What kind of operation in this method？ <|||||>That method is now called `adjust_logits_during_generation`.
It's overwritten for bart:
https://github.com/huggingface/transformers/blob/482a5993c20ef32512a42661bfa404516763b72e/src/transformers/modeling_bart.py#L1028

and marian 
https://github.com/huggingface/transformers/blob/482a5993c20ef32512a42661bfa404516763b72e/src/transformers/modeling_marian.py#L49
<|||||>Hi @sshleifer  - Just a quick doubt. Why ```adjust_logits_during_generation``` is required for Bart. Is it because of any specific constraints the model is having?

What I have observed, the moment we disable it, generation is going haywire. 
I understood, its doing nothing more than forcing everything except 0 ( bos_token_id ) th index to be small or 0.0. But what is the logical reasoning behind it for Bart Model only. Its not applicable for all models ( say T5 ).