Expand description
Encoder-model configuration: config.json → the declarative fields the encoder executor
branches on.
The “any embedding model” contract: the executor never matches on EncArch — only on
PosKind, NormKind, MlpKind, MaskKind, the per-layer layer_window, and the
Pooling mode. Supporting a new encoder architecture is therefore
(1) one EncArch variant + one from_json arm mapping its HF config keys onto these fields,
and (2) one tensor-name table in the weight loader. Anything a config asks for that the fields
cannot express is refused loudly at parse time — never silently mis-computed.
Structs§
- EncBatch
- A ragged batch of token sequences:
tokensis every sequence concatenated,seq_starts(lengthB+1) delimits them. No padding exists anywhere — attention masking is exact by construction because kernels iterateseq_starts[s]..seq_starts[s+1]. - Encoder
Config - Encoder hyper-parameters — the declarative surface the executor and loaders consume.
- RelAttn
- DeBERTa’s disentangled (relative) attention. On top of the usual content→content term, the
score gains a content→position (
c2p) and a position→content (p2c) term, both indexed by a LOG-BUCKETED relative distance: - Siglip
Vision Spec - Vision-tower spec: the declarative config plus the patch geometry the preprocessing needs.
Enums§
- Act
- Activation function (shared by the GEMM epilogue and the GLU split kernel).
- EncArch
- Which encoder architecture the checkpoint is (drives tensor names at load; NOT executor logic).
- Mask
Kind - Attention mask mode.
- MlpKind
- Feed-forward block shape.
- Norm
Kind - Normalization operator.
- PosKind
- Position-information scheme.
Functions§
- encoder_
arch - Map an HF
architectures[0]name to its encoder family, if it is one. - encoder_
config_ from_ dir - Resolve a checkpoint DIRECTORY to an encoder configuration: encoder architectures parse via
EncoderConfig::from_json(the pooling marker, when present, overrides the per-arch default); decoder architectures are accepted only with an explicit embedder marker —Qwen3ForCausalLM+pooling_mode_lasttokenis Qwen3-Embedding. Everything else refuses loudly: a generation checkpoint must never be silently embedded. - pooling_
marker - Read the sentence-transformers pooling marker (
1_Pooling/config.json) from a checkpoint directory, if present. This is the data-driven signal that turns a decoder-architecture checkpoint (e.g. Qwen3-Embedding, whoseconfig.jsonsaysQwen3ForCausalLM) into an EMBEDDER — no per-model special-casing. - siglip_
configs_ from_ dir - Detect a SigLIP checkpoint directory (joint text+vision
config.json;architecturesmay be absent —model_type: "siglip"/"siglip2"is the signal) and return both tower configs. - siglip_
text_ config - Build the SigLIP TEXT-tower config from the joint
config.json(HFSiglipConfigdefaults apply when the sub-config omits keys — verified against google/siglip2-base-patch16-224). Text tower: learned positions (offset 0, no embedding-stage norm), biased pre-LN layers,final_layer_norm, last-token pooling followed by theheadprojection. NOTE the canonical SigLIP text tower attends WITHOUT a padding mask — the adapter pads tomax_posand the final (padded) position is the pooled token, exactly as trained. - siglip_
vision_ config - Build the SigLIP VISION-tower config: 2D patch embedding (
image_size/patch_size⇒(image/patch)²positions), learned per-patch positions, biased pre-LN layers,post_layernorm, MAP attention-pooling head.