Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
OurBuilding Ambient Agents with LangGraph course is now available on LangChain Academy!
Open In ColabOpen on GitHub

MiniMax

MiniMax offers an embeddings service.

This example goes over how to use LangChain to interact with MiniMax Inference for text embedding.

import os

os.environ["MINIMAX_GROUP_ID"]="MINIMAX_GROUP_ID"
os.environ["MINIMAX_API_KEY"]="MINIMAX_API_KEY"
from langchain_community.embeddingsimport MiniMaxEmbeddings
API Reference:MiniMaxEmbeddings
embeddings= MiniMaxEmbeddings()
query_text="This is a test query."
query_result= embeddings.embed_query(query_text)
document_text="This is a test document."
document_result= embeddings.embed_documents([document_text])
import numpyas np

query_numpy= np.array(query_result)
document_numpy= np.array(document_result[0])
similarity= np.dot(query_numpy, document_numpy)/(
np.linalg.norm(query_numpy)* np.linalg.norm(document_numpy)
)
print(f"Cosine similarity between document and query:{similarity}")
Cosine similarity between document and query: 0.1573236279277012

Related


[8]ページ先頭

©2009-2025 Movatter.jp