{"record":{"id":"dffc5eee36b2d862","repo":"run-llama/llama_index","slug":"unknown-query-mode-query-mode","errorCode":null,"errorMessage":"Unknown query mode: {query_mode}","messagePattern":"Unknown query mode: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/indices/query/embedding_utils.py","lineNumber":86,"sourceCode":"    embeddings_np = np.array(embeddings)\n    # create dataset\n    dataset_len = len(embeddings) + 1\n    dataset = np.concatenate([query_embedding_np[None, ...], embeddings_np])\n    y = np.zeros(dataset_len)\n    y[0] = 1\n\n    if query_mode == VectorStoreQueryMode.SVM:\n        # train our SVM\n        # TODO: make params configurable\n        clf = svm.LinearSVC(\n            class_weight=\"balanced\", verbose=False, max_iter=10000, tol=1e-6, C=0.1\n        )\n    elif query_mode == VectorStoreQueryMode.LINEAR_REGRESSION:\n        clf = linear_model.LinearRegression()\n    elif query_mode == VectorStoreQueryMode.LOGISTIC_REGRESSION:\n        clf = linear_model.LogisticRegression(class_weight=\"balanced\")\n    else:\n        raise ValueError(f\"Unknown query mode: {query_mode}\")\n\n    clf.fit(dataset, y)  # train\n\n    # infer on whatever data you wish, e.g. the original data\n    similarities = clf.decision_function(dataset[1:])\n    sorted_ix = np.argsort(-similarities)\n    top_sorted_ix = sorted_ix[:similarity_top_k]\n\n    result_similarities = similarities[top_sorted_ix]\n    result_ids = [embedding_ids[ix] for ix in top_sorted_ix]\n\n    return result_similarities, result_ids\n\n\ndef get_top_k_mmr_embeddings(\n    query_embedding: List[float],\n    embeddings: List[List[float]],\n    similarity_fn: Optional[Callable[..., float]] = None,","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/indices/query/embedding_utils.py#L68-L104","documentation":"get_top_similar_embeddings_by_query only supports three classifier modes: SVM, LINEAR_REGRESSION, and LOGISTIC_REGRESSION. Passing any other VectorStoreQueryMode (DEFAULT, MMR, HYBRID, etc.) falls through to the else and raises, because the function is a specialized embedding-ranking helper, not a general query dispatcher.","triggerScenarios":"Setting vector_store_query_mode to something other than the three supported values on a retriever whose code path routes into this helper — e.g. SVM-mode embeddings but the mode string was overwritten later, or passing an unvalidated string/int as query_mode.","commonSituations":"Copy-pasting retriever configs between engines where the same enum value routes to different internals; building a mode selector UI that forwards arbitrary enum values; refactoring from QueryMode (old enum) to VectorStoreQueryMode and passing a stale value.","solutions":["Use one of VectorStoreQueryMode.SVM, .LINEAR_REGRESSION, .LOGISTIC_REGRESSION when this code path is hit","For nearest-neighbour semantics use VectorStoreQueryMode.DEFAULT (handled by the vector store, not this helper)","Validate query_mode against the supported set before constructing the retriever"],"exampleFix":"# before\nretriever = index.as_retriever(vector_store_query_mode=VectorStoreQueryMode.MMR)\n# if this path is entered: ValueError\n\n# after\nretriever = index.as_retriever(vector_store_query_mode=VectorStoreQueryMode.SVM)  # or DEFAULT","handlingStrategy":"validation","validationCode":"SUPPORTED = {VectorStoreQueryMode.SVM, VectorStoreQueryMode.LINEAR_REGRESSION, VectorStoreQueryMode.LOGISTIC_REGRESSION}\nif query_mode in SUPPORTED and not has_sklearn():\n    query_mode = VectorStoreQueryMode.DEFAULT\nretriever = index.as_retriever(vector_store_query_mode=query_mode)","typeGuard":"def is_classifier_mode(mode: VectorStoreQueryMode) -> bool:\n    return mode in {\n        VectorStoreQueryMode.SVM,\n        VectorStoreQueryMode.LINEAR_REGRESSION,\n        VectorStoreQueryMode.LOGISTIC_REGRESSION,\n    }","tryCatchPattern":"try:\n    sims, ids = get_top_similar_embeddings_by_query(qe, embeddings, query_mode=mode)\nexcept ValueError as e:\n    if 'Unknown query mode' in str(e):\n        raise ValueError(f'{mode} not supported here; use SVM/LINEAR_REGRESSION/LOGISTIC_REGRESSION or DEFAULT') from e\n    raise","preventionTips":["Restrict mode pickers in config/UI to modes the target engine actually supports","Keep one mapping of mode -> engine support instead of scattering enums through configs"],"tags":["llama-index","query-mode","validation","enum"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}