Skip to content

Benchmark and select a multilingual FastEmbed model for semantic search #1372

Description

@phernandez

Summary

Benchmark and select a multilingual FastEmbed embedding model for Basic Memory semantic and hybrid search, including the Basic Memory Cloud path where FastEmbed generates vectors and PostgreSQL/pgvector stores and retrieves them.

This is deliberately separate from #1294. That issue is scoped to lexical full-text search (FTS) analysis across SQLite and PostgreSQL; changing the embedding model does not fix exact CJK keyword matching.

Current state

Goal

Choose a multilingual model from evidence rather than switching defaults based on catalog descriptions alone, then define a safe local and Cloud migration plan.

The benchmark should compare the current English BGE baseline with viable FastEmbed multilingual candidates. Initial candidates to evaluate include, but are not limited to:

  • sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 (384 dimensions)
  • sentence-transformers/paraphrase-multilingual-mpnet-base-v2 (768 dimensions)
  • intfloat/multilingual-e5-large (1024 dimensions; requires query/document prefixes)
  • jinaai/jina-embeddings-v3 (1024 dimensions)

Do not preselect a winner. Candidates may be removed or added based on FastEmbed support, licensing, artifact stability, resource limits, and measured quality.

Evaluation requirements

Retrieval quality

Build a reproducible evaluation corpus and query set that covers:

  • English baseline/regression
  • Chinese, Japanese, and Korean
  • additional representative scripts/languages such as Arabic, Russian, Spanish, and Thai
  • mixed-language notes
  • same-language retrieval
  • cross-language retrieval where the query and relevant note use different languages
  • short notes, long notes, and matches that cross semantic chunk boundaries
  • conceptual/paraphrase queries, not only literal keyword overlap

Report at least recall@k and ranking quality (MRR or nDCG), plus empty-result and material false-positive rates. Keep the dataset and harness in the repository so future model changes can be compared against the same baseline.

Runtime and operational cost

Measure on supported deployment hardware:

  • cold model load time
  • warm query latency
  • document embedding throughput
  • peak and steady-state memory
  • model artifact and container-image size
  • vector dimensions and PostgreSQL storage growth
  • pgvector index build/update time
  • pgvector query latency and recall under the selected index parameters
  • full-project and representative tenant reindex duration

Local sqlite-vec measurements may be useful for the Core default, but Cloud acceptance must use FastEmbed inference with PostgreSQL/pgvector storage.

Model contract

Verify for every candidate:

  • FastEmbed support on Basic Memory's supported Python/platform matrix
  • deterministic configured dimensions
  • correct query/document prefix or input-role behavior
  • provider-boundary normalization
  • stable embedding identity and stale-vector detection
  • cancellation and representative error propagation during batch reindex
  • license and redistribution suitability for preloading in the Cloud image

Cloud rollout requirements

The selected model must have an explicit Cloud plan:

  1. Configure the same provider, model, dimensions, and prefixes in API and worker processes.
  2. Bake/cache the FastEmbed artifact in the Cloud image so workers do not download it at runtime.
  3. Measure and provision worker memory and concurrency from benchmark results.
  4. Deploy the new model identity without comparing query vectors against vectors from the old model.
  5. Rebuild embeddings for every active tenant/project through a retry-safe fleet operation.
  6. Define whether the first cutover accepts temporary vector incompleteness or requires blue/green vector indexes.
  7. Monitor per-tenant readiness, failures, duration, pgvector size, and query latency before declaring the migration complete.

Changing dimensions requires compatible pgvector schema/index migration. Keeping 384 dimensions avoids that particular schema change but still requires a complete embedding rebuild because vectors from different models are not comparable.

Non-goals

Acceptance criteria

  • Reproducible multilingual retrieval benchmark committed
  • Current BGE baseline and all retained candidates measured
  • Quality, latency, memory, artifact-size, and PostgreSQL/pgvector results documented
  • Recommended model and rejected alternatives explained from evidence
  • Local default/configuration decision documented
  • Cloud capacity, image, configuration, and cutover plan documented
  • Fleet reindex and readiness verification plan documented
  • Any implementation work is split into bounded follow-up PRs/issues as needed

Metadata

Metadata

Assignees

No one assigned

    Labels

    cloudBasic Memory CloudenhancementNew feature or requestneeds investigationIssue needs further investigation and/or refinement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions