Initialize n-best list of hypotheses.
(self, num_beams: int, max_length: int, length_penalty: float, early_stopping: bool)
| 343 | |
| 344 | class BeamHypotheses: |
| 345 | def __init__(self, num_beams: int, max_length: int, length_penalty: float, early_stopping: bool): |
| 346 | """ |
| 347 | Initialize n-best list of hypotheses. |
| 348 | """ |
| 349 | self.max_length = max_length - 1 # ignoring bos_token |
| 350 | self.length_penalty = length_penalty |
| 351 | self.early_stopping = early_stopping |
| 352 | self.num_beams = num_beams |
| 353 | self.beams = [] |
| 354 | self.worst_score = 1e9 |
| 355 | |
| 356 | def __len__(self): |
| 357 | """ |
nothing calls this directly
no outgoing calls
no test coverage detected