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

Method is_done

bert/generation_utils.py:980–993  ·  view source on GitHub ↗

If there are enough hypotheses and that none of the hypotheses being generated can become better than the worst one in the heap, then we are done with this sentence.

(self, best_sum_logprobs, cur_len)

Source from the content-addressed store, hash-verified

978 self.worst_score = min(score, self.worst_score)
979
980 def is_done(self, best_sum_logprobs, cur_len):
981 """
982 If there are enough hypotheses and that none of the hypotheses being generated
983 can become better than the worst one in the heap, then we are done with this sentence.
984 """
985
986 if len(self) < self.num_beams:
987 return False
988 elif self.early_stopping:
989 return True
990 else:
991 cur_score = best_sum_logprobs / cur_len ** self.length_penalty
992 ret = self.worst_score >= cur_score
993 return ret

Callers 1

_generate_beam_searchMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected