MCPcopy
hub / github.com/zai-org/ChatGLM3 / InvalidScoreLogitsProcessor

Class InvalidScoreLogitsProcessor

openai_api_demo/utils.py:9–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7
8
9class InvalidScoreLogitsProcessor(LogitsProcessor):
10 def __call__(
11 self, input_ids: torch.LongTensor, scores: torch.FloatTensor
12 ) -> torch.FloatTensor:
13 if torch.isnan(scores).any() or torch.isinf(scores).any():
14 scores.zero_()
15 scores[..., 5] = 5e4
16 return scores
17
18
19def process_response(output: str, use_tool: bool = False) -> Union[str, dict]:

Callers 1

generate_stream_chatglm3Function · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected