Repository navigation
Description
Summary
The knowledge base keeps vectors in one table per width (chunk_vectors_<width>), and those tables do not record which model made a vector. When an administrator changes the organization's embedding model in Settings to a different model of the same width, nothing is re-embedded: the old vectors stay, new queries are embedded by the new model, and search compares vectors from two different models. Search results get worse without any message. MCP refuses a change of model once the knowledge base holds anything; the app does not. This was first noticed on 2026-10-10 while building settings over MCP, and has been waiting for a decision since.
Anchors are at main da3b98b730 (2026-10-13).
What the repo says today
- The vector tables hold
chunk_idandembeddingonly, one table per width (services/db/migrations/knowledge-db/private_knowledge/00000000000015_chunk_vectors_by_width.sql:15-18). The supported widths are 256, 384, 512, 768, 1024, 1536, 2048, 3072 and 4096 (packages/shared/src/schemas/knowledge.ts:89-91). The shared public-web corpus has the same tables (services/db/migrations/knowledge-db/public_web/00000000000016_chunk_vectors_by_width.sql). - The app saves a model through
POST /embeddingand checks nothing about what is indexed (services/platform/backend/domains/knowledge/routes.ts:323-353, which callssaveKnowledgeEmbeddinginembedding-save.ts:116). - What follows a save is decided by width.
requeueDocumentsWithoutVectorsre-queues the documents that have no vector of the width the model now states (services/platform/backend/domains/knowledge/service.ts:1600-1635). Its comment says: "Decided by what the corpus holds, never by comparing the old settings with the new: a save that leaves the width alone finds nothing here". - MCP refuses another model while documents or websites are indexed (
EMBEDDING_CORPUS_NOT_EMPTY, ruleMCP-R28:services/platform/backend/domains/knowledge/settings-resource.ts:90-101, testsettings-resource.test.ts:144). Its hint sends the person to Settings › Data residency, "where what is indexed is queued again", which is true only when the width changes.
What was and was not observed
Read from the code above. I did not reproduce a degraded search with two same-width models on a running stack, so the size of the effect is not measured. In general two embedding models produce vectors in different spaces even when they are the same width; whether the degradation is large for any particular pair was not examined.
Options
- Re-embed on any model change: clear the organization's vectors of that width and re-queue every document, which costs the re-embedding a width change already costs.
- Record the model: add a
modelcolumn to the vector tables and search and re-queue by model. A migration in every knowledge database, bring-your-own databases included; allows keeping both while re-embedding. - Refuse in the app as MCP does: allow a model change only while the knowledge base is empty, and tell the person to remove and re-add.
- Leave as it is and warn in the page and the docs.
Whichever is chosen, the shared public-web corpus needs the same answer, and the MCP hint should say what is true.
Questions
- How often does an organization move between two models of the same width? (Models with the same width from one vendor are common.)
- Is the cost of re-embedding on a change acceptable to the people who change it?
Related
#4685 (settings over MCP, where MCP-R28 was written)
Activity
fix(platform): embed documents again after a change of embedding model
yannickmonney commentedon Nov 2, 2026
Documents and email bodies: handled on
trainby8d148e30e(fix(platform): embed documents again after a change of embedding model), which reachesmainwith the next train. Websites are not covered and move to #5326.What the commit does, closest to option 2 above but with the model recorded per document rather than per vector:
private_knowledge.documents.embedding_model: the model whose vectors a document's chunks hold, by the name the settings state. Indexing stamps it on every claim, reuses stored chunks only under that model (no skip, no resume, no copy from a document another model embedded), and stops writing once a run of another model claimed the row.text-embedding-3-smallandopenai/text-embedding-3-smallare two models.requeueDocumentsNotEmbeddedByModel, renamed fromrequeueDocumentsWithoutVectors). While they wait, the documents' dense leg leaves out vectors whose document records another model; they are still found by their words.knowledge.reconcile_corpusre-queues whatever the stated model has not embedded, the backstop for what a save could not reach.What stays open here:
MCP-R28is unchanged. Its hint ("where what is indexed is queued again") is now true for documents and email bodies on any change of model, and for websites only on a change of width.fix(platform): embed documents again after a change of embedding model