Initialize n-best list of hypotheses.
(self, num_beams, max_length, length_penalty, early_stopping)
| 947 | |
| 948 | class BeamHypotheses(object): |
| 949 | def __init__(self, num_beams, max_length, length_penalty, early_stopping): |
| 950 | """ |
| 951 | Initialize n-best list of hypotheses. |
| 952 | """ |
| 953 | self.max_length = max_length - 1 # ignoring bos_token |
| 954 | self.length_penalty = length_penalty |
| 955 | self.early_stopping = early_stopping |
| 956 | self.num_beams = num_beams |
| 957 | self.beams = [] |
| 958 | self.worst_score = 1e9 |
| 959 | |
| 960 | def __len__(self): |
| 961 | """ |
nothing calls this directly
no outgoing calls
no test coverage detected