MCPcopy
hub / github.com/lm-sys/FastChat / prepare_logits_processor

Function prepare_logits_processor

fastchat/serve/inference.py:45–58  ·  view source on GitHub ↗
(
    temperature: float, repetition_penalty: float, top_p: float, top_k: int
)

Source from the content-addressed store, hash-verified

43
44
45def prepare_logits_processor(
46 temperature: float, repetition_penalty: float, top_p: float, top_k: int
47) -> LogitsProcessorList:
48 processor_list = LogitsProcessorList()
49 # TemperatureLogitsWarper doesn't accept 0.0, 1.0 makes it a no-op so we skip two cases.
50 if temperature >= 1e-5 and temperature != 1.0:
51 processor_list.append(TemperatureLogitsWarper(temperature))
52 if repetition_penalty > 1.0:
53 processor_list.append(RepetitionPenaltyLogitsProcessor(repetition_penalty))
54 if 1e-8 <= top_p < 1.0:
55 processor_list.append(TopPLogitsWarper(top_p))
56 if top_k > 0:
57 processor_list.append(TopKLogitsWarper(top_k))
58 return processor_list
59
60
61@torch.inference_mode()

Callers 1

generate_streamFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…