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

AdapterConfig

Selects the adapter type and parameterizes it.

class kempnerforge.config.adapter.AdapterConfig[source]

Bases: object

Selects 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. 0 means “match

out_dim”; ignored by the other types.

activation: Activation between the two MLP projections. One of

"gelu" (default), "silu", "relu". mlp_2layer only.

pool_window: Pooling kernel side for the pooling adapters (e.g. 2

for image 2×2, 3 for 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.

type: str = 'mlp_2layer'
hidden_dim: int = 0
activation: str = 'gelu'
pool_window: int = 2
pool_heads: int = 16
extra_kwargs()[source]

Builder kwargs beyond in_dim / out_dim.

hidden_dim=0 is mapped to None so the adapter falls back to its own default (e.g., out_dim for MLP2LayerAdapter). Pooling kwargs are always passed; projection builders swallow them via **_.

Return type:

dict[str, Any]

output_num_tokens(num_input_tokens)[source]

Predict the post-adapter token count for num_input_tokens in.

Mirrors the built module’s output_num_tokens so config-time sequence-length checks match the build-time/runtime token budget. Projection adapters are the identity; pooling adapters apply the shared pooled_token_count math. Non-positive inputs (e.g. the num_tokens=0 “infer at build time” sentinel) pass through.

Parameters:

num_input_tokens (int)

Return type:

int

__init__(type='mlp_2layer', hidden_dim=0, activation='gelu', pool_window=2, pool_heads=16)
Parameters:
  • type (str)

  • hidden_dim (int)

  • activation (str)

  • pool_window (int)

  • pool_heads (int)

Return type:

None