What Embedding Models Are Available in Mem0 and How to Switch Between Them

Mem0 supports 12+ embedding providers—including OpenAI, Azure OpenAI, Hugging Face, Ollama, Gemini, VertexAI, Together, LMStudio, LangChain, AWS Bedrock, and FastEmbed—which you can switch between by setting the provider field in EmbedderConfig when initializing the Memory class.

Mem0 (mem0ai/mem0) is a memory layer for LLM applications that abstracts embedding generation through a unified factory pattern. Understanding what embedding models are available in Mem0 and how to configure them is essential for optimizing retrieval performance, managing costs, and ensuring data sovereignty across different deployment environments.

Available Embedding Providers in Mem0

The EmbedderFactory in mem0/utils/factory.py maintains a provider_to_class mapping that registers all supported embedding backends. According to the source code, the following providers are available:

Provider Implementation Module Use Case
openai mem0.embeddings.openai.OpenAIEmbedding OpenAI API (text-embedding-3-small, etc.)
ollama mem0.embeddings.ollama.OllamaEmbedding Local Ollama server
huggingface mem0.embeddings.huggingface.HuggingFaceEmbedding Hugging Face Inference API or local models
azure_openai mem0.embeddings.azure_openai.AzureOpenAIEmbedding Azure OpenAI Service
gemini mem0.embeddings.gemini.GoogleGenAIEmbedding Google Gemini API
vertexai mem0.embeddings.vertexai.VertexAIEmbedding Google Cloud Vertex AI
together mem0.embeddings.together.TogetherEmbedding Together AI API
lmstudio mem0.embeddings.lmstudio.LMStudioEmbedding LM Studio local server
langchain mem0.embeddings.langchain.LangchainEmbedding Any LangChain-compatible embedder
aws_bedrock mem0.embeddings.aws_bedrock.AWSBedrockEmbedding Amazon Bedrock
fastembed mem0.embeddings.fastembed.FastEmbedEmbedding FastEmbed (Qdrant)
mock mem0.embeddings.mock.MockEmbeddings Fallback for upstash_vector store

The list of allowed provider names is enforced by the embedder configuration model in mem0/embeddings/configs.py (EmbedderConfig)—any name outside this whitelist raises a validation error.

How to Switch Between Embedding Models

Mem0 provides three primary methods for switching embedding providers: via the high-level Memory API, direct factory usage, or environment variables.

Using the High-Level Memory API

The most common approach is configuring the EmbedderConfig within MemoryConfig when instantiating the Memory class:

from mem0 import Memory
from mem0.configs.base import MemoryConfig
from mem0.embeddings.configs import EmbedderConfig

# Choose the provider you want, e.g., "huggingface"

embed_cfg = EmbedderConfig(
    provider="huggingface",
    config={"model": "sentence-transformers/all-MiniLM-L6-v2"}   # provider-specific args

)

mem_cfg = MemoryConfig(embedder=embed_cfg)

memory = Memory(mem_cfg)   # The Memory object now uses the HuggingFace embedder

Changing provider to "openai", "azure_openai", "gemini", or any other supported key automatically swaps the underlying embedder class instantiated by the factory.

Using the EmbedderFactory Directly

For custom pipelines that only need the embedder without the full memory stack, call EmbedderFactory.create from mem0/utils/factory.py:

from mem0.utils.factory import EmbedderFactory

# OpenAI example

openai_embedder = EmbedderFactory.create(
    provider_name="openai",
    config={"model": "text-embedding-3-large", "embedding_dims": 3072},
    vector_config=None   # not needed for the embedder itself

)

# Ollama example

ollama_embedder = EmbedderFactory.create(
    provider_name="ollama",
    config={"model": "nomic-embed-text"},
    vector_config=None
)

The factory loads the appropriate class from the provider_to_class mapping and builds a BaseEmbedderConfig instance internally before instantiating the concrete embedder.

Environment-Based Configuration

Many embedder implementations fall back to environment variables when a required key is not supplied in the config dict. For instance, OpenAIEmbedding reads OPENAI_API_KEY and OPENAI_BASE_URL automatically. You can keep the same embedder class and switch keys by changing environment variables, but the provider name itself must be changed in the configuration to use a different backend (e.g., switching from "openai" to "azure_openai").

Practical Code Examples

Switching from OpenAI to Azure OpenAI

from mem0 import Memory
from mem0.configs.base import MemoryConfig
from mem0.embeddings.configs import EmbedderConfig

# 1️⃣ OpenAI (default)

mem_openai = Memory(
    MemoryConfig(
        embedder=EmbedderConfig(
            provider="openai",
            config={"model": "text-embedding-3-small"}
        )
    )
)

# 2️⃣ Azure OpenAI

mem_azure = Memory(
    MemoryConfig(
        embedder=EmbedderConfig(
            provider="azure_openai",
            config={
                "model": "text-embedding-3-large",
                "api_key": "AZURE_API_KEY",
                "azure_endpoint": "https://my-azure-openai.cognitiveservices.azure.com/",
                "azure_deployment": "my-deployment"
            }
        )
    )
)

# Both objects expose the same `add`, `search`, … methods; only the embedding provider differs.

Runtime Provider Selection

from mem0.utils.factory import EmbedderFactory

def get_embedder(name: str):
    cfg = {"model": "default-model"}   # provider-specific defaults can be omitted

    return EmbedderFactory.create(name, cfg, vector_config=None)

# Choose at runtime:

embedder = get_embedder("fastembed")   # Fastembed backend

vectors = embedder.embed("Mem0 is a memory-augmented LLM framework")

Listing Available Providers Programmatically

from mem0.utils.factory import EmbedderFactory

available = list(EmbedderFactory.provider_to_class.keys())
print("Supported embedder providers:", available)

# Output: ['openai', 'ollama', 'huggingface', 'azure_openai', 'gemini',

#          'vertexai', 'together', 'lmstudio', 'langchain',

#          'aws_bedrock', 'fastembed']

Key Implementation Files

The embedding system in Mem0 is implemented across several key files:

These files together define what embedding models Mem0 can use and how you tell the library which one to employ. By adjusting the provider field (and any provider-specific options) in the EmbedderConfig, you seamlessly switch between OpenAI, Azure, Hugging Face, Ollama, Gemini, VertexAI, Together, LMStudio, LangChain, AWS Bedrock, FastEmbed, or the internal mock implementation.

Summary

  • Mem0 provides 12+ embedding providers through a plugin-style factory pattern defined in mem0/utils/factory.py.
  • Switch models by setting the provider string in EmbedderConfig (e.g., "openai", "huggingface", "azure_openai").
  • The factory validates provider names against a whitelist in mem0/embeddings/configs.py, raising errors for invalid selections.
  • Configure provider-specific parameters (model names, API keys, endpoints) via the config dict in EmbedderConfig.
  • Access the underlying factory directly via EmbedderFactory.create() for custom pipelines without the full Memory stack.

Frequently Asked Questions

What is the default embedding model in Mem0?

If you do not specify an embedder configuration, Mem0 typically defaults to the OpenAI provider using the text-embedding-3-small model. However, this depends on your environment variables; if OPENAI_API_KEY is not set and another provider is configured, the system will use the explicitly defined provider instead.

Can I use a custom embedding model not listed in the factory?

Yes, via the langchain provider. The LangchainEmbedding class in mem0/embeddings/langchain.py wraps any LangChain-compatible embeddings object, allowing you to inject custom models or third-party LangChain integrations that are not natively implemented in Mem0.

How do I configure API keys for different embedding providers?

Most embedder implementations read API keys from environment variables when not provided in the config dict. For example, OpenAIEmbedding automatically reads OPENAI_API_KEY and OPENAI_BASE_URL. For Azure OpenAI, you can pass api_key, azure_endpoint, and azure_deployment directly in the config dict of EmbedderConfig, or set the corresponding environment variables.

Does switching embedding models affect existing stored memories?

Yes. Embeddings generated by different models are not compatible because each model produces vectors with different dimensions and semantic mappings. If you switch from OpenAI to Hugging Face (or any other provider), you should treat this as a new memory configuration. Existing memories stored with the previous embedder will not be retrievable via vector similarity search unless you re-embed all data with the new model.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →