mem0ai/mem0 · error · Error
FastEmbed embed() returned no embeddings
Error message
FastEmbed embed() returned no embeddings
What it means
Thrown by FastEmbedEmbedder.embed() when iterating the fastembed output stream yields no defined first embedding for the single input text. FastEmbed returns results as async batches; if the stream completes without ever producing batch[0], the SDK cannot return a vector and raises rather than returning undefined. It indicates an anomalous library/model interaction, not bad input text.
Source
Thrown at mem0-ts/src/oss/src/embeddings/fastembed.ts:82
return sdk.FlagEmbedding.init({ model: this.modelName });
}
private normalizeInput(text: string): string {
return text.replace(/\n/g, " ");
}
async embed(text: string): Promise<number[]> {
const normalizedText = this.normalizeInput(text);
const model = await this.getEmbeddingModel();
for await (const batch of model.embed([normalizedText])) {
const embedding = batch[0];
if (embedding !== undefined) {
return embedding;
}
}
throw new Error("FastEmbed embed() returned no embeddings");
}
async embedBatch(texts: string[]): Promise<number[][]> {
const normalizedTexts = texts.map((text) => this.normalizeInput(text));
const model = await this.getEmbeddingModel();
const embeddings: number[][] = [];
for await (const batch of model.embed(normalizedTexts)) {
embeddings.push(...batch);
}
return embeddings;
}
}
View on GitHub (pinned to 001c235229)
Solutions
- Pin/align the fastembed version with what this mem0-ts release was tested against, then clear the fastembed model cache and let it re-download
- Verify with a trivial input: await embedder.embed('hello') — if that also throws, the model artifacts are bad, not your text
- Pre-trim inputs and avoid feeding whitespace-only strings
Example fix
// before
const vec = await embedder.embed(userText); // throws on empty stream
// after
const text = userText.trim();
if (!text) throw new Error('refusing to embed empty text');
const vec = await embedder.embed(text); Defensive patterns
Strategy: try-catch
Validate before calling
const text = raw.trim();
if (!text) throw new Error('refusing to embed empty text');
await embedder.embed(text); Try / catch
try {
vec = await embedder.embed(text);
} catch (e) {
if (e instanceof Error && e.message === 'FastEmbed embed() returned no embeddings') {
// library/model artifact problem: clear the fastembed cache and rebuild once
throw new Error('FastEmbed produced no output — clear the ONNX model cache and retry init');
}
throw e;
} Prevention
- Sanity-test embed('hello') right after constructing the embedder to catch broken model artifacts early
- Pin the fastembed peer dependency version that matches your mem0-ts release
- If a first-run download is interrupted, delete the fastembed cache directory and re-run
When it happens
Trigger: A fastembed version whose embed() yields empty arrays for some inputs; model files corrupted after a partial download so inference returns nothing; an edge case where normalized input (e.g. whitespace-only text) produces no output row.
Common situations: After upgrading the optional fastembed peer dependency to an incompatible version; interrupted first-run model download leaving broken artifacts in the cache directory.
Related errors
- Unsupported FastEmbed model "${config.model}". Supported mod
- Error getting embedding from AWS Bedrock model ${this.model}
- AWS Bedrock model ${this.model} returned no embedding for on
- HuggingFace embed() returned no embeddings for model '${this
- LM Studio embedder failed: ${message}
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/26fe9c0c352eead1.
Report an issue: GitHub.