(logits: np.ndarray)
| 13355 | |
| 13356 | @staticmethod |
| 13357 | def logits_to_logprobs(logits: np.ndarray) -> np.ndarray: |
| 13358 | logits = logits.astype(np.float32, copy=False) |
| 13359 | max_logit = float(np.max(logits)) |
| 13360 | shifted = logits - max_logit |
| 13361 | return shifted - math.log(float(np.sum(np.exp(shifted, dtype=np.float64)))) |
| 13362 | |
| 13363 | def step(self) -> bool: |
| 13364 | step_started_at = time.perf_counter() |