MCPcopy
hub / github.com/THUDM/LongWriter / InvalidScoreLogitsProcessor

Class InvalidScoreLogitsProcessor

train/patch/modeling_chatglm.py:59–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57
58
59class InvalidScoreLogitsProcessor(LogitsProcessor):
60 def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor:
61 if torch.isnan(scores).any() or torch.isinf(scores).any():
62 scores.zero_()
63 scores[..., 5] = 5e4
64 return scores
65
66def split_tensor_along_last_dim(
67 tensor: torch.Tensor,

Callers 1

chatMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected