Vector similarity search ranks results by approximate proximity in embedding space. This is fast but imprecise. A document can be a close neighbour in embedding space without actually answering the query.A cross-encoder reranker fixes this. Instead of comparing independent embeddings, it receives the query and each candidate document together and produces an exact relevance score using bidirectional attention:
search() fetches top_k × 2 candidates from a vector store (over-fetch)
The cross-encoder scores every candidate against the query in a single batch
Results are re-sorted by cross-encoder score and truncated to top_k
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"MemWire","description":"Open source \u0026 enterprise-ready AI memory infrastructure layer","colors":{"primary":"#6366f1","light":"#818cf8","dark":"#4f46e5"},"logo":{"light":"https://mintcdn.com/memwire/TxHdS7hR2Dea58P8/logo/logo-dark.png?fit=max\u0026auto=format\u0026n=TxHdS7hR2Dea58P8\u0026q=85\u0026s=24fcfb12210bffb594d64c96502c25d9","dark":"https://mintcdn.com/memwire/TxHdS7hR2Dea58P8/logo/logo-light.png?fit=max\u0026auto=format\u0026n=TxHdS7hR2Dea58P8\u0026q=85\u0026s=0570c15a5eb7b2d72af5a2f336d605b1"},"favicon":"/favicon.svg","api":{"playground":{}},"navbar":{"links":[{"href":"https://github.com/memoryoss/memwire","label":"GitHub"}],"primary":{"type":"button","label":"Get Started","href":"https://github.com/memoryoss/memwire"}},"footer":{"socials":{"github":"https://github.com/memoryoss/memwire","discord":"https://discord.gg/pGeS7CCcem"}},"seo":{"indexing":"all"},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"metadata":{"timestamp":false},"styling":{"latex":false},"navigation":{"global":{"anchors":[{"anchor":"GitHub","icon":"github","href":"https://github.com/memoryoss/memwire"},{"anchor":"Roadmap","icon":"map","href":"https://github.com/memoryoss/memwire/blob/main/ROADMAP.md"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"memwire","hasAudioNarration":false,"actualSubdomain":"memwire","customDomains":["memwirelabs.ai"],"gitSource":{"type":"github","owner":"memoryoss","repo":"memwire","deployBranch":"main","contentDirectory":"docs","isPrivate":false,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6a21ebcc4469870420d76bd2","collectionId":"636470e3-1560-414a-89d5-d46d7828e897","schemaVersion":"v2"},"feedback":{"thumbs":true,"edits":true,"issues":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6a21ebcc4469870420d76bd2:success","clientVersion":"0.0.4021","searchFilterCounts":[{"language":"default","tag":"Open Source","count":18},{"language":"default","tag":"API reference","count":8},{"language":"default","tag":"Configuration","count":8},{"language":"default","tag":"Features","count":8},{"language":"default","tag":"Knowledge","count":3},{"language":"default","tag":"Memory","count":3},{"language":"default","tag":"LLMs","count":3},{"language":"default","tag":"Embedding Models","count":2},{"language":"default","tag":"Getting started","count":2},{"language":"default","tag":"Vector Databases","count":2}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"pause-universal-search-reconcile","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"per-site-search-delta","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-private-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"features/reranker","slug":"/features/reranker","pageMetadata":{"title":"Reranker","description":"Boost search precision with a local cross-encoder that rescores candidates using full query-document attention.","href":"/features/reranker","hidden":false},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Boost search precision with a local cross-encoder that rescores candidates using full query-document attention.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,hr:`hr`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,..._provideComponents(),...props.components},{CodeBlock,Heading,Table,Tip,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Tip)_missingMdxReference(`Tip`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`how-it-works`,children:`How it works`}),`\n`,_jsx(_components.p,{children:`Vector similarity search ranks results by approximate proximity in embedding space. This is fast but imprecise. A document can be a close neighbour in embedding space without actually answering the query.`}),`\n`,_jsxs(_components.p,{children:[`A `,_jsx(_components.strong,{children:`cross-encoder reranker`}),` fixes this. Instead of comparing independent embeddings, it receives the query and each candidate document together and produces an exact relevance score using bidirectional attention:`]}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`search()`}),` fetches `,_jsx(_components.code,{children:`top_k × 2`}),` candidates from a vector store (over-fetch)`]}),`\n`,_jsx(_components.li,{children:`The cross-encoder scores every candidate against the query in a single batch`}),`\n`,_jsxs(_components.li,{children:[`Results are re-sorted by cross-encoder score and truncated to `,_jsx(_components.code,{children:`top_k`})]}),`\n`]}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`enabling-the-reranker`,children:`Enabling the reranker`}),`\n`,_jsxs(_components.p,{children:[`Reranking is `,_jsx(_components.strong,{children:`disabled by default`}),`. Enable it with a single config flag:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`11`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`11`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` memwire `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MemWire, MemWireConfig`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`config `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MemWireConfig(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` qdrant_path`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"./memwire_data\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` use_reranking`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`memory `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MemWire(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`config`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`config)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`results `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` memory.search(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"when is the project deadline?\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`user_id`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"alice\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`top_k`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`5`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`for`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` record, score `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`in`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` results:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"[`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`score`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`:.4f}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`record.content`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`The model is `,_jsx(_components.strong,{children:`lazy-loaded`}),`, it is downloaded and initialised only on the first `,_jsx(_components.code,{children:`search()`}),` call that triggers reranking, not at every startup.`]}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`changing-the-model`,children:`Changing the model`}),`\n`,_jsxs(_components.p,{children:[`The default model is `,_jsx(_components.code,{children:`Xenova/ms-marco-MiniLM-L-6-v2`}),`, a lightweight MS MARCO-trained cross-encoder. Swap it via `,_jsx(_components.code,{children:`reranker_model_name`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`config `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MemWireConfig(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` qdrant_path`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"./memwire_data\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` use_reranking`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` reranker_model_name`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Xenova/ms-marco-MiniLM-L-6-v2\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# default`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Any ONNX cross-encoder supported by FastEmbed can be used here.`}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`combining-with-hybrid-search`,children:`Combining with hybrid search`}),`\n`,_jsx(_components.p,{children:`For the best retrieval quality, run both hybrid search and reranking together:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`config `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MemWireConfig(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` qdrant_path`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"./memwire_data\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` use_hybrid_search`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# dense + sparse retrieval (default)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` use_reranking`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# cross-encoder rescoring on top`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`memory `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MemWire(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`config`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`config)`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`The pipeline becomes: `,_jsx(_components.strong,{children:`sparse + dense fusion → cross-encoder rescore → top-k`}),`.`]}),`\n`,_jsx(Tip,{children:_jsx(_components.p,{children:`Hybrid search and reranking complement each other. Hybrid search maximises recall; the reranker maximises precision from those candidates.`})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`performance-considerations`,children:`Performance considerations`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Concern`}),_jsx(_components.th,{children:`Detail`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`First call latency`})}),_jsx(_components.td,{children:`The ONNX model is downloaded once (~85 MB) and cached by FastEmbed.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Per-query latency`})}),_jsxs(_components.td,{children:[`Cross-encoder scores `,_jsx(_components.code,{children:`top_k × 2`}),` documents in a single batched ONNX forward pass — typically 10–50 ms on CPU.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Memory`})}),_jsx(_components.td,{children:`The reranker model stays resident after first use (~100 MB RAM).`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.strong,{children:`Privacy`})}),_jsx(_components.td,{children:`Everything runs locally. No query or memory content is sent to any external service.`})]})]})]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Reranking only applies to `,_jsx(_components.code,{children:`search()`}),`. The `,_jsx(_components.code,{children:`recall()`}),` method uses graph-based BFS traversal and is not affected by `,_jsx(_components.code,{children:`use_reranking`}),`.`]})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`configuration-reference`,children:`Configuration reference`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Default`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`use_reranking`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`False`})}),_jsxs(_components.td,{children:[`Enable cross-encoder reranking on `,_jsx(_components.code,{children:`search()`}),` results.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`reranker_model_name`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`Xenova/ms-marco-MiniLM-L-6-v2`})}),_jsx(_components.td,{children:`FastEmbed-compatible cross-encoder model name.`})]})]})]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Reranker","description":"Boost search precision with a local cross-encoder that rescores candidates using full query-document attention.","href":"/features/reranker","hidden":false}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"How it works","slug":"how-it-works","depth":2,"children":[]},{"title":"Enabling the reranker","slug":"enabling-the-reranker","depth":2,"children":[]},{"title":"Changing the model","slug":"changing-the-model","depth":2,"children":[]},{"title":"Combining with hybrid search","slug":"combining-with-hybrid-search","depth":2,"children":[]},{"title":"Performance considerations","slug":"performance-considerations","depth":2,"children":[]},{"title":"Configuration reference","slug":"configuration-reference","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"memwire","siteName":"MemWire","title":"Reranker - MemWire","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-03-15T08:54:14.174Z","originalFileLocation":"features/reranker.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Boost search precision with a local cross-encoder that rescores candidates using full query-document attention.\">\u003cmeta data-mint-head name=\"application-name\" content=\"MemWire\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/memwire/r7qdU7d8pI2vVYA6/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/memwire/r7qdU7d8pI2vVYA6/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/memwire/r7qdU7d8pI2vVYA6/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/memwire/r7qdU7d8pI2vVYA6/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/memwire/r7qdU7d8pI2vVYA6/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/memwire/r7qdU7d8pI2vVYA6/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/memwire/r7qdU7d8pI2vVYA6/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/memwire/r7qdU7d8pI2vVYA6/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/memwire/r7qdU7d8pI2vVYA6/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Reranker - MemWire\">\u003cmeta data-mint-head property=\"og:description\" content=\"Boost search precision with a local cross-encoder that rescores candidates using full query-document attention.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"MemWire\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://memwirelabs.ai/features/reranker\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://memwire.mintlify.app/_mintlify/api/og/v2?division=Features\u0026amp;title=Reranker\u0026amp;description=Boost+search+precision+with+a+local+cross-encoder+that+rescores+candidates+using+full+query-document+attention.\u0026amp;theme=cc464b15e44a8b28ed0b8d9a\u0026amp;signature=8e034592010e8e6aa2a593bf0ec10fd4fe20a5b3600f5522880be551c68aad66\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Reranker - MemWire\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Boost search precision with a local cross-encoder that rescores candidates using full query-document attention.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://memwire.mintlify.app/_mintlify/api/og/v2?division=Features\u0026amp;title=Reranker\u0026amp;description=Boost+search+precision+with+a+local+cross-encoder+that+rescores+candidates+using+full+query-document+attention.\u0026amp;theme=cc464b15e44a8b28ed0b8d9a\u0026amp;signature=8e034592010e8e6aa2a593bf0ec10fd4fe20a5b3600f5522880be551c68aad66\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/memwire/r7qdU7d8pI2vVYA6/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"MemWire\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#6366f1\">\u003clink data-mint-head rel=\"canonical\" href=\"https://memwirelabs.ai/features/reranker\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/features/reranker.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://memwirelabs.ai/#organization\",\"name\":\"MemWire\",\"url\":\"https://memwirelabs.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/memwire/TxHdS7hR2Dea58P8/logo/logo-dark.png?fit=max\u0026auto=format\u0026n=TxHdS7hR2Dea58P8\u0026q=85\u0026s=24fcfb12210bffb594d64c96502c25d9\"}},{\"@type\":\"WebSite\",\"@id\":\"https://memwirelabs.ai#website\",\"name\":\"MemWire\",\"url\":\"https://memwirelabs.ai\",\"publisher\":{\"@id\":\"https://memwirelabs.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://memwirelabs.ai/features/reranker#webpage\",\"url\":\"https://memwirelabs.ai/features/reranker\",\"name\":\"Reranker\",\"description\":\"Boost search precision with a local cross-encoder that rescores candidates using full query-document attention.\",\"dateModified\":\"2026-03-15T08:54:14.174Z\",\"isPartOf\":{\"@id\":\"https://memwirelabs.ai#website\"},\"breadcrumb\":{\"@id\":\"https://memwirelabs.ai/features/reranker#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://memwirelabs.ai/features/reranker#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Features\",\"item\":\"https://memwirelabs.ai/features/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Reranker\",\"item\":\"https://memwirelabs.ai/features/reranker\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://memwirelabs.ai/features/reranker#article\",\"headline\":\"Reranker\",\"name\":\"Reranker\",\"description\":\"Boost search precision with a local cross-encoder that rescores candidates using full query-document attention.\",\"url\":\"https://memwirelabs.ai/features/reranker\",\"mainEntityOfPage\":{\"@id\":\"https://memwirelabs.ai/features/reranker#webpage\"},\"dateModified\":\"2026-03-15T08:54:14.174Z\",\"publisher\":{\"@id\":\"https://memwirelabs.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://memwirelabs.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"MemWire\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"MemWire","nav":{"global":{"anchors":[{"anchor":"GitHub","icon":"github","href":"https://github.com/memoryoss/memwire"},{"anchor":"Roadmap","icon":"map","href":"https://github.com/memoryoss/memwire/blob/main/ROADMAP.md"}]},"tabs":[{"tab":"Open Source","groups":[{"group":"Getting started","pages":[{"title":"Introduction","icon":"book-open","href":""},{"title":"Quickstart","icon":"rocket","href":"/quickstart"}]},{"group":"Features","pages":[{"title":"Overview","href":"/features/overview"},{"title":"Graph Memory","href":"/features/graph-memory"},{"title":"Multi-Tenancy","href":"/features/multi-tenancy"},{"title":"Knowledge Base","href":"/features/knowledge-base"},{"title":"Hybrid Search","description":"Combine dense semantic vectors and sparse SPLADE keyword vectors for higher-recall retrieval.","href":"/features/hybrid-search"},{"title":"Reranker","href":"/features/reranker"},{"title":"LLM-Free Classification","description":"Auto-tag every memory by any category and no external LLM API calls.","href":"/features/llm-free-classification"},{"title":"Adaptive Feedback Loop","href":"/features/adaptive-feedback"}]},{"group":"Configuration","pages":[{"title":"Configure OSS Stack","icon":"sliders","href":"/configuration"},{"group":"Vector Databases","icon":"hard-drive","pages":[{"title":"Overview","href":"/vector-databases"},{"title":"Qdrant","href":"/vector-databases/qdrant"}]},{"group":"Embedding Models","icon":"cube","pages":[{"title":"Overview","href":"/embedders"},{"title":"FastEmbed","href":"/embedders/fastembed"}]},{"group":"LLMs","icon":"message-bot","pages":[{"title":"Overview","href":"/llms"},{"title":"OpenAI","href":"/llms/openai"},{"title":"Azure OpenAI","href":"/llms/azure-openai"}]}]}]},{"tab":"API reference","pages":[{"title":"API reference","href":"/api-reference/introduction"}]}]},"title":"Reranker - MemWire","buildId":"dpl_EnxDqhjaNc9a8MVa833TGULPd9uJ","deploymentId":"dpl_EnxDqhjaNc9a8MVa833TGULPd9uJ","dynamics":[],"chunks":[]}