Skip to content

Support Matryoshka dimension truncation for Ollama embeddings #4

Closed

Description

@achinth-b

Problem

nomic-embed-text (the default model) supports Matryoshka Representation Learning — its embedding vectors can be truncated to fewer dimensions (e.g., 256 instead of 768) with ~95% retrieval quality preserved. Ollama's /api/embed endpoint already accepts a dimensions parameter for this, but mnemon currently always requests full native dimensions.

For large knowledge bases, this means 3× more storage and slower cosine similarity computation than necessary.

Proposal

Add a MNEMON_EMBED_DIMENSIONS env var (following the existing MNEMON_EMBED_ENDPOINT / MNEMON_EMBED_MODEL pattern). When set, pass "dimensions": N in the Ollama embed request. When unset, behavior is identical to today.

export MNEMON_EMBED_DIMENSIONS=256
mnemon recall "some query"  # uses 256-dim vectors

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions