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 name attribute selects the registered model class (case-insensitively); the whole config is passed to that class’s from_config.

Returns:

The model instance built by the selected class’s from_config, with the add-ons the config’s extra asks for (see prepare_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 with name: d4 (default) or name: d3 plus the options of DFTD4 / DFTD3, or True for the PBE0-D4 defaults) wraps the model with the dispersion correction (D4Dispersion or D3Dispersion); "long_range" (a dict of LatentEwald options, or True for 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:

InteratomicPotential

Raises:

KeyError – If cfg.name does not match any registered model.