Skip to main content

Python class

EmbeddingsContext

EmbeddingsContextโ€‹

class max.interfaces.EmbeddingsContext(*args, **kwargs)

source

Bases: BaseContext, Protocol

Protocol defining the interface for embeddings generation contexts.

An EmbeddingsContext represents model inputs for embeddings generation pipelines, managing the state and parameters needed for generating embeddings from input text. Unlike text generation contexts, this focuses on single-step embedding generation without iterative token generation concerns.

This protocol includes only the fields necessary for embeddings generation, excluding text generation specific features like:

  • End-of-sequence token handling (eos_token_ids)
  • Grammar matchers for structured output (matcher)
  • JSON schema constraints (json_schema)
  • Log probability tracking (log_probabilities)
  • Token generation iteration state

model_nameโ€‹

property model_name: str

source

The name of the embeddings model to use.

Returns:

A string identifying the specific embeddings model for this request.

tokensโ€‹

property tokens: TokenBuffer

source

The input tokens to be embedded.

Returns:

A NumPy array of token IDs representing the input text to generate embeddings for.