1:"$Sreact.fragment" 2:I[56271,["2545","static/chunks/c16f53c3-391a1f5a73546b11.js","2619","static/chunks/2619-eccd988d1e161df3.js","3353","static/chunks/3353-35c19838f8cf7b3b.js","7177","static/chunks/app/layout-cb4429a7e3e88a9f.js"],"ThemeProviders"] 3:I[41402,["2545","static/chunks/c16f53c3-391a1f5a73546b11.js","2619","static/chunks/2619-eccd988d1e161df3.js","3353","static/chunks/3353-35c19838f8cf7b3b.js","7177","static/chunks/app/layout-cb4429a7e3e88a9f.js"],""] 4:I[91367,["2545","static/chunks/c16f53c3-391a1f5a73546b11.js","2619","static/chunks/2619-eccd988d1e161df3.js","3353","static/chunks/3353-35c19838f8cf7b3b.js","7177","static/chunks/app/layout-cb4429a7e3e88a9f.js"],"KBarSearchProvider"] 5:I[52619,["2619","static/chunks/2619-eccd988d1e161df3.js","1356","static/chunks/1356-354ecf51aaaf5203.js","6909","static/chunks/app/blog/%5B...slug%5D/page-d416e20a09ba8ecb.js"],""] 6:I[51350,["2545","static/chunks/c16f53c3-391a1f5a73546b11.js","2619","static/chunks/2619-eccd988d1e161df3.js","3353","static/chunks/3353-35c19838f8cf7b3b.js","7177","static/chunks/app/layout-cb4429a7e3e88a9f.js"],"KBarButton"] 10:I[57150,[],""] :HL["/_next/static/css/29ff447a95e95257.css","style"] :HL["/_next/static/css/77af622156c5e021.css","style"] :HL["/_next/static/css/ddf3d904beac0ed7.css","style"] 0:{"P":null,"b":"FUTryh0Sm2lrVLTvF5oMH","p":"","c":["","blog","rag-pipeline-architecture"],"i":false,"f":[[["",{"children":["blog",{"children":[["slug","rag-pipeline-architecture","c"],{"children":["__PAGE__",{}]}]}]},"$undefined","$undefined",true],["",["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/29ff447a95e95257.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/_next/static/css/77af622156c5e021.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}]],["$","html",null,{"lang":"zh-cn","className":"scroll-smooth","suppressHydrationWarning":true,"children":[["$","link",null,{"rel":"apple-touch-icon","sizes":"76x76","href":"/static/favicons/apple-touch-icon.png"}],["$","link",null,{"rel":"icon","type":"image/png","sizes":"32x32","href":"/static/favicons/favicon-32x32.png"}],["$","link",null,{"rel":"icon","type":"image/png","sizes":"16x16","href":"/static/favicons/favicon-16x16.png"}],["$","link",null,{"rel":"manifest","href":"/static/favicons/site.webmanifest"}],["$","link",null,{"rel":"mask-icon","href":"/static/favicons/safari-pinned-tab.svg","color":"#5bbad5"}],["$","meta",null,{"name":"msapplication-TileColor","content":"#4f46e5"}],["$","meta",null,{"name":"theme-color","media":"(prefers-color-scheme: light)","content":"#ffffff"}],["$","meta",null,{"name":"theme-color","media":"(prefers-color-scheme: dark)","content":"#0f172a"}],["$","link",null,{"rel":"alternate","type":"application/rss+xml","href":"/feed.xml"}],["$","body",null,{"className":"bg-white pl-[calc(100vw-100%)] text-black antialiased dark:bg-gray-950 dark:text-white","children":["$","$L2",null,{"children":[["$undefined","$undefined","$undefined",["$","$L3",null,{"async":true,"defer":true,"src":"https://analytics.umami.is/script.js"}],"$undefined","$undefined"],["$","section",null,{"className":"mx-auto max-w-3xl px-4 sm:px-6 xl:max-w-5xl xl:px-0","children":[["$","$L4",null,{"kbarConfig":{"searchDocumentsPath":"/search.json"},"children":[["$","header",null,{"className":"flex items-center w-full bg-white dark:bg-gray-950 justify-between py-10","children":[["$","$L5",null,{"className":"break-words","href":"/","aria-label":"TechLog","children":["$","div",null,{"className":"flex items-center justify-between","children":[["$","div",null,{"className":"mr-3","children":["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","xmlnsXlink":"http://www.w3.org/1999/xlink","width":53.87,"height":43.61,"viewBox":"344.564 330.278 111.737 91.218","children":[["$","defs",null,{"children":[["$","linearGradient",null,{"id":"logo_svg__b","x1":420.97,"x2":420.97,"y1":331.28,"y2":418.5,"gradientUnits":"userSpaceOnUse","children":[["$","stop",null,{"offset":"0%","style":{"stopColor":"#06b6d4","stopOpacity":1}}],["$","stop",null,{"offset":"100%","style":{"stopColor":"#67e8f9","stopOpacity":1}}]]}],["$","linearGradient",null,{"id":"logo_svg__d","x1":377.89,"x2":377.89,"y1":331.28,"y2":418.5,"gradientUnits":"userSpaceOnUse","children":[["$","stop",null,{"offset":"0%","style":{"stopColor":"#06b6d4","stopOpacity":1}}],["$","stop",null,{"offset":"100%","style":{"stopColor":"#67e8f9","stopOpacity":1}}]]}],["$","path",null,{"id":"logo_svg__a","d":"M453.3 331.28v28.57l-64.66 58.65v-30.08z"}],["$","path",null,{"id":"logo_svg__c","d":"M410.23 331.28v28.57l-64.67 58.65v-30.08z"}]]}],["$","use",null,{"xlinkHref":"#logo_svg__a","fill":"url(#logo_svg__b)"}],["$","use",null,{"xlinkHref":"#logo_svg__c","fill":"url(#logo_svg__d)"}]]}]}],["$","div",null,{"className":"hidden h-6 text-2xl font-semibold sm:block","children":"TechLog"}]]}]}],["$","div",null,{"className":"flex items-center space-x-4 leading-5 sm:-mr-6 sm:space-x-6","children":[["$","div",null,{"className":"no-scrollbar hidden max-w-40 items-center gap-x-4 overflow-x-auto sm:flex md:max-w-72 lg:max-w-96","children":[["$","$L5","博客",{"className":"hover:text-primary-500 dark:hover:text-primary-400 m-1 font-medium text-gray-900 dark:text-gray-100","href":"/blog.html","children":"博客"}],["$","$L5","标签",{"className":"hover:text-primary-500 dark:hover:text-primary-400 m-1 font-medium text-gray-900 dark:text-gray-100","href":"/tags.html","children":"标签"}],["$","$L5","项目",{"className":"hover:text-primary-500 dark:hover:text-primary-400 m-1 font-medium text-gray-900 dark:text-gray-100","href":"/projects.html","children":"项目"}],["$","$L5","关于",{"className":"hover:text-primary-500 dark:hover:text-primary-400 m-1 font-medium text-gray-900 dark:text-gray-100","href":"/about.html","children":"关于"}]]}],["$","$L6",null,{"aria-label":"Search","children":["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","fill":"none","viewBox":"0 0 24 24","strokeWidth":1.5,"stroke":"currentColor","className":"hover:text-primary-500 dark:hover:text-primary-400 h-6 w-6 text-gray-900 dark:text-gray-100","children":"$L7"}]}],"$L8","$L9"]}]]}],"$La"]}],"$Lb"]}]]}]}]]}]]}],{"children":["blog","$Lc",{"children":[["slug","rag-pipeline-architecture","c"],"$Ld",{"children":["__PAGE__","$Le",{},null,false]},null,false]},null,false]},null,false],"$Lf",false]],"m":"$undefined","G":["$10",[]],"s":false,"S":true} 11:I[49217,["2545","static/chunks/c16f53c3-391a1f5a73546b11.js","2619","static/chunks/2619-eccd988d1e161df3.js","3353","static/chunks/3353-35c19838f8cf7b3b.js","7177","static/chunks/app/layout-cb4429a7e3e88a9f.js"],"default"] 12:I[394,["2545","static/chunks/c16f53c3-391a1f5a73546b11.js","2619","static/chunks/2619-eccd988d1e161df3.js","3353","static/chunks/3353-35c19838f8cf7b3b.js","7177","static/chunks/app/layout-cb4429a7e3e88a9f.js"],"default"] 13:I[9766,[],""] 14:I[98924,[],""] 16:I[24431,[],"OutletBoundary"] 18:I[15278,[],"AsyncMetadataOutlet"] 1a:I[24431,[],"ViewportBoundary"] 1c:I[24431,[],"MetadataBoundary"] 1d:"$Sreact.suspense" 7:["$","path",null,{"strokeLinecap":"round","strokeLinejoin":"round","d":"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"}] 8:["$","$L11",null,{}] 9:["$","$L12",null,{}] a:["$","main",null,{"className":"mb-auto","children":["$","$L13",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L14",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","div",null,{"className":"flex flex-col items-start justify-start md:mt-24 md:flex-row md:items-center md:justify-center md:space-x-6","children":[["$","div",null,{"className":"space-x-2 pt-6 pb-8 md:space-y-5","children":["$","h1",null,{"className":"text-6xl leading-9 font-extrabold tracking-tight text-gray-900 md:border-r-2 md:px-6 md:text-8xl md:leading-14 dark:text-gray-100","children":"404"}]}],["$","div",null,{"className":"max-w-md","children":[["$","p",null,{"className":"mb-4 text-xl leading-normal font-bold md:text-2xl","children":"Sorry we couldn't find this page."}],["$","p",null,{"className":"mb-8","children":"But dont worry, you can find plenty of other things on our homepage."}],["$","$L5",null,{"className":"focus:shadow-outline-blue inline rounded-lg border border-transparent bg-blue-600 px-4 py-2 text-sm leading-5 font-medium text-white shadow-xs transition-colors duration-150 hover:bg-blue-700 focus:outline-hidden dark:hover:bg-blue-500","href":"/","children":"Back to homepage"}]]}]]}],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}] b:["$","footer",null,{"children":["$","div",null,{"className":"mt-16 flex flex-col items-center","children":[["$","div",null,{"className":"mb-3 flex space-x-4","children":[["$","a",null,{"className":"text-sm text-gray-500 transition hover:text-gray-600","target":"_blank","rel":"noopener noreferrer","href":"mailto:birenwenmou@qq.com","children":[["$","span",null,{"className":"sr-only","children":"mail"}],["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 20 20","className":"hover:text-primary-500 dark:hover:text-primary-400 fill-current text-gray-700 dark:text-gray-200 h-6 w-6","children":[["$","title",null,{"children":"Mail"}],["$","path",null,{"d":"M2.003 5.884L10 9.882l7.997-3.998A2 2 0 0016 4H4a2 2 0 00-1.997 1.884z"}],["$","path",null,{"d":"M18 8.118l-8 4-8-4V14a2 2 0 002 2h12a2 2 0 002-2V8.118z"}]]}]]}],["$","a",null,{"className":"text-sm text-gray-500 transition hover:text-gray-600","target":"_blank","rel":"noopener noreferrer","href":"https://github.com/joker1point","children":[["$","span",null,{"className":"sr-only","children":"github"}],["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 24 24","className":"hover:text-primary-500 dark:hover:text-primary-400 fill-current text-gray-700 dark:text-gray-200 h-6 w-6","children":[["$","title",null,{"children":"GitHub"}],["$","path",null,{"d":"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"}]]}]]}],null,null,null,null,null,null,null,null,null]}],["$","div",null,{"className":"mb-2 flex space-x-2 text-sm text-gray-500 dark:text-gray-400","children":[["$","div",null,{"children":"眠月"}],["$","div",null,{"children":" • "}],["$","div",null,{"children":"© 2026"}],["$","div",null,{"children":" • "}],["$","$L5",null,{"className":"break-words","href":"/","children":"TechLog"}]]}],["$","div",null,{"className":"mb-8 text-sm text-gray-500 dark:text-gray-400","children":["$","a",null,{"className":"break-words","target":"_blank","rel":"noopener noreferrer","href":"https://github.com/joker1point","children":"GitHub"}]}]]}]}] c:["$","$1","c",{"children":[null,["$","$L13",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L14",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]]}] d:["$","$1","c",{"children":[null,["$","$L13",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L14",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]]}] e:["$","$1","c",{"children":["$L15",[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/ddf3d904beac0ed7.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}]],["$","$L16",null,{"children":["$L17",["$","$L18",null,{"promise":"$@19"}]]}]]}] f:["$","$1","h",{"children":[null,[["$","$L1a",null,{"children":"$L1b"}],null],["$","$L1c",null,{"children":["$","div",null,{"hidden":true,"children":["$","$1d",null,{"fallback":null,"children":"$L1e"}]}]}]]}] 1f:I[62088,["2619","static/chunks/2619-eccd988d1e161df3.js","1356","static/chunks/1356-354ecf51aaaf5203.js","6909","static/chunks/app/blog/%5B...slug%5D/page-d416e20a09ba8ecb.js"],"default"] 20:I[81356,["2619","static/chunks/2619-eccd988d1e161df3.js","1356","static/chunks/1356-354ecf51aaaf5203.js","6909","static/chunks/app/blog/%5B...slug%5D/page-d416e20a09ba8ecb.js"],"Image"] 15:[["$","script",null,{"type":"application/ld+json","dangerouslySetInnerHTML":{"__html":"{\"@context\":\"https://schema.org\",\"@type\":\"BlogPosting\",\"headline\":\"RAG 链路全解析:从文档入库到混合记忆的实战架构\",\"datePublished\":\"2026-06-04T00:00:00.000Z\",\"dateModified\":\"2026-06-04T00:00:00.000Z\",\"description\":\"详述 RAG(检索增强生成)的完整技术链路,包括文档入库、向量化、召回重排、Prompt 拼接,以及基于 Node.js + ChromaDB + SQLite 的三层混合记忆进阶方案。\",\"image\":\"/static/images/twitter-card.png\",\"url\":\"https://techlog-18328.app.workbuddy.host/blog/rag-pipeline-architecture\",\"author\":[{\"@type\":\"Person\",\"name\":\"眠月\"}]}"}}],["$","section",null,{"className":"mx-auto max-w-3xl px-4 sm:px-6 xl:max-w-5xl xl:px-0","children":[["$","$L1f",null,{}],["$","article",null,{"children":["$","div",null,{"className":"xl:divide-y xl:divide-gray-200 xl:dark:divide-gray-700","children":[["$","header",null,{"className":"pt-6 xl:pb-6","children":["$","div",null,{"className":"space-y-1 text-center","children":[["$","dl",null,{"className":"space-y-10","children":[["$","div",null,{"children":[["$","dt",null,{"className":"sr-only","children":"Published on"}],["$","dd",null,{"className":"text-base leading-6 font-medium text-gray-500 dark:text-gray-400","children":["$","time",null,{"dateTime":"2026-06-04T00:00:00.000Z","children":"2026年6月4日星期四"}]}]]}],["$","div",null,{"children":[["$","dt",null,{"className":"sr-only","children":"Word count"}],["$","dd",null,{"className":"text-sm text-gray-400 dark:text-gray-500","children":["2,534"," 字"," · 阅读约 9 分钟"]}]]}]]}],["$","div",null,{"children":["$","h1",null,{"className":"text-3xl leading-9 font-extrabold tracking-tight text-gray-900 sm:text-4xl sm:leading-10 md:text-5xl md:leading-14 dark:text-gray-100","children":"RAG 链路全解析:从文档入库到混合记忆的实战架构"}]}]]}]}],["$","div",null,{"className":"grid-rows-[auto_1fr] divide-y divide-gray-200 pb-8 xl:grid xl:grid-cols-4 xl:gap-x-6 xl:divide-y-0 dark:divide-gray-700","children":[["$","dl",null,{"className":"pt-6 pb-10 xl:border-b xl:border-gray-200 xl:pt-11 xl:dark:border-gray-700","children":[["$","dt",null,{"className":"sr-only","children":"Authors"}],["$","dd",null,{"children":["$","ul",null,{"className":"flex flex-wrap justify-center gap-4 sm:space-x-12 xl:block xl:space-y-8 xl:space-x-0","children":[["$","li","眠月",{"className":"flex items-center space-x-2","children":[["$","$L20",null,{"src":"/static/images/avatar.png","width":38,"height":38,"alt":"avatar","className":"h-10 w-10 rounded-full"}],["$","dl",null,{"className":"text-sm leading-5 font-medium whitespace-nowrap","children":[["$","dt",null,{"className":"sr-only","children":"Name"}],["$","dd",null,{"className":"text-gray-900 dark:text-gray-100","children":"眠月"}],["$","dt",null,{"className":"sr-only","children":"Twitter"}],["$","dd",null,{"children":""}]]}]]}]]}]}]]}],["$","div",null,{"className":"divide-y divide-gray-200 xl:col-span-3 xl:row-span-2 xl:pb-0 dark:divide-gray-700","children":[["$","div",null,{"className":"prose dark:prose-invert max-w-none pt-10 pb-8","children":[["$","blockquote",null,{"children":["$","p",null,{"children":"一套超越传统 RAG、融合长期记忆与动态状态的智能体架构"}]}],["$","h2",null,{"className":"content-header","id":"引言为什么需要重新思考-rag","children":[["$","a",null,{"className":"break-words","href":"#引言为什么需要重新思考-rag","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"引言:为什么需要重新思考 RAG?"]}],["$","p",null,{"children":["传统的 RAG 系统大多遵循一个标准流程:",["$","strong",null,{"children":"文档切块 → Embedding → 向量库 → TopK 检索 → Prompt 拼接 → LLM 回答"}],"。这个链路在处理简单的知识问答场景时表现出色,但当面对需要",["$","strong",null,{"children":"长期记忆用户偏好、理解对话上下文、感知情绪状态"}],"的复杂对话场景时,就显得力不从心了。"]}],"$L21","$L22","$L23","$L24","$L25","$L26","$L27","$L28","$L29","$L2a","$L2b","$L2c","$L2d","$L2e","$L2f","$L30","$L31","$L32","$L33","$L34","$L35","$L36","$L37","$L38","$L39","$L3a","$L3b","$L3c","$L3d","$L3e","$L3f","$L40","$L41","$L42","$L43","$L44","$L45","$L46","$L47","$L48","$L49","$L4a","$L4b","$L4c","$L4d","$L4e","$L4f","$L50","$L51","$L52","$L53","$L54","$L55","$L56","$L57","$L58","$L59","$L5a","$L5b","$L5c","$L5d","$L5e","$L5f","$L60","$L61","$L62","$L63","$L64","$L65","$L66","$L67","$L68","$L69","$L6a","$L6b","$L6c","$L6d","$L6e"]}],"$L6f","$L70"]}],"$L71"]}]]}]}]]}]] 72:I[16991,["2619","static/chunks/2619-eccd988d1e161df3.js","1356","static/chunks/1356-354ecf51aaaf5203.js","6909","static/chunks/app/blog/%5B...slug%5D/page-d416e20a09ba8ecb.js"],"default"] 8b:I[50528,["2619","static/chunks/2619-eccd988d1e161df3.js","1356","static/chunks/1356-354ecf51aaaf5203.js","6909","static/chunks/app/blog/%5B...slug%5D/page-d416e20a09ba8ecb.js"],"default"] 21:["$","p",null,{"children":["本文将分享一套经过实战检验的 RAG 增强架构,它不仅完成了基础的文档检索功能,更重要的是,通过",["$","strong",null,{"children":"三层记忆混合方案"}],",让 AI 真正具备了\"记住\"和\"感知\"的能力。"]}] 22:["$","hr",null,{}] 23:["$","h2",null,{"className":"content-header","id":"第一部分基础-rag-链路回顾","children":[["$","a",null,{"className":"break-words","href":"#第一部分基础-rag-链路回顾","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"第一部分:基础 RAG 链路回顾"]}] 24:["$","p",null,{"children":"先来快速回顾一下标准 RAG 的核心流程,这是整个架构的基石:"}] 25:["$","div",null,{"className":"w-full overflow-x-auto","children":["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{"children":"阶段"}],["$","th",null,{"children":"核心任务"}],["$","th",null,{"children":"技术要点"}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"1. 文档入库"}]}],["$","td",null,{"children":"多源文档清洗与切块"}],["$","td",null,{"children":"PDF、网页、Markdown、数据库内容先清洗,再按段落或语义切块"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"2. 向量化"}]}],["$","td",null,{"children":"Chunk 转向量并存储"}],["$","td",null,{"children":"通过 Embedding 模型转成向量,写入 Milvus、FAISS、Qdrant、pgvector 等向量库"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"3. 用户提问"}]}],["$","td",null,{"children":"问题向量化"}],["$","td",null,{"children":"用户问题也转成向量,用相似度检索相关 chunk"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"4. 召回与重排"}]}],["$","td",null,{"children":"精准筛选相关片段"}],["$","td",null,{"children":"先粗召回 TopK,再用 Reranker 选出最相关片段"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"5. 生成答案"}]}],["$","td",null,{"children":"Prompt 组装与 LLM 调用"}],["$","td",null,{"children":"把用户问题、检索片段、回答规则拼成 Prompt,交给 LLM 生成最终回答"}]]}]]}]]}]}] 26:["$","p",null,{"children":["这个流程解决的是\"",["$","strong",null,{"children":"知识从哪里来"}],"\"的问题。但对话系统还需要解决\"",["$","strong",null,{"children":"过去说过什么"}],"\"和\"",["$","strong",null,{"children":"现在什么状态"}],"\"的问题——这就是三层混合记忆方案登场的时刻。"]}] 27:["$","hr",null,{}] 28:["$","h2",null,{"className":"content-header","id":"第二部分三层混合记忆架构","children":[["$","a",null,{"className":"break-words","href":"#第二部分三层混合记忆架构","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"第二部分:三层混合记忆架构"]}] 29:["$","p",null,{"children":"我设计了一个三层并行的记忆系统,让 AI 能够像人一样,拥有\"过目不忘\"的底片式记忆、\"提纲挈领\"的摘要记忆,以及\"随用随取\"的工作记忆。"}] 2a:["$","h3",null,{"className":"content-header","id":"架构全景图","children":[["$","a",null,{"className":"break-words","href":"#架构全景图","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"架构全景图"]}] 2b:["$","$L72",null,{"className":"language-js","children":["$","code",null,{"className":"language-js code-highlight","children":[["$","span",null,{"className":"code-line","children":"┌─────────────────────────────────────────────────────────────────────────────┐\n"}],["$","span",null,{"className":"code-line","children":"│ 三层混合记忆架构 │\n"}],["$","span",null,{"className":"code-line","children":"├─────────────────────────────────────────────────────────────────────────────┤\n"}],["$","span",null,{"className":"code-line","children":"│ │\n"}],["$","span",null,{"className":"code-line","children":"│ ┌─────────────────┐ │\n"}],["$","span",null,{"className":"code-line","children":"│ │ 用户提问 │ │\n"}],["$","span",null,{"className":"code-line","children":"│ └────────┬────────┘ │\n"}],["$","span",null,{"className":"code-line","children":"│ │ │\n"}],["$","span",null,{"className":"code-line","children":"│ ▼ │\n"}],["$","span",null,{"className":"code-line","children":"│ ┌─────────────────────────────────────────────────────────────────────┐ │\n"}],["$","span",null,{"className":"code-line","children":"│ │ 三层记忆并行检索 │ │\n"}],["$","span",null,{"className":"code-line","children":"│ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │\n"}],["$","span",null,{"className":"code-line","children":"│ │ │ 第一层 │ │ 第二层 │ │ 第三层 │ │ │\n"}],["$","span",null,{"className":"code-line","children":["│ │ │ 全量留存 │ │ 滚动摘要 │ │ ",["$","span",null,{"className":"token constant","children":"RAG"}]," 记忆 │ │ │\n"]}],["$","span",null,{"className":"code-line","children":["│ │ ",["$","span",null,{"className":"token function","children":"│"}]," ",["$","span",null,{"className":"token punctuation","children":"("}],"底片层",["$","span",null,{"className":"token punctuation","children":")"}]," │ ",["$","span",null,{"className":"token function","children":"│"}]," ",["$","span",null,{"className":"token punctuation","children":"("}],"摘要层",["$","span",null,{"className":"token punctuation","children":")"}]," │ ",["$","span",null,{"className":"token function","children":"│"}]," ",["$","span",null,{"className":"token punctuation","children":"("}],"向量层",["$","span",null,{"className":"token punctuation","children":")"}]," │ │ │\n"]}],["$","span",null,{"className":"code-line","children":"│ │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │ │\n"}],["$","span",null,{"className":"code-line","children":"│ │ │ │ │ │ │\n"}],["$","span",null,{"className":"code-line","children":"│ │ ▼ ▼ ▼ │ │\n"}],["$","span",null,{"className":"code-line","children":"│ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │\n"}],["$","span",null,{"className":"code-line","children":["│ │ │ ",["$","span",null,{"className":"token maybe-class-name","children":"SQLite"}]," │ │ 每",["$","span",null,{"className":"token number","children":"50"}],"条 │ │ 向量数据库 │ │ │\n"]}],["$","span",null,{"className":"code-line","children":["│ │ │ 全量存储 │ │ 生成摘要 │ │ ",["$","span",null,{"className":"token maybe-class-name","children":"ChromaDB"}]," │ │ │\n"]}],["$","span",null,{"className":"code-line","children":"│ │ └──────────────┘ └──────────────┘ └──────────────┘ │ │\n"}],["$","span",null,{"className":"code-line","children":"│ └─────────────────────────────────────────────────────────────────────┘ │\n"}],"$L73","$L74","$L75","$L76","$L77","$L78","$L79","$L7a","$L7b","$L7c","$L7d","$L7e","$L7f","$L80","$L81","$L82","$L83","$L84","$L85","$L86","$L87","$L88","$L89","$L8a"]}]}] 2c:["$","h3",null,{"className":"content-header","id":"第一层全量留存底片层","children":[["$","a",null,{"className":"break-words","href":"#第一层全量留存底片层","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"第一层:全量留存(底片层)"]}] 2d:["$","blockquote",null,{"children":["$","p",null,{"children":["$","strong",null,{"children":"\"所有对话,永不删除\""}]}]}] 2e:["$","div",null,{"className":"w-full overflow-x-auto","children":["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{"children":"特性"}],["$","th",null,{"children":"说明"}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"存储介质"}]}],["$","td",null,{"children":"SQLite(better-sqlite3 直连)"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"写入策略"}]}],["$","td",null,{"children":"原始消息全量入库"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"删除策略"}]}],["$","td",null,{"children":"不做物理删除,作为永远的底层底片"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"加密方案"}]}],["$","td",null,{"children":"对敏感字段做加密处理"}]]}]]}]]}]}] 2f:["$","p",null,{"children":"这一层的价值在于:为未来的审计、分析和模型微调保留了完整的数据基础。你可以随时回溯任意时间点的原始对话,进行数据挖掘或模型训练。"}] 30:["$","h3",null,{"className":"content-header","id":"第二层滚动摘要摘要层","children":[["$","a",null,{"className":"break-words","href":"#第二层滚动摘要摘要层","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"第二层:滚动摘要(摘要层)"]}] 31:["$","blockquote",null,{"children":["$","p",null,{"children":["$","strong",null,{"children":"\"50条消息,一次提炼\""}]}]}] 32:["$","div",null,{"className":"w-full overflow-x-auto","children":["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{"children":"特性"}],["$","th",null,{"children":"说明"}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"触发条件"}]}],["$","td",null,{"children":"每积累 50 条消息自动触发"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"生成机制"}]}],["$","td",null,{"children":"调用 LLM 对 50 条消息生成结构化摘要"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"存储方式"}]}],["$","td",null,{"children":"摘要存入 SQLite,与原始消息关联"}]]}]]}]]}]}] 33:["$","p",null,{"children":"这一层解决了长期对话中\"信息过载\"的问题。原始消息数量线性增长,但经过摘要压缩后,关键信息密度大幅提升,为后续检索提供了高效的索引。"}] 34:["$","h3",null,{"className":"content-header","id":"第三层rag-记忆向量层","children":[["$","a",null,{"className":"break-words","href":"#第三层rag-记忆向量层","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"第三层:RAG 记忆(向量层)"]}] 35:["$","blockquote",null,{"children":["$","p",null,{"children":["$","strong",null,{"children":"\"碎片提取,向量召回\""}]}]}] 36:["$","p",null,{"children":"这是最核心、最复杂的一层。系统后台有一个专门的异步模块,持续做三件事:"}] 37:["$","div",null,{"className":"w-full overflow-x-auto","children":["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{"children":"任务"}],["$","th",null,{"children":"说明"}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"事实提取"}]}],["$","td",null,{"children":"从对话中提取客观事实(如\"用户养了一只猫叫Momo\")"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"偏好识别"}]}],["$","td",null,{"children":"记录用户偏好(如\"用户喜欢简洁的回答\")"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"情绪捕捉"}]}],["$","td",null,{"children":"分析情绪状态(如\"用户今天看起来有些焦虑\")"}]]}]]}]]}]}] 38:["$","p",null,{"children":["提取出的碎片经过向量化,存入 ChromaDB。对话时,系统通过",["$","strong",null,{"children":"混合检索"}],"将这些记忆重新召回。"]}] 39:["$","hr",null,{}] 3a:["$","h2",null,{"className":"content-header","id":"第三部分混合检索策略三路召回--rrf","children":[["$","a",null,{"className":"break-words","href":"#第三部分混合检索策略三路召回--rrf","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"第三部分:混合检索策略(三路召回 + RRF)"]}] 3b:["$","p",null,{"children":["单纯依赖向量检索会丢失很多精确信息。我实现了一个",["$","strong",null,{"children":"三路召回 + RRF(倒数排序融合)"}]," 的混合检索策略:"]}] 3c:["$","h3",null,{"className":"content-header","id":"三路召回通道","children":[["$","a",null,{"className":"break-words","href":"#三路召回通道","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"三路召回通道"]}] 3d:["$","$L72",null,{"className":"language-js","children":["$","code",null,{"className":"language-js code-highlight","children":[["$","span",null,{"className":"code-line","children":"┌─────────────────────────────────────────────────────────────────┐\n"}],["$","span",null,{"className":"code-line","children":"│ 三路召回并行执行 │\n"}],["$","span",null,{"className":"code-line","children":"├─────────────────────────────────────────────────────────────────┤\n"}],["$","span",null,{"className":"code-line","children":"│ │\n"}],["$","span",null,{"className":"code-line","children":["│ 通道一:",["$","span",null,{"className":"token constant","children":"FTS5"}]," 关键词检索 │\n"]}],["$","span",null,{"className":"code-line","children":["│ ├── 基于 ",["$","span",null,{"className":"token maybe-class-name","children":"SQLite"}]," 的全文搜索 │\n"]}],["$","span",null,{"className":"code-line","children":"│ ├── 擅长精确匹配(人名、地名、专有名词) │\n"}],["$","span",null,{"className":"code-line","children":["│ └── 返回匹配结果及 ",["$","span",null,{"className":"token constant","children":"BM25"}]," 分数 │\n"]}],["$","span",null,{"className":"code-line","children":"│ │\n"}],["$","span",null,{"className":"code-line","children":"│ 通道二:向量语义检索 │\n"}],["$","span",null,{"className":"code-line","children":["│ ├── ",["$","span",null,{"className":"token maybe-class-name","children":"ChromaDB"}]," 向量相似度检索 │\n"]}],["$","span",null,{"className":"code-line","children":"│ ├── 擅长语义泛化(近义词、相关概念) │\n"}],["$","span",null,{"className":"code-line","children":["│ └── 返回 ",["$","span",null,{"className":"token maybe-class-name","children":"TopK"}]," 向量及余弦相似度 │\n"]}],["$","span",null,{"className":"code-line","children":"│ │\n"}],["$","span",null,{"className":"code-line","children":"│ 通道三:实体聚合检索 │\n"}],["$","span",null,{"className":"code-line","children":"│ ├── 从对话中提取的实体(人、事、物、情绪标签) │\n"}],["$","span",null,{"className":"code-line","children":"│ ├── 按实体类型和重要性加权 │\n"}],["$","span",null,{"className":"code-line","children":"│ └── 返回关联实体对应的记忆碎片 │\n"}],["$","span",null,{"className":"code-line","children":"│ │\n"}],["$","span",null,{"className":"code-line","children":"└─────────────────────────────────────────────────────────────────┘\n"}]]}]}] 3e:["$","h3",null,{"className":"content-header","id":"rrf-融合排序算法","children":[["$","a",null,{"className":"break-words","href":"#rrf-融合排序算法","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"RRF 融合排序算法"]}] 3f:["$","p",null,{"children":["三路召回的结果通过 ",["$","strong",null,{"children":"RRF(Reciprocal Rank Fusion)"}]," 算法进行融合排序:"]}] 40:["$","$L72",null,{"className":"language-js","children":["$","code",null,{"className":"language-js code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token constant","children":"RRF"}]," 得分 ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token function","children":"Σ"}]," ",["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token number","children":"1"}]," ",["$","span",null,{"className":"token operator","children":"/"}]," ",["$","span",null,{"className":"token punctuation","children":"("}],"k ",["$","span",null,{"className":"token operator","children":"+"}]," 排名",["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":")"}],"\n"]}],["$","span",null,{"className":"code-line","children":"\n"}],["$","span",null,{"className":"code-line","children":"其中:\n"}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token operator","children":"-"}]," 排名:某条记忆在单个召回通道中的位置(从",["$","span",null,{"className":"token number","children":"1"}],"开始)\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token operator","children":"-"}]," k:常数,通常取 ",["$","span",null,{"className":"token number","children":"60"}],"\n"]}]]}]}] 41:["$","p",null,{"children":["$","strong",null,{"children":"为什么选择 RRF?"}]}] 42:["$","ul",null,{"children":[["$","li",null,{"children":"不需要对异构分数(BM25、余弦相似度、实体权重)进行归一化"}],["$","li",null,{"children":"对离群值不敏感,融合结果鲁棒"}],["$","li",null,{"children":"计算简单,延迟极低"}]]}] 43:["$","p",null,{"children":"融合后的 TopK 记忆被动态塞入 system prompt 中,作为 LLM 生成的上下文。"}] 44:["$","hr",null,{}] 45:["$","h2",null,{"className":"content-header","id":"第四部分动态状态引擎三层-prompt-叠加","children":[["$","a",null,{"className":"break-words","href":"#第四部分动态状态引擎三层-prompt-叠加","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"第四部分:动态状态引擎(三层 Prompt 叠加)"]}] 46:["$","p",null,{"children":["传统的角色扮演系统通常只有一个固定的 prompt。我在此基础上做了",["$","strong",null,{"children":"三层叠加"}],"设计:"]}] 47:["$","h3",null,{"className":"content-header","id":"三层结构详解","children":[["$","a",null,{"className":"break-words","href":"#三层结构详解","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"三层结构详解"]}] 48:["$","div",null,{"className":"w-full overflow-x-auto","children":["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{"children":"层次"}],["$","th",null,{"children":"内容"}],["$","th",null,{"children":"更新频率"}],["$","th",null,{"children":"作用"}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"固定人格"}]}],["$","td",null,{"children":"角色基础设定(性格、背景、语言风格)"}],["$","td",null,{"children":"永久固定"}],["$","td",null,{"children":"确保角色一致性"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"动态情绪"}]}],["$","td",null,{"children":"实时分析的情绪状态(开心/焦虑/疲惫/兴奋)"}],["$","td",null,{"children":"每轮对话更新"}],["$","td",null,{"children":"让回复更有\"人情味\""}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"动态记忆"}]}],["$","td",null,{"children":"从三层记忆中召回的相关碎片"}],["$","td",null,{"children":"每轮对话动态注入"}],["$","td",null,{"children":"提供长期上下文连贯性"}]]}]]}]]}]}] 49:["$","h3",null,{"className":"content-header","id":"情绪状态引擎的实现","children":[["$","a",null,{"className":"break-words","href":"#情绪状态引擎的实现","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"情绪状态引擎的实现"]}] 4a:["$","p",null,{"children":["这部分参考了 GitHub 上 ",["$","strong",null,{"children":"jiwen 项目"}],"的设计思路。引擎实时分析以下维度:"]}] 4b:["$","div",null,{"className":"w-full overflow-x-auto","children":["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{"children":"维度"}],["$","th",null,{"children":"检测方法"}],["$","th",null,{"children":"输出示例"}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":"基础情绪"}],["$","td",null,{"children":"情感分类模型"}],["$","td",null,{"children":"愉悦/愤怒/悲伤/恐惧/惊讶"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"情绪强度"}],["$","td",null,{"children":"回归模型打分"}],["$","td",null,{"children":"0-1 之间的强度值"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"疲劳指数"}],["$","td",null,{"children":"对话轮次 + 时间衰减"}],["$","td",null,{"children":"连续对话超过30轮自动降低\"兴奋度\""}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"满意度倾向"}],["$","td",null,{"children":"用户回复的情感分析"}],["$","td",null,{"children":"积极/中性/消极"}]]}]]}]]}]}] 4c:["$","p",null,{"children":"这些信号最终被合成为一个\"情绪状态向量\",叠加到 prompt 中。例如:"}] 4d:["$","$L72",null,{"className":"language-js","children":["$","code",null,{"className":"language-js code-highlight","children":[["$","span",null,{"className":"code-line","children":"【当前情绪状态】\n"}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token operator","children":"-"}]," ",["$","span",null,{"className":"token function","children":"基础情绪:愉悦"}]," ",["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token number","children":"0.82"}],["$","span",null,{"className":"token punctuation","children":")"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token operator","children":"-"}]," 强度:中高\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token operator","children":"-"}]," 疲劳指数:低(对话第",["$","span",null,{"className":"token number","children":"8"}],"轮)\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token operator","children":"-"}]," 用户近期满意度:积极\n"]}],["$","span",null,{"className":"code-line","children":"\n"}],["$","span",null,{"className":"code-line","children":"请以关心、温暖的语气回应。\n"}]]}]}] 4e:["$","hr",null,{}] 4f:["$","h2",null,{"className":"content-header","id":"第五部分完整技术栈","children":[["$","a",null,{"className":"break-words","href":"#第五部分完整技术栈","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"第五部分:完整技术栈"]}] 50:["$","h3",null,{"className":"content-header","id":"后端核心","children":[["$","a",null,{"className":"break-words","href":"#后端核心","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"后端核心"]}] 51:["$","div",null,{"className":"w-full overflow-x-auto","children":["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{"children":"组件"}],["$","th",null,{"children":"技术选型"}],["$","th",null,{"children":"理由"}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"应用框架"}]}],["$","td",null,{"children":"Node.js + Express"}],["$","td",null,{"children":"高 I/O 性能,生态成熟"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"数据库"}]}],["$","td",null,{"children":"SQLite + better-sqlite3"}],["$","td",null,{"children":"零配置,同步 API 性能极佳"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"进程管理"}]}],["$","td",null,{"children":"PM2"}],["$","td",null,{"children":"稳定可靠的生产级进程管理"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"外网暴露"}]}],["$","td",null,{"children":"Cloudflare Tunnel"}],["$","td",null,{"children":"无需公网 IP,自带 SSL,配置简单"}]]}]]}]]}]}] 52:["$","h3",null,{"className":"content-header","id":"ai-与检索层","children":[["$","a",null,{"className":"break-words","href":"#ai-与检索层","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"AI 与检索层"]}] 53:["$","div",null,{"className":"w-full overflow-x-auto","children":["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{"children":"组件"}],["$","th",null,{"children":"技术选型"}],["$","th",null,{"children":"理由"}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"向量检索服务"}]}],["$","td",null,{"children":"Python FastAPI + ChromaDB"}],["$","td",null,{"children":"Python 生态对 AI 模型最友好"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"Embedding 模型"}]}],["$","td",null,{"children":"Jina v2 base zh (768维)"}],["$","td",null,{"children":"中文效果好,轻量级"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"推理后端"}]}],["$","td",null,{"children":"ONNX Runtime"}],["$","td",null,{"children":"CPU 推理速度快,无需 GPU"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"混合检索"}]}],["$","td",null,{"children":"FTS5 + 向量检索 + RRF"}],["$","td",null,{"children":"兼顾精确与语义"}]]}]]}]]}]}] 54:["$","h3",null,{"className":"content-header","id":"数据加密","children":[["$","a",null,{"className":"break-words","href":"#数据加密","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"数据加密"]}] 55:["$","div",null,{"className":"w-full overflow-x-auto","children":["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{"children":"内容"}],["$","th",null,{"children":"方案"}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":"敏感字段"}],["$","td",null,{"children":"应用层加密(AES-256-GCM)"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":"SQLite 文件"}],["$","td",null,{"children":"可选文件系统级加密"}]]}]]}]]}]}] 56:["$","hr",null,{}] 57:["$","h2",null,{"className":"content-header","id":"第六部分优化建议与展望","children":[["$","a",null,{"className":"break-words","href":"#第六部分优化建议与展望","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"第六部分:优化建议与展望"]}] 58:["$","p",null,{"children":"这套架构已经在生产环境中稳定运行,以下几个方向值得进一步探索:"}] 59:["$","h3",null,{"className":"content-header","id":"1-向量库的可扩展性","children":[["$","a",null,{"className":"break-words","href":"#1-向量库的可扩展性","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"1. 向量库的可扩展性"]}] 5a:["$","p",null,{"children":["当前 ChromaDB 在文档量 ",["$","strong",null,{"children":"< 10 万"}],"时表现优异。如果知识库持续增长,可以考虑迁移到:"]}] 5b:["$","div",null,{"className":"w-full overflow-x-auto","children":["$","table",null,{"children":[["$","thead",null,{"children":["$","tr",null,{"children":[["$","th",null,{"children":"方案"}],["$","th",null,{"children":"适用场景"}]]}]}],["$","tbody",null,{"children":[["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"Qdrant"}]}],["$","td",null,{"children":"需要高性能、分布式部署"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"Milvus"}]}],["$","td",null,{"children":"超大规模(百万级以上)"}]]}],["$","tr",null,{"children":[["$","td",null,{"children":["$","strong",null,{"children":"sqlite-vec"}]}],["$","td",null,{"children":"希望简化架构,向量与业务数据同库"}]]}]]}]]}]}] 5c:["$","h3",null,{"className":"content-header","id":"2-重排序层reranker的引入","children":[["$","a",null,{"className":"break-words","href":"#2-重排序层reranker的引入","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"2. 重排序层(Reranker)的引入"]}] 5d:["$","p",null,{"children":["目前 RRF 融合工作在",["$","strong",null,{"children":"索引级"}],"。可以增加一个",["$","strong",null,{"children":"模型级重排序"}],"层:"]}] 5e:["$","$L72",null,{"className":"language-js","children":["$","code",null,{"className":"language-js code-highlight","children":["$","span",null,{"className":"code-line","children":["三路召回 → ",["$","span",null,{"className":"token constant","children":"RRF"}]," → ",["$","span",null,{"className":"token maybe-class-name","children":"Top20"}]," → ",["$","span",null,{"className":"token maybe-class-name","children":"Reranker"}]," 模型精排 → ",["$","span",null,{"className":"token maybe-class-name","children":"Top5"}],"\n"]}]}]}] 5f:["$","p",null,{"children":"推荐的 Reranker 模型:"}] 60:["$","ul",null,{"children":[["$","li",null,{"children":[["$","code",null,{"children":"bge-reranker-base"}],"(中文效果优秀)"]}],["$","li",null,{"children":[["$","code",null,{"children":"cross-encoder/ms-marco-MiniLM-L-6-v2"}],"(英文)"]}]]}] 61:["$","h3",null,{"className":"content-header","id":"3-sqlite-性能优化","children":[["$","a",null,{"className":"break-words","href":"#3-sqlite-性能优化","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"3. SQLite 性能优化"]}] 62:["$","$L72",null,{"className":"language-sql","children":["$","code",null,{"className":"code-highlight language-sql","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token comment","children":"-- 开启 WAL 模式,提升读写并发"}],"\n"]}],["$","span",null,{"className":"code-line","children":["PRAGMA journal_mode",["$","span",null,{"className":"token operator","children":"="}],"WAL",["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":"\n"}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token comment","children":"-- 调整缓存大小"}],"\n"]}],["$","span",null,{"className":"code-line","children":["PRAGMA cache_size",["$","span",null,{"className":"token operator","children":"="}],["$","span",null,{"className":"token operator","children":"-"}],["$","span",null,{"className":"token number","children":"64000"}],["$","span",null,{"className":"token punctuation","children":";"}]," ",["$","span",null,{"className":"token comment","children":"-- 64MB"}],"\n"]}],["$","span",null,{"className":"code-line","children":"\n"}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token comment","children":"-- 启用内存映射"}],"\n"]}],["$","span",null,{"className":"code-line","children":["PRAGMA mmap_size",["$","span",null,{"className":"token operator","children":"="}],["$","span",null,{"className":"token number","children":"268435456"}],["$","span",null,{"className":"token punctuation","children":";"}]," ",["$","span",null,{"className":"token comment","children":"-- 256MB"}],"\n"]}]]}]}] 63:["$","h3",null,{"className":"content-header","id":"4-异步写入队列","children":[["$","a",null,{"className":"break-words","href":"#4-异步写入队列","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"4. 异步写入队列"]}] 64:["$","p",null,{"children":"对于\"全量留存\"这类非实时操作,可以引入消息队列异步处理:"}] 65:["$","$L72",null,{"className":"language-js","children":["$","code",null,{"className":"language-js code-highlight","children":["$","span",null,{"className":"code-line","children":"用户对话 → 主流程同步返回 → 写入队列 → 后台批量落库\n"}]}]}] 66:["$","p",null,{"children":"避免数据库写入阻塞主对话流程。"}] 67:["$","hr",null,{}] 68:["$","h2",null,{"className":"content-header","id":"结语","children":[["$","a",null,{"className":"break-words","href":"#结语","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"content-header-link","children":["$","svg",null,{"className":"h-5 linkicon w-5","fill":"currentColor","viewBox":"0 0 20 20","xmlns":"http://www.w3.org/2000/svg","children":[["$","path",null,{"d":"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z"}],["$","path",null,{"d":"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z"}]]}]}]}],"结语"]}] 69:["$","p",null,{"children":["本文分享的 RAG 架构从一个简单的\"文档入库 → 检索 → 生成\"链路出发,逐步演进为一个",["$","strong",null,{"children":"具备长期记忆和情绪感知能力的智能体系统"}],"。"]}] 6a:["$","p",null,{"children":"核心收获可以总结为三点:"}] 6b:["$","ol",null,{"children":[["$","li",null,{"children":["$","p",null,{"children":[["$","strong",null,{"children":"检索不能只靠向量"}],":FTS5 + 向量语义 + 实体聚合的三路召回,加上 RRF 融合排序,才能应对复杂的对话场景。"]}]}],["$","li",null,{"children":["$","p",null,{"children":[["$","strong",null,{"children":"记忆需要分层设计"}],":全量留存(底片)+ 滚动摘要(提纲)+ RAG 记忆(细节),三层各司其职。"]}]}],["$","li",null,{"children":["$","p",null,{"children":[["$","strong",null,{"children":"Prompt 需要动态合成"}],":固定人格保证角色一致性,动态情绪增加人情味,动态记忆提供上下文连贯性。"]}]}]]}] 6c:["$","p",null,{"children":["这套架构的所有组件都可以在 GitHub 上找到实现参考(如 ",["$","strong",null,{"children":"jiwen 项目"}],"的情绪状态引擎)。希望本文能为正在构建类似系统的开发者提供一些实战思路。"]}] 6d:["$","hr",null,{}] 6e:["$","blockquote",null,{"children":[["$","p",null,{"children":["$","strong",null,{"children":"附录:参考资源"}]}],["$","ul",null,{"children":[["$","li",null,{"children":"SQLite FTS5 官方文档"}],["$","li",null,{"children":"ChromaDB 向量数据库指南"}],["$","li",null,{"children":"RRF 混合检索算法原理"}],["$","li",null,{"children":"Jina Embeddings 模型介绍"}],["$","li",null,{"children":"Cloudflare Tunnel 配置教程"}]]}]]}] 6f:["$","div",null,{"className":"pt-6 pb-6 text-sm text-gray-700 dark:text-gray-300","children":[["$","a",null,{"className":"break-words","target":"_blank","rel":"nofollow","href":"https://mobile.twitter.com/search?q=https%3A%2F%2Ftechlog-18328.app.workbuddy.host%2Fblog%2Frag-pipeline-architecture","children":"Discuss on Twitter"}]," • ",["$","a",null,{"className":"break-words","target":"_blank","rel":"noopener noreferrer","href":"https://github.com/joker1point/techlog/blob/main/data/blog/rag-pipeline-architecture.mdx","children":"View on GitHub"}]]}] 70:["$","div",null,{"className":"pt-6 pb-6 text-center text-gray-700 dark:text-gray-300","id":"comment","children":["$","$L8b",null,{"slug":"rag-pipeline-architecture"}]}] 71:["$","footer",null,{"children":[["$","div",null,{"className":"divide-gray-200 text-sm leading-5 font-medium xl:col-start-1 xl:row-start-2 xl:divide-y dark:divide-gray-700","children":[["$","div",null,{"className":"py-4 xl:py-8","children":[["$","h2",null,{"className":"text-xs tracking-wide text-gray-500 uppercase dark:text-gray-400","children":"Tags"}],["$","div",null,{"className":"flex flex-wrap","children":[["$","$L5","rag",{"className":"text-primary-500 hover:text-primary-600 dark:hover:text-primary-400 mr-3 text-sm font-medium uppercase","href":"/tags/rag.html","children":"rag"}],["$","$L5","ai",{"className":"text-primary-500 hover:text-primary-600 dark:hover:text-primary-400 mr-3 text-sm font-medium uppercase","href":"/tags/ai.html","children":"ai"}],["$","$L5","llm",{"className":"text-primary-500 hover:text-primary-600 dark:hover:text-primary-400 mr-3 text-sm font-medium uppercase","href":"/tags/llm.html","children":"llm"}],["$","$L5","embedding",{"className":"text-primary-500 hover:text-primary-600 dark:hover:text-primary-400 mr-3 text-sm font-medium uppercase","href":"/tags/embedding.html","children":"embedding"}],["$","$L5","chromadb",{"className":"text-primary-500 hover:text-primary-600 dark:hover:text-primary-400 mr-3 text-sm font-medium uppercase","href":"/tags/chromadb.html","children":"chromadb"}],["$","$L5","nodejs",{"className":"text-primary-500 hover:text-primary-600 dark:hover:text-primary-400 mr-3 text-sm font-medium uppercase","href":"/tags/nodejs.html","children":"nodejs"}],["$","$L5","architecture",{"className":"text-primary-500 hover:text-primary-600 dark:hover:text-primary-400 mr-3 text-sm font-medium uppercase","href":"/tags/architecture.html","children":"architecture"}],["$","$L5","engineering",{"className":"text-primary-500 hover:text-primary-600 dark:hover:text-primary-400 mr-3 text-sm font-medium uppercase","href":"/tags/engineering.html","children":"engineering"}]]}]]}],["$","div",null,{"className":"flex justify-between py-4 xl:block xl:space-y-8 xl:py-8","children":[["$","div",null,{"children":[["$","h2",null,{"className":"text-xs tracking-wide text-gray-500 uppercase dark:text-gray-400","children":"Previous Article"}],["$","div",null,{"className":"text-primary-500 hover:text-primary-600 dark:hover:text-primary-400","children":["$","$L5",null,{"className":"break-words","href":"/blog/webpack-to-turbopack.html","children":"前端工程化:从 Webpack 到 Turbopack 的迁移指南"}]}]]}],["$","div",null,{"children":[["$","h2",null,{"className":"text-xs tracking-wide text-gray-500 uppercase dark:text-gray-400","children":"Next Article"}],["$","div",null,{"className":"text-primary-500 hover:text-primary-600 dark:hover:text-primary-400","children":["$","$L5",null,{"className":"break-words","href":"/blog/ide-agent-vs-ai-assistant.html","children":"IDE Agent 开发体验:为什么直接操作代码比通用 AI 助手更靠谱"}]}]]}]]}]]}],["$","div",null,{"className":"pt-4 xl:pt-8","children":["$","$L5",null,{"className":"text-primary-500 hover:text-primary-600 dark:hover:text-primary-400","href":"/blog.html","aria-label":"Back to the blog","children":"← Back to the blog"}]}]]}] 73:["$","span",null,{"className":"code-line","children":"│ │ │\n"}] 74:["$","span",null,{"className":"code-line","children":"│ ▼ │\n"}] 75:["$","span",null,{"className":"code-line","children":"│ ┌─────────────────────────────────────────────────────────────────────┐ │\n"}] 76:["$","span",null,{"className":"code-line","children":["│ │ 三路召回 ",["$","span",null,{"className":"token operator","children":"+"}]," ",["$","span",null,{"className":"token constant","children":"RRF"}]," 融合排序 │ │\n"]}] 77:["$","span",null,{"className":"code-line","children":"│ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │\n"}] 78:["$","span",null,{"className":"code-line","children":["│ │ │ ",["$","span",null,{"className":"token constant","children":"FTS5"}]," 关键词 │ │ 向量语义 │ │ 实体聚合 │ │ │\n"]}] 79:["$","span",null,{"className":"code-line","children":"│ │ └──────────────┘ └──────────────┘ └──────────────┘ │ │\n"}] 7a:["$","span",null,{"className":"code-line","children":"│ └─────────────────────────────────────────────────────────────────────┘ │\n"}] 7b:["$","span",null,{"className":"code-line","children":"│ │ │\n"}] 7c:["$","span",null,{"className":"code-line","children":"│ ▼ │\n"}] 7d:["$","span",null,{"className":"code-line","children":"│ ┌─────────────────────────────────────────────────────────────────────┐ │\n"}] 7e:["$","span",null,{"className":"code-line","children":["│ │ 三层 ",["$","span",null,{"className":"token maybe-class-name","children":"Prompt"}]," 动态叠加 │ │\n"]}] 7f:["$","span",null,{"className":"code-line","children":"│ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │\n"}] 80:["$","span",null,{"className":"code-line","children":"│ │ │ 固定人格 │ │ 动态情绪 │ │ 动态记忆 │ │ │\n"}] 81:["$","span",null,{"className":"code-line","children":["│ │ ",["$","span",null,{"className":"token function","children":"│"}]," ",["$","span",null,{"className":"token punctuation","children":"("}],"角色原型",["$","span",null,{"className":"token punctuation","children":")"}]," │ ",["$","span",null,{"className":"token function","children":"│"}]," ",["$","span",null,{"className":"token punctuation","children":"("}],"状态引擎",["$","span",null,{"className":"token punctuation","children":")"}]," │ ",["$","span",null,{"className":"token function","children":"│"}]," ",["$","span",null,{"className":"token punctuation","children":"("}],"检索碎片",["$","span",null,{"className":"token punctuation","children":")"}]," │ │ │\n"]}] 82:["$","span",null,{"className":"code-line","children":"│ │ └──────────────┘ └──────────────┘ └──────────────┘ │ │\n"}] 83:["$","span",null,{"className":"code-line","children":"│ └─────────────────────────────────────────────────────────────────────┘ │\n"}] 84:["$","span",null,{"className":"code-line","children":"│ │ │\n"}] 85:["$","span",null,{"className":"code-line","children":"│ ▼ │\n"}] 86:["$","span",null,{"className":"code-line","children":"│ ┌─────────────────┐ │\n"}] 87:["$","span",null,{"className":"code-line","children":["│ │ ",["$","span",null,{"className":"token constant","children":"LLM"}]," 生成回答 │ │\n"]}] 88:["$","span",null,{"className":"code-line","children":"│ └─────────────────┘ │\n"}] 89:["$","span",null,{"className":"code-line","children":"│ │\n"}] 8a:["$","span",null,{"className":"code-line","children":"└─────────────────────────────────────────────────────────────────────────────┘\n"}] 1b:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]] 17:null 19:{"metadata":[["$","title","0",{"children":"RAG 链路全解析:从文档入库到混合记忆的实战架构 | TechLog"}],["$","meta","1",{"name":"description","content":"详述 RAG(检索增强生成)的完整技术链路,包括文档入库、向量化、召回重排、Prompt 拼接,以及基于 Node.js + ChromaDB + SQLite 的三层混合记忆进阶方案。"}],["$","meta","2",{"name":"robots","content":"index, follow"}],["$","meta","3",{"name":"googlebot","content":"index, follow, max-video-preview:-1, max-image-preview:large, max-snippet:-1"}],["$","link","4",{"rel":"canonical","href":"https://techlog-18328.app.workbuddy.host/blog/rag-pipeline-architecture"}],["$","link","5",{"rel":"alternate","type":"application/rss+xml","href":"https://techlog-18328.app.workbuddy.host/feed.xml"}],["$","meta","6",{"property":"og:title","content":"RAG 链路全解析:从文档入库到混合记忆的实战架构"}],["$","meta","7",{"property":"og:description","content":"详述 RAG(检索增强生成)的完整技术链路,包括文档入库、向量化、召回重排、Prompt 拼接,以及基于 Node.js + ChromaDB + SQLite 的三层混合记忆进阶方案。"}],["$","meta","8",{"property":"og:url","content":"https://techlog-18328.app.workbuddy.host/blog/rag-pipeline-architecture"}],["$","meta","9",{"property":"og:site_name","content":"TechLog"}],["$","meta","10",{"property":"og:locale","content":"en_US"}],["$","meta","11",{"property":"og:image","content":"https://techlog-18328.app.workbuddy.host/static/images/twitter-card.png"}],["$","meta","12",{"property":"og:type","content":"article"}],["$","meta","13",{"property":"article:published_time","content":"2026-06-04T00:00:00.000Z"}],["$","meta","14",{"property":"article:modified_time","content":"2026-06-04T00:00:00.000Z"}],["$","meta","15",{"property":"article:author","content":"眠月"}],["$","meta","16",{"name":"twitter:card","content":"summary_large_image"}],["$","meta","17",{"name":"twitter:title","content":"RAG 链路全解析:从文档入库到混合记忆的实战架构"}],["$","meta","18",{"name":"twitter:description","content":"详述 RAG(检索增强生成)的完整技术链路,包括文档入库、向量化、召回重排、Prompt 拼接,以及基于 Node.js + ChromaDB + SQLite 的三层混合记忆进阶方案。"}],["$","meta","19",{"name":"twitter:image","content":"https://techlog-18328.app.workbuddy.host/static/images/twitter-card.png"}]],"error":null,"digest":"$undefined"} 1e:"$19:metadata"