Download benchmarks/config.py from Pulsar-Dynamic-Technologies/Adria: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/Pulsar-Dynamic-Technologies/Adria/resolve/main/benchmarks/config.py
- Command line
-
hf download hf://Pulsar-Dynamic-Technologies/Adria/benchmarks/config.py
-
curl -L -o config.py https://huggingface.co/Pulsar-Dynamic-Technologies/Adria/resolve/main/benchmarks/config.py
1.45 kB
| import json | |
| from pathlib import Path | |
| CONFIGS_PATH = Path(__file__).parent / "configs.json" | |
| def _load_all() -> dict: | |
| if CONFIGS_PATH.exists(): | |
| with open(CONFIGS_PATH) as f: | |
| return json.load(f) | |
| return {} | |
| def load_config(model_name: str, n_params: int) -> dict: | |
| """ | |
| Load saved kwargs for (model_name, n_params). | |
| Raises KeyError if no config has been saved yet for this combination. | |
| config_ui.py should be run to generate these configs. | |
| :param model_name: The name of the model to load the config for. | |
| :param n_params: The parameter count to load the config for. | |
| :return: The kwargs dictionary for that model config | |
| """ | |
| configs = _load_all() | |
| model_configs = configs.get(model_name) | |
| if model_configs is None: | |
| raise KeyError(f"No config for {model_name}") | |
| key = str(n_params) | |
| if key not in model_configs: | |
| raise KeyError(f"No config for {model_name} with param count {n_params}") | |
| return dict(model_configs[key]) | |
| def has_config(model_name: str, n_params: int) -> bool: | |
| """ | |
| Returns true if a saved config exists for (model_name, n_params). | |
| :param model_name: The name of the model to check for the config for. | |
| :param n_params: The parameter count to check for the config for. | |
| :return: True if the config exists for (model_name, n_params). | |
| """ | |
| configs = _load_all() | |
| return str(n_params) in configs.get(model_name, {}) | |