Encoders¶
Select a frozen encoder by name: FeaturesConfig(encoder="uni2") in Python,
features.encoder.name in YAML. An encoder is a leaf of the encoder registry: a name
plus its params (output_variant, allow_non_recommended_settings).
Precision and batch size are execution settings (slide2vec’s
ExecutionOptions); Preprocessing controls image geometry.
Encoding methods
Single encoder — pick one preset from the model zoo below (the common case).
Composite (multi-encoder) — concatenate several presets into one richer per-position vector: details.
The run’s features are configured by soma.config.FeaturesConfig, which holds
the encoder leaf (soma.config.EncoderLeaf) next to slide2vec’s
PreprocessingConfig, ExecutionOptions and DenseOptions.
- class soma.config.FeaturesConfig(kind='cached', encoder=None, extraction=<factory>, execution=<factory>, dense=None, cache=<factory>, spacing_policy='strict')¶
Bases:
Editablefeatures: where a run’s features come from (ADR 0019).kind:cachedextracts once;livere-encodes the (augmented) pixels every step (grid shape).encoder: a slide2vec encoder orcomposite(Nonewhen the run is handed its features).extraction,executionanddenseare slide2vec’sPreprocessingConfig,ExecutionOptionsandDenseOptions, held as given; an unset tiling comes fromdense(grid) or the encoder preset.spacing_policy: native_if_coarserreads a coarser sample at its native spacing.
- class soma.config.EncoderLeaf(name, params=<factory>)¶
Bases:
ComponentThe frozen encoder: a slide2vec encoder, or
compositefor several concatenated.paramsare slide2vec’sModel.from_presetkeywords (output_variant,allow_non_recommended_settings), or the composite’s members (soma.models.encoders.CompositeParams); theencodersregistry validates them.
Model Zoo¶
Tile encoders are grouped by output dimension. Spacing is in µm/px; multiple
dimensions indicate output variants. soma.components("encoders") lists the
presets installed in slide2vec’s registry, each with its level; soma list
encoders --level tile prints one level.
Tile-level encoders¶
Preset |
Model |
Output dim |
Spacing |
|---|---|---|---|
|
384 |
|
|
|
384 |
|
|
|
384 / 768 |
|
|
|
512 |
|
|
|
768 |
|
|
|
768 |
|
|
|
768 |
|
|
|
768 / 1536 |
|
|
|
768 / 1536 |
|
|
|
1024 |
|
|
|
1024 |
|
|
|
1024 |
|
|
|
1024 / 2048 |
|
|
|
1024 |
|
|
|
1024 |
|
|
|
1024 |
|
|
|
1024 |
|
|
|
1280 / 2560 |
|
|
|
1280 / 2560 |
|
|
|
1536 |
|
|
|
1536 |
|
|
|
1536 |
|
|
|
1536 |
|
|
|
1536 / 3072 |
|
|
|
1536 |
|
|
|
1536 / 3072 |
|
|
|
3072 |
|
|
|
4608 |
|
Natural-image controls¶
Non-pathology baselines that share the tile-encoder interface, for measuring how much pathology pretraining contributes. Both are spacing agnostic, with 0.5 µm/px as the default; see Preprocessing for their tile sizes.
Preset |
Model |
Output dim |
Spacing |
|---|---|---|---|
|
768 |
|
|
|
768 |
|
DINOv3 uses patch_mean pooling by default; select
encoder.output_variant: cls for its class-token output.
Slide-level encoders¶
Patient-level encoders¶
Preset |
Model |
Tile encoder |
Output dim |
|---|---|---|---|
|
|
768 |
Set features.extraction.tiling.requested_spacing_um explicitly for encoders with multiple
recommended spacings. For a single recommended spacing, soma can fill it in.
Configuration and runtime validation check the final combination.
Resolving a fixed benchmark MIL recipe¶
A slide-level benchmark that accepts both tile- and slide-level encoders can
use soma.models.encoders.resolve_aggregator() when it builds each
ExperimentConfig. The helper returns the supplied aggregator leaf for a
tile encoder and None for a slide encoder, allowing the existing slide
representation path to pass the embedding directly to the task head. Patient
encoders are rejected because their representations are not slide-level.