github.com
  
  
    huggingface/transformers/blob/master/src/transformers/modeling_bart.py#L1100 3

):
    return {
        "input_ids": None,  # encoder_outputs is defined. input_ids not needed
        "encoder_outputs": encoder_outputs,
        "past_key_values": past,
        "decoder_input_ids": decoder_input_ids,
        "attention_mask": attention_mask,
        "use_cache": use_cache,  # change this to avoid caching (presumably for debugging)
    }

def adjust_logits_during_generation(self, logits, cur_len, max_length):
    if cur_len == 1 and self.config.force_bos_token_to_be_generated:
        self._force_token_id_to_be_generated(logits, self.config.bos_token_id)
    elif cur_len == max_length - 1 and self.config.eos_token_id is not None:
        self._force_token_id_to_be_generated(logits, self.config.eos_token_id)
    return logits

@staticmethod
def _force_token_id_to_be_generated(scores, token_id) -> None:
    """force one of token_ids to be generated by setting prob of all other tokens to 0 (logprob=-float("inf"))"""
    scores[:, [x for x in range(scores.shape[1]) if x != token_id]] = -float("inf")



  
  
    
    
  
  


in the future git grep adjust_logits_during_generation