continuedev/continue · error · Error

Ollama generated empty embedding

Error message

Ollama generated empty embedding

What it means

Thrown by Ollama._embed when POST /api/embed returned OK but the response contained no usable embeddings array (missing or empty). This indicates a protocol-level anomaly: the server claimed success yet produced no vectors.

Source

Thrown at core/llm/llms/Ollama.ts:755

    }
    const resp = await this.fetch(new URL("api/embed", this.apiBase), {
      method: "POST",
      body: JSON.stringify({
        model: this.model,
        input: chunks,
      }),
      headers: headers,
    });

    if (!resp.ok) {
      throw new Error(`Failed to embed chunk: ${await resp.text()}`);
    }

    const data = await resp.json();
    const embedding: number[][] = data.embeddings;

    if (!embedding || embedding.length === 0) {
      throw new Error("Ollama generated empty embedding");
    }
    return embedding;
  }

  public async installModel(
    modelName: string,
    signal: AbortSignal,
    progressReporter?: (task: string, increment: number, total: number) => void,
  ): Promise<any> {
    const modelInfo = await getRemoteModelInfo(modelName, signal);
    if (!modelInfo) {
      throw new Error(`'${modelName}' not found in the Ollama registry!`);
    }

    const release = await Ollama.modelsBeingInstalledMutex.acquire();
    try {
      if (Ollama.modelsBeingInstalled.has(modelName)) {
        throw new Error(`Model '${modelName}' is already being installed.`);

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Upgrade Ollama to a current version so /api/embed returns the multi-input format
  2. Verify with curl: curl http://localhost:11434/api/embed -d '{"model":"nomic-embed-text","input":["hi"]}' and check the response contains "embeddings"
  3. Remove any proxy between the extension and Ollama
Defensive patterns

Strategy: validation

Validate before calling

const r = await fetch(`${host}/api/embed`, { method: 'POST', body: JSON.stringify({ model, input: ['test'] }) });
const j = await r.json();
if (!Array.isArray(j.embeddings) || j.embeddings.length === 0) throw new Error('Ollama /api/embed response malformed — upgrade Ollama');

Type guard

interface OllamaEmbedResponse { embeddings?: number[][] }
const hasEmbeddings = (j: unknown): j is OllamaEmbedResponse => Array.isArray((j as OllamaEmbedResponse).embeddings) && (j as OllamaEmbedResponse).embeddings!.length > 0;

Try / catch

try { return await llm.embed(chunks); }
catch (e) { if (e instanceof Error && e.message === 'Ollama generated empty embedding') upgradeOllamaHint(); throw e; }

Prevention

When it happens

Trigger: Ollama responding 200 with a body lacking 'embeddings' — seen with mismatched Ollama versions, proxies returning an empty 200, or models that return an unexpected response shape.

Common situations: Old Ollama builds returning {embedding: [...]} (singular, /api/embeddings format) instead of {embeddings: [...]}, or a middleware stripping the body.

Related errors


AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27). Data as JSON: /api/errors/b8ed0c0781c6f139. Report an issue: GitHub.