infiniflow/ragflow · error · Exception
Datasets use different embedding models: {[kb.embd_id for kb
Error message
Datasets use different embedding models: {[kb.embd_id for kb in kbs]} What it means
Raised (as generic Exception) from get_models when all datasets in a dialog have embedding models but they are not the same model after normalization (tenant_model references and legacy model@instance@provider composites are resolved to base names before comparing). Cross-dataset retrieval requires one shared embedding space, so mismatched models abort model resolution.
Source
Thrown at api/db/services/dialog_service.py:359
yield {"answer": "", "reference": {}, "audio_binary": None, "prompt": "", "created_at": time.time(), "final": False, **flags}
continue
yield {"answer": value, "reference": {}, "audio_binary": tts(tts_mdl, value), "prompt": "", "created_at": time.time(), "final": False}
else:
if model_config["model_type"] == "chat":
answer = await chat_mdl.async_chat(system_prompt, msg, dialog.llm_setting)
else:
answer = await chat_mdl.async_chat(system_prompt, msg, dialog.llm_setting, images=image_files)
user_content = msg[-1].get("content", "[content not available]")
logging.debug("User: {}|Assistant: {}".format(user_content, answer))
yield {"answer": answer, "reference": {}, "audio_binary": tts(tts_mdl, answer), "prompt": "", "created_at": time.time()}
def get_models(dialog, trace_context=None, langfuse_session_id=None):
embd_mdl, chat_mdl, rerank_mdl, tts_mdl = None, None, None, None
kbs = KnowledgebaseService.get_by_ids(dialog.kb_ids)
err = validate_dataset_embedding_models(kbs)
if err:
raise Exception(err)
if kbs and kbs[0].embd_id:
embd_owner_tenant_id = kbs[0].tenant_id
embd_model_config = resolve_model_config(embd_owner_tenant_id, LLMType.EMBEDDING, kbs[0].embd_id)
embd_mdl = LLMBundle(embd_owner_tenant_id, embd_model_config, trace_context=trace_context, langfuse_session_id=langfuse_session_id)
if not embd_mdl:
raise LookupError("Embedding model(%s) not found" % kbs[0].embd_id)
if dialog.llm_id:
if dialog.tenant_llm_id:
try:
chat_model_config = get_model_config_by_id(dialog.tenant_id, LLMType.CHAT, dialog.tenant_llm_id)
except LookupError:
chat_model_config = resolve_model_config(dialog.tenant_id, LLMType.CHAT, dialog.llm_id)
else:
chat_model_config = resolve_model_config(dialog.tenant_id, LLMType.CHAT, dialog.llm_id)
else:
chat_model_config = get_tenant_default_model_by_type(dialog.tenant_id, LLMType.CHAT)View on GitHub (pinned to 554fb1133a)
Solutions
- Re-embed the outlier dataset(s) with the embedding model used by the others, then re-add them to the dialog.
- Split the dialog so each dialog only groups datasets sharing one embedding model.
- Check the message's listed embd_id values in the error to identify exactly which datasets disagree.
Example fix
# before dialog.kb_ids = [kb_bge.id, kb_gte.id] # different embd_id # after: rebuild kb_gte with kb_bge's embedding model kb_gte.embd_id = kb_bge.embd_id; kb_gte.save(); # then re-parse/re-embed its documents
Defensive patterns
Strategy: validation
Validate before calling
embd_refs = {(kb.embd_id, getattr(kb, 'tenant_embd_id', None)) for kb in kbs}
# rely on the same validator the server uses:
err = validate_dataset_embedding_models(kbs)
if err:
raise ValueError(err) # shows exactly which embd_ids disagree Try / catch
try:
chat(dialog, msg)
except Exception as e:
if 'different embedding models' in str(e):
highlight_mismatched_datasets(dialog.kb_ids) # parse embd list from message
else:
raise Prevention
- Standardize one embedding model per tenant before creating datasets.
- Surface each dataset's embedding model in the dialog-editing UI so mismatches are visible.
When it happens
Trigger: Chat/ask request against a dialog whose kb_ids contain datasets created with different embd_id values (e.g. one BAAI/bge-large-zh, one maidapark/gte), including cases where composite refs point at different base models.
Common situations: Adding a dataset created later under a different default embedding model to an old dialog; tenant switched embedding providers and only some datasets were rebuilt; combining shared and private datasets with different models.
Related errors
- Cannot search across datasets where some have embedding mode
- dataset_id (or kb_id/knowledge_id) is required for retrieval
- Embedding model(%s) not found
- Miss parameter: {key}
- main() must be defined or exported.
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/ace1bb83387bf6a7.
Report an issue: GitHub.