MiniMaxEmbeddings#

class langchain_community.embeddings.minimax.MiniMaxEmbeddings[source]#

Bases: BaseModel, Embeddings

MiniMax embedding model integration.

Setup:

To use, you should have the environment variable MINIMAX_GROUP_ID and MINIMAX_API_KEY set with your API token.

export MINIMAX_API_KEY="your-api-key"
export MINIMAX_GROUP_ID="your-group-id"
Key init args — completion params:
model: Optional[str]

Name of ZhipuAI model to use.

api_key: Optional[str]

Automatically inferred from env var MINIMAX_GROUP_ID if not provided.

group_id: Optional[str]

Automatically inferred from env var MINIMAX_GROUP_ID if not provided.

See full list of supported init args and their descriptions in the params section.

Instantiate:

from langchain_community.embeddings import MiniMaxEmbeddings

embed = MiniMaxEmbeddings(
    model="embo-01",
    # api_key="...",
    # group_id="...",
    # other
)
Embed single text:
input_text = "The meaning of life is 42"
embed.embed_query(input_text)
[0.03016241, 0.03617699, 0.0017198119, -0.002061239, -0.00029994643, -0.0061320597, -0.0043635326, ...]
Embed multiple text:
input_texts = ["This is a test query1.", "This is a test query2."]
embed.embed_documents(input_texts)
[
    [-0.0021588828, -0.007608119, 0.029349545, -0.0038194496, 0.008031177, -0.004529633, -0.020150753, ...],
    [ -0.00023150232, -0.011122423, 0.016930554, 0.0083089275, 0.012633711, 0.019683322, -0.005971041, ...]
]

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

param embed_type_db: str = 'db'#

For embed_documents

param embed_type_query: str = 'query'#

For embed_query

param endpoint_url: str = 'https://api.minimax.chat/v1/embeddings'#

Endpoint URL to use.

param minimax_api_key: SecretStr | None = None (alias 'api_key')#

API Key for MiniMax API.

param minimax_group_id: str | None = None (alias 'group_id')#

Group ID for MiniMax API.

param model: str = 'embo-01'#

Embeddings model name to use.

async aembed_documents(texts: list[str]) list[list[float]]#

Asynchronous Embed search docs.

Parameters:

texts (list[str]) – List of text to embed.

Returns:

List of embeddings.

Return type:

list[list[float]]

async aembed_query(text: str) list[float]#

Asynchronous Embed query text.

Parameters:

text (str) – Text to embed.

Returns:

Embedding.

Return type:

list[float]

embed(texts: List[str], embed_type: str) List[List[float]][source]#
Parameters:
  • texts (List[str])

  • embed_type (str)

Return type:

List[List[float]]

embed_documents(texts: List[str]) List[List[float]][source]#

Embed documents using a MiniMax embedding endpoint.

Parameters:

texts (List[str]) – The list of texts to embed.

Returns:

List of embeddings, one for each text.

Return type:

List[List[float]]

embed_query(text: str) List[float][source]#

Embed a query using a MiniMax embedding endpoint.

Parameters:

text (str) – The text to embed.

Returns:

Embeddings for the text.

Return type:

List[float]

classmethod validate_environment(values: Dict) Dict[source]#

Validate that group id and api key exists in environment.

Parameters:

values (Dict)

Return type:

Dict

Examples using MiniMaxEmbeddings