(model_path: str)
| 15 | |
| 16 | |
| 17 | def 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 | |
| 36 | def get_eos_token_ids(model_path: str): |
no test coverage detected