personalitylinmult.inference.registry

Resolve a model name to its checkpoint and load a predictor.

Deployment surfaces (a Gradio dropdown, a CLI --model flag) select a model by a short name — "AVT" or "A" — rather than a checkpoint path. This module holds that name-to-checkpoint mapping and hands back a ready FiPredictor, caching each so a repeated selection does not reload from disk.

Attributes

logger

Module-level logger.

Classes

ModelSpec

One registered model.

ModelRegistry

A name-keyed set of models, loaded on demand and cached.

Module Contents

personalitylinmult.inference.registry.logger

Module-level logger.

class personalitylinmult.inference.registry.ModelSpec[source]

One registered model.

Parameters:
  • name (str) – Short selector, e.g. "AVT" or "A".

  • checkpoint (Path) – Path to its .ckpt.

  • description (str) – One-line human summary shown in a UI.

class personalitylinmult.inference.registry.ModelRegistry(specs: list[ModelSpec])[source]

A name-keyed set of models, loaded on demand and cached.

Parameters:

specs (list[ModelSpec]) – The registered models.

Raises:

ValueError – If two specs share a name.

property names: list[str]

The registered model names, in insertion order.

spec(name: str) → ModelSpec[source]

Return the spec for a name.

Parameters:

name (str) – A registered model name.

Returns:

Its spec.

Return type:

ModelSpec

Raises:

KeyError – If the name is not registered.

load(name: str) → personalitylinmult.inference.predictor.FiPredictor[source]

Load (or return the cached) predictor for a name.

Parameters:

name (str) – A registered model name.

Returns:

The predictor.

Return type:

FiPredictor

Raises:
  • KeyError – If the name is not registered.

  • FileNotFoundError – If its checkpoint is missing.

classmethod from_checkpoints(checkpoints: dict[str, pathlib.Path | str]) → ModelRegistry[source]

Build a registry from a {name: checkpoint_path} mapping.

Parameters:

checkpoints (dict[str, Path | str]) – Name-to-path mapping.

Returns:

The registry (paths are not opened until load(), so a missing file surfaces at load time, not here).

Return type:

ModelRegistry