mnemon icon indicating copy to clipboard operation
mnemon copied to clipboard

[Bug] embedding_available=true when the configured model is missing; recall silently drops similarity to 0

Open zlysd55 opened this issue 1 month ago • 0 comments

Summary

mnemon embed --status reports embedding_available: true — and recall proceeds as if semantic search were active — when the configured embedding model does not exist on the provider. The availability check only probes that the endpoint answers; it never verifies the model.

Consequence: recall's similarity signal is silently 0 for every query, with no warning anywhere. On Ollama this happens out of the box, because the default model is nomic-embed-text and most users have pulled a different embedding model (e.g. bge-m3).

Environment

  • mnemon CLI 0.2.12 (Windows, amd64), commit master
  • Ollama local at http://localhost:11434
  • ollama list contains bge-m3:latest but not nomic-embed-text
  • DB has 18 insights, all with stored embeddings (backfilled with --embed-model bge-m3)

Steps to reproduce

$ mnemon embed --status
{"total_insights":18,"embedded":18,"coverage":"100%",
 "embedding_available":true,"ollama_available":true,
 "protocol":"ollama","model":"nomic-embed-text"}

embedding_available: true — but the model named in the same output does not exist:

$ curl -s http://localhost:11434/api/embeddings -d '{"model":"nomic-embed-text","prompt":"x"}'
{"error":"model \"nomic-embed-text\" not found, try pulling it first"}

Yet recall does not report anything:

$ mnemon recall "how do I expose a local server to my phone" --verbose
  ...
  similarity 0.0000        <-- always 0, regardless of query

Every hit is scored by keyword/entity/graph only. There is no error, no warning, and --status says everything is fine.

For comparison, the same query with the correct model:

$ mnemon recall "how do I expose a local server to my phone" --embed-model bge-m3 --verbose
  #1 similarity 0.5888  score 0.582

So the vector path is healthy — it was simply never reached, and nothing said so.

Root cause

1. The availability probe only checks the endpoint — cmd/memory/embed.go:48

available := ec.Available()
output := map[string]interface{}{
    ...
    "embedding_available": available,
    "ollama_available":    available, // Backward-compatible alias.
    "protocol":            ec.Protocol(),
    "model":               ec.Model(),   // <-- names a model that may not exist
}

2. The code already knows the model may need pulling — but that branch is unreachable — cmd/memory/embed.go:62-64

if !ec.Available() {
    if ec.Protocol() == embed.ProtocolOllama {
        return fmt.Errorf("Ollama embedding provider not available at %s — install with: brew install ollama && ollama pull %s", ec.Endpoint(), ec.Model())
    }
    ...
}

Available() returns true as soon as the daemon answers, so when the daemon is up but the model is missing, this error — the one that would tell the user to run ollama pull — never fires. Execution falls through to ec.Embed(), which fails per-call instead.

3. recall swallows that per-call error — cmd/memory/recall.go:183-188

// Try to get query embedding for hybrid search
var queryVec []float64
ec := embed.NewClientWithModel(resolveEmbedModel())
if ec.Available() {
    queryVec, _ = ec.Embed(keyword)   // <-- error discarded; queryVec stays nil
}

queryVec == nil then flows into search.IntentAwareRecallFrom(...), where the similarity signal contributes nothing. Silent downgrade to lexical-only.

Expected behavior

embedding_available should mean "a query can actually be embedded right now". At minimum:

  • embed --status should distinguish endpoint reachable from model usable — e.g. a model_available field, or make embedding_available false when a probe embed fails.
  • recall should not discard the Embed error silently. A one-line warning to stderr (recall: embedding unavailable (model "nomic-embed-text" not found), falling back to lexical scoring) would have made this self-diagnosing.

Suggested fixes (any of)

  1. In --status, do one cheap probe embed (or call /api/tags and check membership for the Ollama protocol) and report the real answer; keep ollama_available as a separate "daemon up" field.
  2. Cache a tri-state client status (unknown | ok | model-missing) on first Embed failure, so recall can emit the warning once instead of per call.
  3. Consider a better default model for the Ollama protocol, or at least surface the first failure prominently — nomic-embed-text is not among the models most ollama pull users end up with, so the default path is broken by default for them.

Notes

  • Backfilling with --all --embed-model bge-m3 works and lifts coverage to 100% — the data side has no problem. This is purely a detection/reporting gap.
  • Related but distinct: #117 (OpenAI-compatible embedding backends) and #4 (Matryoshka truncation).

zlysd55 avatar Oct 26 '26 18:10 zlysd55