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

Method add

bert/generation_utils.py:966–978  ·  view source on GitHub ↗

Add a new hypothesis to the list.

(self, hyp, sum_logprobs)

Source from the content-addressed store, hash-verified

964 return len(self.beams)
965
966 def add(self, hyp, sum_logprobs):
967 """
968 Add a new hypothesis to the list.
969 """
970 score = sum_logprobs / len(hyp) ** self.length_penalty
971 if len(self) < self.num_beams or score > self.worst_score:
972 self.beams.append((score, hyp))
973 if len(self) > self.num_beams:
974 sorted_scores = sorted([(s, idx) for idx, (s, _) in enumerate(self.beams)])
975 del self.beams[sorted_scores[0][1]]
976 self.worst_score = sorted_scores[1][0]
977 else:
978 self.worst_score = min(score, self.worst_score)
979
980 def is_done(self, best_sum_logprobs, cur_len):
981 """

Callers 3

setup_loggerFunction · 0.80
get_pairsFunction · 0.80
_generate_beam_searchMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected