MCPcopy Create free account
hub / github.com/THUDM/GLM / is_done

Method is_done

generation_utils.py:376–389  ·  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: float, cur_len: int)

Source from the content-addressed store, hash-verified

374 self.worst_score = min(score, self.worst_score)
375
376 def is_done(self, best_sum_logprobs: float, cur_len: int) -> bool:
377 """
378 If there are enough hypotheses and that none of the hypotheses being generated can become better than the worst
379 one in the heap, then we are done with this sentence.
380 """
381
382 if len(self) < self.num_beams:
383 return False
384 elif self.early_stopping:
385 return True
386 else:
387 cur_score = best_sum_logprobs / cur_len ** self.length_penalty
388 ret = self.worst_score >= cur_score
389 return ret
390
391
392class LogitsProcessor(ABC):

Callers 1

processMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected