MCPcopy
hub / github.com/ModelTC/LightLLM / get_hidden_size

Function get_hidden_size

lightllm/utils/config_utils.py:17–33  ·  view source on GitHub ↗
(model_path: str)

Source from the content-addressed store, hash-verified

15
16
17def get_hidden_size(model_path: str) -> Optional[int]:
18 # try to get hidden_size in config.json
19 config_json = get_config_json(model_path)
20 try:
21 hidden_size = config_json["hidden_size"]
22 except:
23 # for some multimodal model
24 try:
25 hidden_size = config_json["llm_config"]["hidden_size"]
26 except:
27 hidden_size = config_json.get("text_config", {}).get("hidden_size")
28
29 if isinstance(hidden_size, int):
30 return hidden_size
31
32 logger.error("cannot get hidden size from config.json, return None instead")
33 return None
34
35
36def get_eos_token_ids(model_path: str):

Callers 1

Calls 2

get_config_jsonFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected