Skip to content

Core API

Core types are the stable vocabulary shared by data modules, models, losses, metrics, and builders. `Batch` carries modality tensors and optional targets, masks, and metadata; `ModelOutput` carries predictions and auxiliary tensors. `ExperimentConfig` wraps YAML and supports validation and dotted overrides. The configuration guide explains how these objects appear in an experiment.

Batch and model output

chimera_ml.core.batch.Batch dataclass

Typed batch exchanged between data pipelines and models.

Attributes:

Name Type Description
inputs dict[str, Tensor]

Modality name to tensor mapping. A modality may be absent when a sample or model branch is unavailable.

targets Tensor | None

Task targets, or None for unlabeled inference/test data.

masks dict[str, Any] | None

Flat mask mapping such as sequence_mask or audio_mask.

meta dict[str, Any] | None

Optional sample IDs, lengths, and auxiliary metadata.

Use get_masks to read canonical masks; it also understands legacy nested mask mappings stored in meta.

get_masks

get_masks(mask_name=None)

Return all masks or one specific mask by name.

chimera_ml.core.types.ModelOutput dataclass

Standard model result consumed by losses, metrics, and callbacks.

Attributes:

Name Type Description
preds Tensor

Main predictions, such as class logits or regression values.

aux dict[str, Tensor] | None

Optional named tensors such as embeddings, modality predictions, or extracted features.

Experiment configuration

chimera_ml.core.config.ExperimentConfig dataclass

Mutable wrapper around an experiment YAML mapping.

The wrapper provides loading, serialization, validation, named-section access, and dotted-path overrides used by training and sweep flows.

Attributes:

Name Type Description
raw dict[str, Any]

Top-level experiment configuration mapping.

from_yaml classmethod

from_yaml(path)

Load an experiment config from a YAML file.

copy

copy()

Return a deep copy of this config wrapper.

to_yaml_text

to_yaml_text()

Serialize this config to YAML text.

to_yaml

to_yaml(path)

Write this config to a YAML file.

get

get(key, default=None)

Get a top-level config value with optional default.

section

section(key, *, name=None)

Return a config section handling dict and list-with-name formats.

validate

validate(*, require_experiment_name=True)

Return human-readable config validation errors.

set_at_path

set_at_path(path, value)

Set a config value using dotted paths and named list entries.

apply_overrides

apply_overrides(overrides)

Apply dotted-path config overrides in iteration order.

chimera_ml.core.config.load_yaml

load_yaml(path)

Load a YAML file and return its top-level mapping.

Parameters:

Name Type Description Default
path str

YAML file path.

required

Returns: Parsed YAML mapping. Schema validation is performed separately by ExperimentConfig.validate.

Registries

`Registry` maps a stable configuration key to a factory or class. Training, data, logging, and inference registries all use the same API; components are usually created through the relevant builder.

chimera_ml.core.registry.Registry

Name-to-factory registry used by configuration builders.

A registry owns unique string keys and returns the registered callable. Framework registries such as MODELS, LOSSES, CALLBACKS, and INFERENCE_STEPS share this contract.

register

register(key)

Return a decorator that registers a callable under key.

Raises:

Type Description
KeyError

If key is already registered.

get

get(key)

Return the callable registered under key.

Raises:

Type Description
KeyError

If key is unknown; the error lists known keys.

create

create(key, **kwargs)

Call the factory registered under key with keyword arguments.

Parameters:

Name Type Description Default
key str

Registry key.

required
kwargs Any

Factory arguments.

{}

Returns: Factory result.

keys

keys()

Return registered keys in deterministic sorted order.