MCPcopy Create free account
hub / github.com/SooLab/CGFormer / _use_cache

Method _use_cache

bert/generation_utils.py:39–45  ·  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

37 return logits
38
39 def _use_cache(self, outputs, use_cache):
40 """During generation, decide whether to pass the `past` variable to the next forward pass."""
41 if len(outputs) <= 1 or use_cache is False:
42 return False
43 if hasattr(self.config, "mem_len") and self.config.mem_len == 0:
44 return False
45 return True
46
47 def enforce_repetition_penalty_(self, lprobs, batch_size, num_beams, prev_output_tokens, repetition_penalty):
48 """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