> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langchain.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Embedding model integrations

> Integrate with embedding models using LangChain Python.

## Overview

<Note>
  This overview covers **text-based embedding models**. LangChain does not currently support multimodal embeddings.

  See [top embedding models](#top-integrations).
</Note>

Embedding models transform raw text—such as a sentence, paragraph, or tweet—into a fixed-length vector of numbers that captures its **semantic meaning**. These vectors allow machines to compare and search text based on meaning rather than exact words.

In practice, this means that texts with similar ideas are placed close together in the vector space. For example, instead of matching only the phrase *"machine learning"*, embeddings can surface documents that discuss related concepts even when different wording is used.

### How it works

1. **Vectorization** — The model encodes each input string as a high-dimensional vector.
2. **Similarity scoring** — Vectors are compared using mathematical metrics to measure how closely related the underlying texts are.

### Similarity metrics

Several metrics are commonly used to compare embeddings:

* **Cosine similarity** — measures the angle between two vectors.
* **Euclidean distance** — measures the straight-line distance between points.
* **Dot product** — measures how much one vector projects onto another.

Here's an example of computing cosine similarity between two vectors:

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import numpy as np

def cosine_similarity(vec1, vec2):
    dot = np.dot(vec1, vec2)
    return dot / (np.linalg.norm(vec1) * np.linalg.norm(vec2))

similarity = cosine_similarity(query_embedding, document_embedding)
print("Cosine Similarity:", similarity)
```

## Interface

LangChain provides a standard interface for text embedding models (e.g., OpenAI, Cohere, Hugging Face) via the [Embeddings](https://reference.langchain.com/python/langchain-core/embeddings/embeddings/Embeddings) interface.

Two main methods are available:

* `embed_documents(texts: List[str]) → List[List[float]]`: Embeds a list of documents.
* `embed_query(text: str) → List[float]`: Embeds a single query.

<Note>
  The interface allows queries and documents to be embedded with different strategies, though most providers handle them the same way in practice.
</Note>

## Top integrations

| Model                                                                                      | Package                                                                                                                                                          |
| ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`OpenAIEmbeddings`](/oss/python/integrations/embeddings/openai)                           | [`langchain-openai`](https://reference.langchain.com/python/langchain-openai)                                                                                    |
| [`AzureOpenAIEmbeddings`](/oss/python/integrations/embeddings/azure_openai)                | [`langchain-openai`](https://reference.langchain.com/python/langchain-openai/embeddings/azure/AzureOpenAIEmbeddings)                                             |
| [`GoogleGenerativeAIEmbeddings`](/oss/python/integrations/embeddings/google_generative_ai) | [`langchain-google-genai`](https://reference.langchain.com/python/langchain-google-genai/embeddings/GoogleGenerativeAIEmbeddings)                                |
| [`OllamaEmbeddings`](/oss/python/integrations/embeddings/ollama)                           | [`langchain-ollama`](https://reference.langchain.com/python/langchain-ollama/embeddings/OllamaEmbeddings)                                                        |
| [`TogetherEmbeddings`](/oss/python/integrations/embeddings/together)                       | [`langchain-together`](https://reference.langchain.com/python/langchain-together/embeddings/TogetherEmbeddings)                                                  |
| [`FireworksEmbeddings`](/oss/python/integrations/embeddings/fireworks)                     | [`langchain-fireworks`](https://reference.langchain.com/python/langchain-fireworks/embeddings/FireworksEmbeddings)                                               |
| [`MistralAIEmbeddings`](/oss/python/integrations/embeddings/mistralai)                     | [`langchain-mistralai`](https://reference.langchain.com/python/langchain-mistralai/embeddings/MistralAIEmbeddings)                                               |
| [`VoyageAIEmbeddings`](/oss/python/integrations/embeddings/voyageai)                       | `langchain-voyageai`                                                                                                                                             |
| [`CohereEmbeddings`](/oss/python/integrations/embeddings/cohere)                           | [`langchain-cohere`](https://reference.langchain.com/python/langchain-community/llms/cohere/Cohere)                                                              |
| [`NomicEmbeddings`](/oss/python/integrations/embeddings/nomic)                             | [`langchain-nomic`](https://reference.langchain.com/python/langchain-nomic/embeddings/NomicEmbeddings)                                                           |
| [`FakeEmbeddings`](/oss/python/integrations/embeddings/fake)                               | [`langchain-core`](https://reference.langchain.com/python/langchain-core/embeddings/fake/FakeEmbeddings)                                                         |
| [`DatabricksEmbeddings`](/oss/python/integrations/embeddings/databricks)                   | [`databricks-langchain`](https://api-docs.databricks.com/python/databricks-ai-bridge/latest/databricks_langchain.html#databricks_langchain.DatabricksEmbeddings) |
| [`WatsonxEmbeddings`](/oss/python/integrations/embeddings/ibm_watsonx)                     | [`langchain-ibm`](https://reference.langchain.com/python/langchain-ibm/embeddings/WatsonxEmbeddings)                                                             |
| [`NVIDIAEmbeddings`](/oss/python/integrations/embeddings/nvidia_ai_endpoints)              | [`langchain-nvidia`](https://reference.langchain.com/python/langchain-nvidia-ai-endpoints/embeddings/NVIDIAEmbeddings)                                           |
| [`AIMLAPIEmbeddings`](/oss/python/integrations/embeddings/aimlapi)                         | `langchain-aimlapi`                                                                                                                                              |
| [`PerplexityEmbeddings`](/oss/python/integrations/embeddings/perplexity)                   | [`langchain-perplexity`](https://reference.langchain.com/python/langchain-perplexity/embeddings/PerplexityEmbeddings)                                            |

## Caching

Embeddings can be stored or temporarily cached to avoid needing to recompute them.

Caching embeddings can be done using a `CacheBackedEmbeddings`. This wrapper stores embeddings in a key-value store, where the text is hashed and the hash is used as the key in the cache.

The main supported way to initialize a `CacheBackedEmbeddings` is `from_bytes_store`. It takes the following parameters:

* **`underlying_embedder`**: The embedder to use for embedding.
* **`document_embedding_cache`**: Any [`ByteStore`](/oss/python/integrations/stores/) for caching document embeddings.
* **`batch_size`**: (optional, defaults to `None`) The number of documents to embed between store updates.
* **`namespace`**: (optional, defaults to `""`) The namespace to use for the document cache. Helps avoid collisions (e.g., set it to the embedding model name).
* **`query_embedding_cache`**: (optional, defaults to `None`) A [`ByteStore`](/oss/python/integrations/stores/) for caching query embeddings, or `True` to reuse the same store as `document_embedding_cache`.

<Important>
  - Always set the `namespace` parameter to avoid collisions when using different embedding models.
  - `CacheBackedEmbeddings` does not cache query embeddings by default. To enable this, specify a `query_embedding_cache`.
</Important>

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import time
from langchain_classic.embeddings import CacheBackedEmbeddings  # [!code highlight]
from langchain_classic.storage import LocalFileStore # [!code highlight]
from langchain_core.vectorstores import InMemoryVectorStore

# Create your underlying embeddings model
underlying_embeddings = ... # e.g., OpenAIEmbeddings(), HuggingFaceEmbeddings(), etc.

# Store persists embeddings to the local filesystem
# This isn't for production use, but is useful for local
store = LocalFileStore("./cache/") # [!code highlight]

cached_embedder = CacheBackedEmbeddings.from_bytes_store(
    underlying_embeddings,
    store,
    namespace=underlying_embeddings.model
)

# Example: caching a query embedding
tic = time.time()
print(cached_embedder.embed_query("Hello, world!"))
print(f"First call took: {time.time() - tic:.2f} seconds")

# Subsequent calls use the cache
tic = time.time()
print(cached_embedder.embed_query("Hello, world!"))
print(f"Second call took: {time.time() - tic:.2f} seconds")
```

In production, you would typically use a more robust persistent store, such as a database or cloud storage. Please see [stores integrations](/oss/python/integrations/stores/) for options.

## All embedding models

<Columns cols={3}>
  <Card title="Aleph Alpha" icon="link" href="/oss/python/integrations/embeddings/aleph_alpha" arrow="true" cta="View guide" />

  <Card title="Anyscale" icon="link" href="/oss/python/integrations/embeddings/anyscale" arrow="true" cta="View guide" />

  <Card title="Ascend" icon="link" href="/oss/python/integrations/embeddings/ascend" arrow="true" cta="View guide" />

  <Card title="AI/ML API" icon="link" href="/oss/python/integrations/embeddings/aimlapi" arrow="true" cta="View guide" />

  <Card title="AwaDB" icon="link" href="/oss/python/integrations/embeddings/awadb" arrow="true" cta="View guide" />

  <Card title="AzureOpenAI" icon="link" href="/oss/python/integrations/embeddings/azure_openai" arrow="true" cta="View guide" />

  <Card title="Baichuan Text Embeddings" icon="link" href="/oss/python/integrations/embeddings/baichuan" arrow="true" cta="View guide" />

  <Card title="Baidu Qianfan" icon="link" href="/oss/python/integrations/embeddings/baidu_qianfan_endpoint" arrow="true" cta="View guide" />

  <Card title="Baseten" icon="link" href="/oss/python/integrations/embeddings/baseten" arrow="true" cta="View guide" />

  <Card title="Bedrock" icon="link" href="/oss/python/integrations/embeddings/bedrock" arrow="true" cta="View guide" />

  <Card title="BGE on Hugging Face" icon="link" href="/oss/python/integrations/embeddings/bge_huggingface" arrow="true" cta="View guide" />

  <Card title="Bookend AI" icon="link" href="/oss/python/integrations/embeddings/bookend" arrow="true" cta="View guide" />

  <Card title="Clarifai" icon="link" href="/oss/python/integrations/embeddings/clarifai" arrow="true" cta="View guide" />

  <Card title="Cloudflare Workers AI" icon="link" href="/oss/python/integrations/embeddings/cloudflare_workersai" arrow="true" cta="View guide" />

  <Card title="Clova Embeddings" icon="link" href="/oss/python/integrations/embeddings/clova" arrow="true" cta="View guide" />

  <Card title="Cohere" icon="link" href="/oss/python/integrations/embeddings/cohere" arrow="true" cta="View guide" />

  <Card title="DashScope" icon="link" href="/oss/python/integrations/embeddings/dashscope" arrow="true" cta="View guide" />

  <Card title="Databricks" icon="link" href="/oss/python/integrations/embeddings/databricks" arrow="true" cta="View guide" />

  <Card title="DeepInfra" icon="link" href="/oss/python/integrations/embeddings/deepinfra" arrow="true" cta="View guide" />

  <Card title="EDEN AI" icon="link" href="/oss/python/integrations/embeddings/edenai" arrow="true" cta="View guide" />

  <Card title="Elasticsearch" icon="link" href="/oss/python/integrations/embeddings/elasticsearch" arrow="true" cta="View guide" />

  <Card title="Embaas" icon="link" href="/oss/python/integrations/embeddings/embaas" arrow="true" cta="View guide" />

  <Card title="Fake Embeddings" icon="link" href="/oss/python/integrations/embeddings/fake" arrow="true" cta="View guide" />

  <Card title="FastEmbed by Qdrant" icon="link" href="/oss/python/integrations/embeddings/fastembed" arrow="true" cta="View guide" />

  <Card title="Fireworks" icon="link" href="/oss/python/integrations/embeddings/fireworks" arrow="true" cta="View guide" />

  <Card title="Google Gemini" icon="link" href="/oss/python/integrations/embeddings/google_generative_ai" arrow="true" cta="View guide" />

  <Card title="Google Vertex AI" icon="link" href="/oss/python/integrations/embeddings/google_vertex_ai" arrow="true" cta="View guide" />

  <Card title="GPT4All" icon="link" href="/oss/python/integrations/embeddings/gpt4all" arrow="true" cta="View guide" />

  <Card title="Gradient" icon="link" href="/oss/python/integrations/embeddings/gradient" arrow="true" cta="View guide" />

  <Card title="GreenNode" icon="link" href="/oss/python/integrations/embeddings/greennode" arrow="true" cta="View guide" />

  <Card title="Hugging Face" icon="link" href="/oss/python/integrations/embeddings/huggingfacehub" arrow="true" cta="View guide" />

  <Card title="IBM watsonx.ai" icon="link" href="/oss/python/integrations/embeddings/ibm_watsonx" arrow="true" cta="View guide" />

  <Card title="Infinity" icon="link" href="/oss/python/integrations/embeddings/infinity" arrow="true" cta="View guide" />

  <Card title="Instruct Embeddings" icon="link" href="/oss/python/integrations/embeddings/instruct_embeddings" arrow="true" cta="View guide" />

  <Card title="IPEX-LLM CPU" icon="link" href="/oss/python/integrations/embeddings/ipex_llm" arrow="true" cta="View guide" />

  <Card title="IPEX-LLM GPU" icon="link" href="/oss/python/integrations/embeddings/ipex_llm_gpu" arrow="true" cta="View guide" />

  <Card title="Isaacus" icon="link" href="/oss/python/integrations/embeddings/isaacus" arrow="true" cta="View guide" />

  <Card title="Intel Extension for Transformers" icon="link" href="/oss/python/integrations/embeddings/itrex" arrow="true" cta="View guide" />

  <Card title="Jina" icon="link" href="/oss/python/integrations/embeddings/jina" arrow="true" cta="View guide" />

  <Card title="John Snow Labs" icon="link" href="/oss/python/integrations/embeddings/johnsnowlabs_embedding" arrow="true" cta="View guide" />

  <Card title="LASER" icon="link" href="/oss/python/integrations/embeddings/laser" arrow="true" cta="View guide" />

  <Card title="Lindorm" icon="link" href="/oss/python/integrations/embeddings/lindorm" arrow="true" cta="View guide" />

  <Card title="Llama.cpp" icon="link" href="/oss/python/integrations/embeddings/llamacpp" arrow="true" cta="View guide" />

  <Card title="LLMRails" icon="link" href="/oss/python/integrations/embeddings/llm_rails" arrow="true" cta="View guide" />

  <Card title="LocalAI" icon="link" href="/oss/python/integrations/embeddings/localai" arrow="true" cta="View guide" />

  <Card title="MiniMax" icon="link" href="/oss/python/integrations/embeddings/minimax" arrow="true" cta="View guide" />

  <Card title="MistralAI" icon="link" href="/oss/python/integrations/embeddings/mistralai" arrow="true" cta="View guide" />

  <Card title="Model2Vec" icon="link" href="/oss/python/integrations/embeddings/model2vec" arrow="true" cta="View guide" />

  <Card title="ModelScope" icon="link" href="/oss/python/integrations/embeddings/modelscope_embedding" arrow="true" cta="View guide" />

  <Card title="MosaicML" icon="link" href="/oss/python/integrations/embeddings/mosaicml" arrow="true" cta="View guide" />

  <Card title="Naver" icon="link" href="/oss/python/integrations/embeddings/naver" arrow="true" cta="View guide" />

  <Card title="Nebius" icon="link" href="/oss/python/integrations/embeddings/nebius" arrow="true" cta="View guide" />

  <Card title="Netmind" icon="link" href="/oss/python/integrations/embeddings/netmind" arrow="true" cta="View guide" />

  <Card title="NLP Cloud" icon="link" href="/oss/python/integrations/embeddings/nlp_cloud" arrow="true" cta="View guide" />

  <Card title="Nomic" icon="link" href="/oss/python/integrations/embeddings/nomic" arrow="true" cta="View guide" />

  <Card title="NVIDIA NIMs" icon="link" href="/oss/python/integrations/embeddings/nvidia_ai_endpoints" arrow="true" cta="View guide" />

  <Card title="Oracle Cloud Infrastructure" icon="link" href="/oss/python/integrations/embeddings/oci_generative_ai" arrow="true" cta="View guide" />

  <Card title="Ollama" icon="link" href="/oss/python/integrations/embeddings/ollama" arrow="true" cta="View guide" />

  <Card title="OpenClip" icon="link" href="/oss/python/integrations/embeddings/open_clip" arrow="true" cta="View guide" />

  <Card title="OpenAI" icon="link" href="/oss/python/integrations/embeddings/openai" arrow="true" cta="View guide" />

  <Card title="OpenVINO" icon="link" href="/oss/python/integrations/embeddings/openvino" arrow="true" cta="View guide" />

  <Card title="Optimum Intel" icon="link" href="/oss/python/integrations/embeddings/optimum_intel" arrow="true" cta="View guide" />

  <Card title="Oracle AI Database" icon="link" href="/oss/python/integrations/embeddings/oracleai" arrow="true" cta="View guide" />

  <Card title="OVHcloud" icon="link" href="/oss/python/integrations/embeddings/ovhcloud" arrow="true" cta="View guide" />

  <Card title="Pinecone Embeddings" icon="link" href="/oss/python/integrations/embeddings/pinecone" arrow="true" cta="View guide" />

  <Card title="PredictionGuard" icon="link" href="/oss/python/integrations/embeddings/predictionguard" arrow="true" cta="View guide" />

  <Card title="Perplexity" icon="link" href="/oss/python/integrations/embeddings/perplexity" arrow="true" cta="View guide" />

  <Card title="PremAI" icon="link" href="/oss/python/integrations/embeddings/premai" arrow="true" cta="View guide" />

  <Card title="SageMaker" icon="link" href="/oss/python/integrations/embeddings/sagemaker-endpoint" arrow="true" cta="View guide" />

  <Card title="SambaNova" icon="link" href="/oss/python/integrations/embeddings/sambanova" arrow="true" cta="View guide" />

  <Card title="Self Hosted" icon="link" href="/oss/python/integrations/embeddings/self-hosted" arrow="true" cta="View guide" />

  <Card title="Sentence Transformers" icon="link" href="/oss/python/integrations/embeddings/sentence_transformers" arrow="true" cta="View guide" />

  <Card title="Solar" icon="link" href="/oss/python/integrations/embeddings/solar" arrow="true" cta="View guide" />

  <Card title="SpaCy" icon="link" href="/oss/python/integrations/embeddings/spacy_embedding" arrow="true" cta="View guide" />

  <Card title="SparkLLM" icon="link" href="/oss/python/integrations/embeddings/sparkllm" arrow="true" cta="View guide" />

  <Card title="TensorFlow Hub" icon="link" href="/oss/python/integrations/embeddings/tensorflowhub" arrow="true" cta="View guide" />

  <Card title="Text Embeddings Inference" icon="link" href="/oss/python/integrations/embeddings/text_embeddings_inference" arrow="true" cta="View guide" />

  <Card title="TextEmbed" icon="link" href="/oss/python/integrations/embeddings/textembed" arrow="true" cta="View guide" />

  <Card title="Titan Takeoff" icon="link" href="/oss/python/integrations/embeddings/titan_takeoff" arrow="true" cta="View guide" />

  <Card title="Together AI" icon="link" href="/oss/python/integrations/embeddings/together" arrow="true" cta="View guide" />

  <Card title="Upstage" icon="link" href="/oss/python/integrations/embeddings/upstage" arrow="true" cta="View guide" />

  <Card title="Volc Engine" icon="link" href="/oss/python/integrations/embeddings/volcengine" arrow="true" cta="View guide" />

  <Card title="Voyage AI" icon="link" href="/oss/python/integrations/embeddings/voyageai" arrow="true" cta="View guide" />

  <Card title="Xinference" icon="link" href="/oss/python/integrations/embeddings/xinference" arrow="true" cta="View guide" />

  <Card title="YandexGPT" icon="link" href="/oss/python/integrations/embeddings/yandex" arrow="true" cta="View guide" />

  <Card title="ZhipuAI" icon="link" href="/oss/python/integrations/embeddings/zhipuai" arrow="true" cta="View guide" />
</Columns>

***

<div className="source-links">
  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>

  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/embeddings/index.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>
</div>
