During generation, decide whether to pass the `past` variable to the next forward pass.
(self, outputs, use_cache)
| 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). """ |
no outgoing calls
no test coverage detected