chroma-core/chroma · error · Error

Cannot change the quantization of the embedding function.

Error message

Cannot change the quantization of the embedding function.

What it means

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.

Source

Thrown at clients/js/packages/chromadb-core/src/embeddings/TransformersEmbeddingFunction.ts:134

  }

  getConfig(): StoredConfig {
    return {
      model: this.model,
      revision: this.revision,
      quantized: this.quantized,
    };
  }

  validateConfigUpdate(oldConfig: StoredConfig, newConfig: StoredConfig): void {
    if (oldConfig.model !== newConfig.model) {
      throw new Error("Cannot change the model of the embedding function.");
    }
    if (oldConfig.revision !== newConfig.revision) {
      throw new Error("Cannot change the revision of the embedding function.");
    }
    if (oldConfig.quantized !== newConfig.quantized) {
      throw new Error(
        "Cannot change the quantization of the embedding function.",
      );
    }
  }

  validateConfig(config: StoredConfig): void {
    validateConfigSchema(config, "transformers");
  }
}

View on GitHub (pinned to aecdd12c8a)

Solutions

  1. Pass the same quantized value the collection was created with (inspect the old function's getConfig()).
  2. If you truly need the other variant, create a new collection with that quantized setting and re-embed your documents.

Example fix

// before
await collection.modify({
  embedding_function: new TransformersEmbeddingFunction({ model, revision, quantized: false }),
}); // collection was created with quantized: true -> throws

// after
await collection.modify({
  embedding_function: new TransformersEmbeddingFunction({ model, revision, quantized: true }), // unchanged
});
Defensive patterns

Strategy: validation

Validate before calling

const oldCfg = oldFn.getConfig();
const newCfg = newFn.getConfig();
if (oldCfg.quantized !== newCfg.quantized) {
  throw new Error(`Quantization change (${oldCfg.quantized} -> ${newCfg.quantized}) is forbidden; keep it identical or re-embed into a new collection.`);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16). Data as JSON: /api/errors/53019467da9d467f. Report an issue: GitHub.