MCPcopy Create free account
hub / github.com/huggingface/transformers / _use_cache

Method _use_cache

src/transformers/modeling_utils.py:810–816  ·  view source on GitHub ↗

During generation, decide whether to pass the `past` variable to the next forward pass.

(self, outputs, use_cache)

Source from the content-addressed store, hash-verified

808 return logits
809
810 def _use_cache(self, outputs, use_cache):
811 """During generation, decide whether to pass the `past` variable to the next forward pass."""
812 if len(outputs) <= 1 or use_cache is False:
813 return False
814 if hasattr(self.config, "mem_len") and self.config.mem_len == 0:
815 return False
816 return True
817
818 def enforce_repetition_penalty_(self, lprobs, batch_size, num_beams, prev_output_tokens, repetition_penalty):
819 """repetition penalty (from CTRL paper https://arxiv.org/abs/1909.05858). """

Callers 2

_generate_beam_searchMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected