{"record":{"id":"53019467da9d467f","repo":"chroma-core/chroma","slug":"cannot-change-the-quantization-of-the-embedding-fu","errorCode":null,"errorMessage":"Cannot change the quantization of the embedding function.","messagePattern":"Cannot change the quantization of the embedding function\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clients/js/packages/chromadb-core/src/embeddings/TransformersEmbeddingFunction.ts","lineNumber":134,"sourceCode":"  }\n\n  getConfig(): StoredConfig {\n    return {\n      model: this.model,\n      revision: this.revision,\n      quantized: this.quantized,\n    };\n  }\n\n  validateConfigUpdate(oldConfig: StoredConfig, newConfig: StoredConfig): void {\n    if (oldConfig.model !== newConfig.model) {\n      throw new Error(\"Cannot change the model of the embedding function.\");\n    }\n    if (oldConfig.revision !== newConfig.revision) {\n      throw new Error(\"Cannot change the revision of the embedding function.\");\n    }\n    if (oldConfig.quantized !== newConfig.quantized) {\n      throw new Error(\n        \"Cannot change the quantization of the embedding function.\",\n      );\n    }\n  }\n\n  validateConfig(config: StoredConfig): void {\n    validateConfigSchema(config, \"transformers\");\n  }\n}\n","sourceCodeStart":116,"sourceCodeEnd":144,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/js/packages/chromadb-core/src/embeddings/TransformersEmbeddingFunction.ts#L116-L144","documentation":"Third branch of TransformersEmbeddingFunction.validateConfigUpdate(): the `quantized` flag (whether onnxruntime loads quantized vs fp32 weights) is also pinned at collection creation. Quantized and unquantized variants of the same model produce slightly different embeddings, so flipping the flag on an existing collection is rejected.","triggerScenarios":"collection.modify()/updateCollection with quantized set differently from creation — e.g., collection created with the default quantized: true, later updated with new TransformersEmbeddingFunction({ model, revision, quantized: false }) to chase accuracy.","commonSituations":"Trading memory/speed for accuracy after initial deployment; copying constructor options from docs/tests that explicitly set quantized while the collection was created with the default; upgrading the embedding function class defaults between client versions.","solutions":["Pass the same quantized value the collection was created with (inspect the old function's getConfig()).","If you truly need the other variant, create a new collection with that quantized setting and re-embed your documents."],"exampleFix":"// before\nawait collection.modify({\n  embedding_function: new TransformersEmbeddingFunction({ model, revision, quantized: false }),\n}); // collection was created with quantized: true -> throws\n\n// after\nawait collection.modify({\n  embedding_function: new TransformersEmbeddingFunction({ model, revision, quantized: true }), // unchanged\n});","handlingStrategy":"validation","validationCode":"const oldCfg = oldFn.getConfig();\nconst newCfg = newFn.getConfig();\nif (oldCfg.quantized !== newCfg.quantized) {\n  throw new Error(`Quantization change (${oldCfg.quantized} -> ${newCfg.quantized}) is forbidden; keep it identical or re-embed into a new collection.`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set quantized explicitly in all environments so the constructor default can never drift under you.","Keep the full constructor options (model, revision, quantized) in version control next to collection setup code."],"tags":["transformers","embeddings","immutable-config","quantization","collection-update"],"backgroundTag":"embedding-model-mismatch","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}