xnn.common.models.registry.build_model#
- xnn.common.models.registry.build_model(cfg)[source]#
Instantiate a registered model from a configuration dataclass.
- Parameters:
cfg (ModelConfig) – The model configuration. Its
nameattribute selects the registered model class (case-insensitively); the whole config is passed to that class’sfrom_config.- Returns:
The model instance built by the selected class’s
from_config, with the add-ons the config’sextraasks for (seeprepare_model()): a"pretrained"source replaces the fresh build by the weights of any hub model;"lora"adapts the linear layers (inject_lora());"heads"gives the model several readout heads (MultiHead);"dispersion"(a dict withname: d4(default) orname: d3plus the options ofDFTD4/DFTD3, orTruefor the PBE0-D4 defaults) wraps the model with the dispersion correction (D4DispersionorD3Dispersion);"long_range"(a dict ofLatentEwaldoptions, orTruefor the defaults) wraps it with the Latent Ewald Summation long-range term. Dispersion is applied before LES, so LES sees the D4-corrected model’s features (they are passed through unchanged).- Return type:
- Raises:
KeyError – If
cfg.namedoes not match any registered model.