For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Python module
max.pipelines.lib.registration_encoder
Serves embedding architectures that register an ENCODER.
An encoder-only architecture registers its encoder module for the
ENCODER role, and encoder_pipeline_model() builds the pipeline
model: it finalizes the config, constructs the encoder as
encoder_cls(config), loads the checkpoint, builds the graph from
encoder_input_types(), and batches and executes it. The encoder takes
EncoderInputs and returns the embeddings: a graph-API
(max.nn.legacy.Module) encoder in its __call__, over graph
values, and a ModuleV3 (max.nn.Module) encoder in its
forward, over tensors.
An encoder takes its batch in one of two layouts, which its class picks:
- padded (the default):
tokensand anattention_mask, both[batch_size, seq_len]; - ragged, when it sets
ragged_batch = True:tokens,input_row_offsetsandreturn_n_logits, as a ragged decoder takes them but with no KV cache.
A registered encoder class can also set graph_name, the name its graph
compiles under. A graph-API encoder can set strict_state_dict_loading,
override_quantization_encoding and weight_alignment, the options it
loads the checkpoint with, which an instance may also set from its config.
A graph-API encoder whose graph predates registration with input types
other than its layout’s defines legacy_input_types(), which returns
them in field order, so its precompiled MEFs keep their key.
A ModuleV3 encoder is built under the pipeline’s dtype and moved to its
device, and the checkpoint’s float32 and bfloat16 weights are cast
to the dtypes its parameters declare.
Pipeline models
EncoderPipelineModel | Serves a registered ENCODER module. |
|---|---|
GraphApiEncoderPipelineModel | Serves a registered graph-API ENCODER module. |
ModuleV3EncoderPipelineModel | Serves a registered ModuleV3 ENCODER module. |
encoder_pipeline_model | Returns the pipeline model that serves an ENCODER registration. |
|---|
Encoder inputs
EncoderInputs | The inputs of an ENCODER module's __call__. |
|---|---|
PaddedEncoderInputs | The prepared inputs of a padded ENCODER. |
RaggedEncoderInputs | The prepared inputs of a ragged ENCODER. |
Batch processors
PaddedEncoderProcessor | Pads a batch of text for a registered padded ENCODER. |
|---|---|
RaggedEncoderProcessor | Batches ragged text for a registered ragged ENCODER. |
Graph input types
encoder_input_types | Returns an ENCODER graph's input types, keyed by field, in order. |
|---|