Copy
---
title: MosaicML
---
>[MosaicML](https://docs.mosaicml.com/en/latest/inference.html)은 관리형 추론 서비스를 제공합니다. 다양한 오픈소스 모델을 사용하거나 자체 모델을 배포할 수 있습니다.
이 예제는 LangChain을 사용하여 텍스트 임베딩을 위한 `MosaicML` Inference와 상호작용하는 방법을 다룹니다.
```python
# sign up for an account: https://forms.mosaicml.com/demo?utm_source=langchain
from getpass import getpass
MOSAICML_API_TOKEN = getpass()
Copy
import os
os.environ["MOSAICML_API_TOKEN"] = MOSAICML_API_TOKEN
Copy
from langchain_community.embeddings import MosaicMLInstructorEmbeddings
Copy
embeddings = MosaicMLInstructorEmbeddings(
query_instruction="Represent the query for retrieval: "
)
Copy
query_text = "This is a test query."
query_result = embeddings.embed_query(query_text)
Copy
document_text = "This is a test document."
document_result = embeddings.embed_documents([document_text])
Copy
import numpy as 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}")
Copy
---
<Callout icon="pen-to-square" iconType="regular">
[Edit the source of this page on GitHub.](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/text_embedding/mosaicml.mdx)
</Callout>
<Tip icon="terminal" iconType="regular">
[Connect these docs programmatically](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
</Tip>