moss-minilm, moss-mediumlm). If you
already generate embeddings elsewhere - a proprietary model, a hosted embedding API, or a
shared pipeline across services - use modelId: 'custom' to supply your own vectors. Moss
indexes and searches them; it does not load a local model.
How it works
- At index time, every document must carry its own
embedding. WithmodelId: 'custom', Moss does not embed for you. (If you omitmodelIdand every document has anembedding, Moss infers'custom'automatically; mixed documents are rejected.) - At query time, you must pass the query vector via
QueryOptions.embedding, because there is no local model to embed the query text. - All vectors must share the same dimensionality.
Example
In a session
Sessions support custom embeddings too: open the session withmodelId: 'custom', set
embedding on every document you add, and pass embedding on every query.
With
modelId: 'custom', adding a document without an embedding, or querying without
embedding in the query options, throws.Related
- Sessions - custom embeddings in a live session.
- Hybrid search - blend semantic and keyword scoring.
- DocumentInfo and QueryOptions - where
embeddinglives. - SDK reference - the full JavaScript SDK overview.