mem0ai/mem0 · error · ValueError
Ollama embed() returned no embeddings for model '{self.confi
Error message
Ollama embed() returned no embeddings for model '{self.config.model}' What it means
Raised by OllamaEmbedding.embed when the Ollama client's embed() response contains an empty or missing 'embeddings' list. This happens when the local Ollama server returns a 200-style response with no vectors — typically because the named model is not a text-embedding model (e.g. a chat model like llama3) or the response shape changed.
Source
Thrown at mem0/embeddings/ollama.py:52
or self._normalize_model_name(model.get("model", "")) == target
for model in local_models
):
self.client.pull(self.config.model)
def embed(self, text, memory_action: Optional[Literal["add", "search", "update"]] = None):
"""
Get the embedding for the given text using Ollama.
Args:
text (str): The text to embed.
memory_action (optional): The type of embedding to use. Must be one of "add", "search", or "update". Defaults to None.
Returns:
list: The embedding vector.
"""
response = self.client.embed(model=self.config.model, input=text)
embeddings = response.get("embeddings") or []
if not embeddings:
raise ValueError(f"Ollama embed() returned no embeddings for model '{self.config.model}'")
return embeddings[0]
def embed_batch(self, texts, memory_action="add"):
"""Embed multiple texts in a single Ollama API call."""
if not texts:
return []
response = self.client.embed(model=self.config.model, input=texts)
embeddings = response.get("embeddings") or []
if len(embeddings) != len(texts):
raise ValueError(f"Ollama embed() returned {len(embeddings)} embeddings for {len(texts)} texts using model '{self.config.model}'")
return embeddings
View on GitHub (pinned to 001c235229)
Solutions
- Set the embedder model to a real embedding model: nomic-embed-text or mxbai-embed-large, and ollama pull it
- Update the Ollama server to a recent version (the embed API is newer than the legacy embeddings endpoint)
- Re-pull the model to rule out corruption: ollama rm <model> && ollama pull <model>
- Test outside mem0: curl http://localhost:11434/api/embed -d '{"model":"nomic-embed-text","input":"hi"}' should return embeddings
Example fix
// before
Memory.from_config({"embedder": {"provider": "ollama", "config": {"model": "llama3"}}}) # ValueError: no embeddings
# after
Memory.from_config({"embedder": {"provider": "ollama", "config": {"model": "nomic-embed-text"}}}) Defensive patterns
Strategy: validation
Validate before calling
import ollama
resp = ollama.Client(host="http://localhost:11434").embed(
model="nomic-embed-text", input="healthcheck")
assert resp.get("embeddings"), "chosen model produces no embeddings — use an embedding model" Type guard
EMBEDDING_MODELS = {"nomic-embed-text", "mxbai-embed-large", "snowflake-arctic-embed", "all-minilm"}
def is_embedding_model(model: str) -> bool:
return model in EMBEDDING_MODELS or "embed" in model Try / catch
try:
vec = embedder.embed(text)
except ValueError as e:
if "returned no embeddings" in str(e):
# model is wrong or server misbehaving — surface clearly
raise RuntimeError(f"Ollama model '{embedder.config.model}' is not usable for embedding") from e
raise Prevention
- Use a dedicated embedding model for the embedder config, never the chat model
- Health-check embed() once at startup before processing real traffic
- Keep the Ollama server updated and models fully pulled
When it happens
Trigger: Setting config.model to a generative model (e.g. 'llama3', 'mistral') instead of an embedding model ('nomic-embed-text', 'mxbai-embed-large'); the model file is corrupted on disk; an Ollama server version whose embed endpoint returns {} for unsupported models.
Common situations: Reusing the LLM model name for the embedder config; model pulled partially (ollama pull interrupted); older Ollama server predating the /api/embed endpoint.
Related errors
- Ollama embed() returned {len(embeddings)} embeddings for {le
- LM Studio embed_batch() returned {len(embeddings)} embedding
- Ollama embed() returned no embeddings for model '${this.mode
- `model` parameter is required
- `model` must be an instance of Embeddings
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/c98f7580a5526e3a.
Report an issue: GitHub.