maxframe.learn.contrib.llm.text.embed#
- maxframe.learn.contrib.llm.text.embed(series, model: TextEmbeddingModel, dimensions: int | None = None, encoding_format: str | None = None, simple_output: bool = False, params: Dict[str, Any] | None = None, index=None, *, input: str | None = None, **kw)[source]#
Embed text content in a series using a text embedding model.
- Parameters:
series (Series or DataFrame) – A maxframe Series containing text data to be embedded, or a DataFrame used with
inputto render one text embedding request per row.model (TextEmbeddingModel) – Text embedding model instance used for generating embeddings.
dimensions (int, optional) – Dimensions of the embedding vectors. If not specified, uses model default.
encoding_format (str, optional) – Encoding format of the embedding (e.g., ‘float’, ‘base64’). If not specified, uses model default.
input (str, optional) – Text template used with DataFrame input. Use
{col_name}as a placeholder to reference input columns.simple_output (bool, optional) – Whether to return the embedding data directly without additional metadata, by default False.
params (Dict[str, Any], optional) – Additional parameters for embedding configuration, by default None. Can include model-specific settings.
index (array-like, optional) – Index for the output series, by default None, will generate new index.
- Returns:
A DataFrame containing the generated embeddings and success status. Columns include ‘response’ (embedding vectors) and ‘success’ (boolean status). If ‘success’ is False, the ‘response’ column will contain error information instead of the expected output.
- Return type:
Examples
>>> from maxframe.learn.contrib.llm.models.managed import ManagedTextEmbeddingModel >>> import maxframe.dataframe as md >>> >>> # Initialize the embedding model >>> embedding_model = ManagedTextEmbeddingModel(name="text-embedding-ada-002") >>> >>> # Create sample data >>> texts = md.Series([ ... "Machine learning is a powerful technology.", ... "Natural language processing enables computers to understand text.", ... "Deep learning uses neural networks for pattern recognition." ... ]) >>> >>> # Generate embeddings >>> result = embed(texts, embedding_model, simple_output=True) >>> result.execute()
Notes
Preview: This API is in preview state and may be unstable. The interface may change in future releases.