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

Function get_context_length

fastchat/utils.py:332–344  ·  view source on GitHub ↗

Get the context length of a model from a huggingface model config.

(config)

Source from the content-addressed store, hash-verified

330
331
332def get_context_length(config):
333 """Get the context length of a model from a huggingface model config."""
334 rope_scaling = getattr(config, "rope_scaling", None)
335 if rope_scaling:
336 rope_scaling_factor = config.rope_scaling["factor"]
337 else:
338 rope_scaling_factor = 1
339
340 for key in SEQUENCE_LENGTH_KEYS:
341 val = getattr(config, key, None)
342 if val is not None:
343 return int(rope_scaling_factor * val)
344 return 2048
345
346
347def str_to_torch_dtype(dtype: str):

Callers 5

__init__Method · 0.90
lightllm_worker.pyFile · 0.90
__init__Method · 0.90
__init__Method · 0.90
chat_loopFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…