kempnerforge.config.adapter¶
Adapter (connector) configuration.
AdapterConfig selects which adapter the VLM wrapper instantiates and
parameterizes the chosen adapter. Dispatched via the adapter registry
at build time (see kempnerforge/model/adapter.py).
In TOML, [adapter] is a top-level section parallel to [model],
[vision_encoder], and [vlm]. When [vlm] is set without an
[adapter] section, JobConfig materializes the default AdapterConfig.
Classes
Selects the adapter type and parameterizes it. |
- class kempnerforge.config.adapter.AdapterConfig[source]¶
Bases:
objectSelects the adapter type and parameterizes it.
- Fields:
- type: Registry key for the adapter builder. Projection adapters
"mlp_2layer"(default) /"linear"keep the token count; pooling adapters"avgpool"/"attentional_pool"reduce it.- hidden_dim: Hidden width for
mlp_2layer.0means “match out_dim”; ignored by the other types.- activation: Activation between the two MLP projections. One of
"gelu"(default),"silu","relu".mlp_2layeronly.- pool_window: Pooling kernel side for the pooling adapters (e.g.
2 for image 2×2,
3for video 3×3); ignored by projection adapters.- pool_heads: Number of attention heads for
attentional_pool; must divide the vision feature dim. Ignored by the other types.
- extra_kwargs()[source]¶
Builder kwargs beyond
in_dim/out_dim.hidden_dim=0is mapped toNoneso the adapter falls back to its own default (e.g.,out_dimforMLP2LayerAdapter). Pooling kwargs are always passed; projection builders swallow them via**_.
- output_num_tokens(num_input_tokens)[source]¶
Predict the post-adapter token count for
num_input_tokensin.Mirrors the built module’s
output_num_tokensso config-time sequence-length checks match the build-time/runtime token budget. Projection adapters are the identity; pooling adapters apply the sharedpooled_token_countmath. Non-positive inputs (e.g. thenum_tokens=0“infer at build time” sentinel) pass through.