chroma-core/chroma · error · ValueError
The model name cannot be changed after the embedding functio
Error message
The model name cannot be changed after the embedding function has been initialized.
What it means
When a collection's embedding function is replaced, chromadb calls update_ef.validate_config_update(old_config, new_config) via overwrite_embedding_function (chromadb/api/collection_configuration.py:711, reached from Collection.modify). AmazonBedrockEmbeddingFunction rejects any new_config that contains the "model_name" key, because changing the embedding model would make all existing vectors in the collection incompatible. Caveat: the guard checks key presence, not value change — and get_config() always includes "model_name" — so effectively any bedrock-to-bedrock embedding function update raises, even with an identical model.
Source
Thrown at chromadb/utils/embedding_functions/amazon_bedrock_embedding_function.py:123
else:
session = boto3.Session(**session_args)
return AmazonBedrockEmbeddingFunction(
session=session, model_name=model_name, **kwargs
)
def get_config(self) -> Dict[str, Any]:
return {
"model_name": self.model_name,
"session_args": self._session_args,
"kwargs": self.kwargs,
}
def validate_config_update(
self, old_config: Dict[str, Any], new_config: Dict[str, Any]
) -> None:
if "model_name" in new_config:
raise ValueError(
"The model name cannot be changed after the embedding function has been initialized."
)
@staticmethod
def validate_config(config: Dict[str, Any]) -> None:
"""
Validate the configuration using the JSON schema.
Args:
config: Configuration to validate
Raises:
ValidationError: If the configuration does not match the schema
"""
validate_config_schema(config, "amazon_bedrock")
View on GitHub (pinned to aecdd12c8a)
Solutions
- Create a new collection with the desired bedrock model and re-embed your documents — model changes cannot be applied in place.
- If you only meant to change other collection settings (metadata, hnsw config), call modify() without an embedding_function so this validation never runs.
- If you believe unchanged model_name should be allowed, file an upstream issue: the check should compare old vs new values, not mere key presence.
Example fix
# before: raises ValueError "The model name cannot be changed..."
client.get_collection("docs", embedding_function=old_ef).modify(
configuration=CollectionConfiguration(
embedding_function=AmazonBedrockEmbeddingFunction(session=new_session)
)
)
# after: model is fixed per collection — make a new one and re-embed
new_col = client.create_collection("docs_v2", embedding_function=AmazonBedrockEmbeddingFunction(session=new_session))
for batch in read_old_batches():
new_col.add(**batch)
# or, to change only non-EF settings: col.modify(metadata={...}) with no embedding_function Defensive patterns
Strategy: validation
Validate before calling
from chromadb.utils.embedding_functions import AmazonBedrockEmbeddingFunction
def can_update_bedrock_ef(new_ef) -> bool:
try:
new_ef.validate_config_update(new_ef.get_config(), {k: v for k, v in new_ef.get_config().items() if k != "model_name"})
return True
except ValueError:
return False # model_name change attempted — must create a new collection instead
if can_update_bedrock_ef(new_ef):
col.modify(configuration=CollectionConfiguration(embedding_function=new_ef))
else:
raise RuntimeError("Bedrock model_name is fixed per collection; create a new collection and re-embed") Try / catch
try:
col.modify(configuration=CollectionConfiguration(embedding_function=new_ef))
except ValueError as e:
if "model name cannot be changed" in str(e):
# model is immutable per collection — migrate instead
new_col = client.create_collection(f"{col.name}_v2", embedding_function=new_ef)
migrate_documents(col, new_col)
else:
raise Prevention
- Treat the embedding model as part of a collection's identity: plan migrations as new collections plus re-embeds.
- When calling modify(), pass only the settings you intend to change — omit embedding_function entirely for non-EF updates.
- Wrap collection migrations in a script that checkpoints progress, since in-place model swaps are not possible.
When it happens
Trigger: collection.modify(configuration=CollectionConfiguration(embedding_function=AmazonBedrockEmbeddingFunction(...))) on a collection whose current embedding function is also amazon_bedrock; overwrite_embedding_function passes the new function's get_config() (which always contains model_name) straight into this check.
Common situations: Trying to tweak session args or kwargs on an existing collection; attempting a model-version migration in place; copy-pasting the original constructor into a modify() call while debugging.
Related errors
- Keyword argument {key} is not a primitive type
- The boto3 python package is not installed. Please install it
- Failed to register embedding function: {e}
- Failed to register sparse embedding function: {e}
- Config must contain a 'name' field.
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/1eff8b58affcc4c8.
Report an issue: GitHub.