{"record":{"id":"e89823c25e299be3","repo":"mudler/LocalAI","slug":"router-rerank-reranker-is-required-configure-rou","errorCode":null,"errorMessage":"router/rerank: reranker is required (configure router.classifier_model)","messagePattern":"router/rerank: reranker is required \\(configure router\\.classifier_model\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/services/routing/router/rerank.go","lineNumber":44,"sourceCode":"\n\t// budget trims the query to the reranker model's context minus the\n\t// longest policy description (paired with the query per rerank call);\n\t// nil reranks Probe.Prompt as built by the caller.\n\tbudget *lazyBudget\n}\n\n// defaultRerankActivationThreshold is the relevance floor a label\n// must clear to be considered active. Reranker scores live in [0, 1]\n// for cross-encoder / ColBERT heads; 0.5 picks \"more positive than\n// not on this label.\"\nconst defaultRerankActivationThreshold = 0.5\n\nfunc NewRerankClassifier(policies []ScorePolicy, reranker backend.Reranker, cacheCap int, activationThreshold float64) *RerankClassifier {\n\tif len(policies) == 0 {\n\t\tpanic(\"router/rerank: at least one policy is required\")\n\t}\n\tif reranker == nil {\n\t\tpanic(\"router/rerank: reranker is required (configure router.classifier_model)\")\n\t}\n\tfor _, p := range policies {\n\t\tif p.Label == \"\" {\n\t\t\tpanic(\"router/rerank: policy has empty label\")\n\t\t}\n\t\tif p.Description == \"\" {\n\t\t\tpanic(fmt.Sprintf(\"router/rerank: policy %q has no description\", p.Label))\n\t\t}\n\t}\n\tif activationThreshold <= 0 {\n\t\tactivationThreshold = defaultRerankActivationThreshold\n\t}\n\tlabels := make([]string, len(policies))\n\tdocs := make([]string, len(policies))\n\tfor i, p := range policies {\n\t\tlabels[i] = p.Label\n\t\tdocs[i] = p.Description\n\t}","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/core/services/routing/router/rerank.go#L26-L62","documentation":"Construction-time panic in NewRerankClassifier: policies were supplied but the reranker backend handle is nil. The reranker (configured via router.classifier_model) is the cross-encoder the classifier delegates scoring to; without it there is no way to rank policies, so construction aborts.","triggerScenarios":"Router config sets a rerank classifier with policies but router.classifier_model is unset/empty, or the named model failed to load so the loader passed nil; calling NewRerankClassifier(policies, nil, ...) directly.","commonSituations":"Enabling the classifier before pulling/installing the reranker model; classifier_model name typo so model resolution returns nil; the classifier model backend lacking rerank capability; ordering issue where the router is built before models are registered.","solutions":["Set router.classifier_model in config to a model that provides rerank embeddings/scores (e.g. a cross-encoder)","Verify the named model exists and loaded successfully (check model list / logs at startup)","Ensure the referenced backend implements backend.Reranker (a rerank-capable model, not a plain LLM)","Fix construction order so the reranker handle is resolved before the router is assembled"],"exampleFix":"# before (yaml)\nrouter:\n  classifier:\n    type: rerank\n    policies: [...]\n# after\nrouter:\n  classifier_model: rerank- ms-marco-minilm  # model id with rerank capability\n  classifier:\n    type: rerank\n    policies: [...]","handlingStrategy":"validation","validationCode":"reranker, err := resolveModel(cfg.Router.ClassifierModel)\nif err != nil || reranker == nil {\n    return fmt.Errorf(\"router: classifier_model %q not loaded\", cfg.Router.ClassifierModel)\n}","typeGuard":"func implementsReranker(m backend.Backend) bool { _, ok := m.(backend.Reranker); return ok }","tryCatchPattern":null,"preventionTips":["Install and verify the reranker model before enabling the classifier","Assert the resolved model implements backend.Reranker during router assembly","Fail config load when classifier is enabled without classifier_model"],"tags":["router","config","nil","classifier"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}