chroma-core/chroma · error · ValueError
Preferred providers must be unique
Error message
Preferred providers must be unique
What it means
The second constructor check in ONNXMiniLM_L6_V2 compares len(preferred_providers) with len(set(preferred_providers)); duplicates mean the same execution provider would be registered twice in the ONNX InferenceSession, which is meaningless and usually signals a config-generation bug, so it raises ValueError("Preferred providers must be unique"). Order still matters (first match wins in ORT), so dedupe must preserve order.
Source
Thrown at chromadb/utils/embedding_functions/onnx_mini_lm_l6_v2.py:64
def __init__(self, preferred_providers: Optional[List[str]] = None) -> None:
"""
Initialize the ONNXMiniLM_L6_V2 embedding function.
Args:
preferred_providers (List[str], optional): The preferred ONNX runtime providers.
Defaults to None.
"""
# convert the list to set for unique values
if preferred_providers and not all(
[isinstance(i, str) for i in preferred_providers]
):
raise ValueError("Preferred providers must be a list of strings")
# check for duplicate providers
if preferred_providers and len(preferred_providers) != len(
set(preferred_providers)
):
raise ValueError("Preferred providers must be unique")
self._preferred_providers = preferred_providers
try:
# Equivalent to import onnxruntime
self.ort = importlib.import_module("onnxruntime")
except ImportError:
raise ValueError(
"The onnxruntime python package is not installed. Please install it with `pip install onnxruntime`"
)
try:
# Equivalent to from tokenizers import Tokenizer
self.Tokenizer = importlib.import_module("tokenizers").Tokenizer
except ImportError:
raise ValueError(
"The tokenizers python package is not installed. Please install it with `pip install tokenizers`"
)
try:View on GitHub (pinned to aecdd12c8a)
Solutions
- Dedupe while preserving order before constructing: seen=set(); providers=[p for p in providers if not (p in seen or seen.add(p))]
- Fix the config merge that produces the duplicate (don't append the default CPU fallback if it is already present)
- Drop the argument entirely (pass None) to let the EF use all available providers
Example fix
// before fn = ONNXMiniLM_L6_V2(preferred_providers=["CUDAExecutionProvider", "CPUExecutionProvider", "CPUExecutionProvider"]) # ValueError // after providers = list(dict.fromkeys(["CUDAExecutionProvider", "CPUExecutionProvider", "CPUExecutionProvider"])) fn = ONNXMiniLM_L6_V2(preferred_providers=providers)
Defensive patterns
Strategy: validation
Validate before calling
providers = list(dict.fromkeys(providers)) if providers else providers # order-preserving dedupe fn = ONNXMiniLM_L6_V2(preferred_providers=providers)
Prevention
- When appending a CPU fallback to user providers, check it isn't already present
- Dedupe with dict.fromkeys() to preserve provider priority order
- Write a unit test asserting len(providers) == len(set(providers)) for generated configs
When it happens
Trigger: ONNXMiniLM_L6_V2(preferred_providers=["CPUExecutionProvider", "CPUExecutionProvider"]); concatenating a user provider list with a default fallback list without deduping (e.g. cfg_providers + ["CPUExecutionProvider"]); config templating that injects the same provider for GPU and CPU sections.
Common situations: Appending CPUExecutionProvider as a fallback after user-specified providers that already include it; YAML anchors reusing a provider list twice; environment-specific overrides merged on top of defaults with the same entry.
Related errors
- Preferred providers must be a list of strings
- Preferred providers must be subset of available providers: {
- Could not build embedding function {ef_config['name']} from
- Updating '{key}' is not supported for {NAME}
- The onnxruntime python package is not installed. Please inst
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/3256084b53428a6a.
Report an issue: GitHub.