Configs API
Model-size presets and helpers shared across every architecture. Two registries are provided:
medlatents.configs.MODEL_CONFIGS– a dictionary keyed by lowercase size names ("nano","small","base","large","xl") whose values are plaindictobjects withhidden_size,depth, andnum_heads. This is the registry used throughout the examples and is the most convenient to splat into model constructors.medlatents.configs.MODEL_SIZES– a dictionary keyed by capitalized short names ("Nano","S","B","L","XL") whose values areModelSizedataclasses. The two registries are numerically consistent.
from medlatents import AutoregressiveTransformer
from medlatents.configs import MODEL_CONFIGS
cfg = MODEL_CONFIGS["nano"]
model = AutoregressiveTransformer(
seq_length=256,
vocab_size=512,
hidden_size=cfg["hidden_size"],
depth=cfg["depth"],
num_heads=cfg["num_heads"],
)
Registries
- medlatents.configs.MODEL_CONFIGS
dict[str, dict[str, int]]keyed bynano/small/base/large/xl; each value provideshidden_size,depthandnum_heads.
- medlatents.configs.MODEL_SIZES
dict[str, ModelSize]keyed byNano/S/B/L/XL(dataclass view, numerically consistent withMODEL_CONFIGS).
- medlatents.configs.MODEL_TYPES
List of supported
model_typestrings.
Data Classes and Helpers
- class medlatents.configs.ModelSize(depth, hidden_size, num_heads)[source][source]
Bases:
objectStandard transformer model size configuration.
- medlatents.configs.create_model_variants(model_cls, base_name, sizes=None, **default_kwargs)[source][source]
Generate model size variants (Nano/S/B/L/XL) for a model class.
- Parameters:
- Return type:
- Returns:
Dictionary mapping variant names to factory functions
Example
>>> variants = create_model_variants(AutoregressiveTransformer, "Autoreg") >>> model = variants["Autoreg-S"](seq_length=1024, vocab_size=512)