[{"data":1,"prerenderedAt":74},["ShallowReactive",2],{"article-other\u002Frag-datasbase":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"tags":11,"body":13,"_type":68,"_id":69,"_source":70,"_file":71,"_stem":72,"_extension":73},"\u002Farticles\u002Fother\u002Frag-datasbase","other",false,"","RAG 与向量数据库：从键值存储到语义检索的直观理解","用传统数据库的视角理解 RAG 向量数据库：一条数据如何同时保存原文、元数据与 embedding，并参与语义检索。","2026-08-08",[12],"随笔",{"type":14,"children":15,"toc":63},"root",[16,24,30,35,40,50,55],{"type":17,"tag":18,"props":19,"children":21},"element","h2",{"id":20},"起因",[22],{"type":23,"value":20},"text",{"type":17,"tag":25,"props":26,"children":27},"p",{},[28],{"type":23,"value":29},"没有理解透RAG中用向量数据库存数据这个直观的。传统后端用数据库存数据的时候能用DataGrip这些工具可视化数据，非常清晰明确，用向量数据库没有这么直观的感受。比如说key-value这种结构存之后是什么样的。",{"type":17,"tag":18,"props":31,"children":33},{"id":32},"现在的理解",[34],{"type":23,"value":32},{"type":17,"tag":25,"props":36,"children":37},{},[38],{"type":23,"value":39},"向量数据库最大的特点就是比普通表多一列超长数字数组(向量)。",{"type":17,"tag":41,"props":42,"children":44},"pre",{"code":43},"普通业务表：\nuser_id  ->  { name, age, city }\n\nRAG 向量表：\nchunk_id ->  { text, metadata, embedding }\n",[45],{"type":17,"tag":46,"props":47,"children":48},"code",{"__ignoreMap":7},[49],{"type":23,"value":43},{"type":17,"tag":25,"props":51,"children":52},{},[53],{"type":23,"value":54},"举例",{"type":17,"tag":41,"props":56,"children":58},{"code":57},"key = chunk_001\nvalue = {\n  text: \"RAG 会先检索相关知识，再生成回答。\",\n  metadata: {\"doc\": \"rag.md\", \"page\": 1},\n  embedding: [0.12, -0.48, 0.77, ...]\n}\n\nchunk_001\n   │\n   ├─ 原文：给 LLM 阅读、最终引用\n   ├─ 元数据：过滤用，例如来源、页码、用户权限\n   └─ 向量：只负责“找得像不像”\n",[59],{"type":17,"tag":46,"props":60,"children":61},{"__ignoreMap":7},[62],{"type":23,"value":57},{"title":7,"searchDepth":64,"depth":64,"links":65},2,[66,67],{"id":20,"depth":64,"text":20},{"id":32,"depth":64,"text":32},"markdown","content:articles:other:RAG-datasbase.md","content","articles\u002Fother\u002FRAG-datasbase.md","articles\u002Fother\u002FRAG-datasbase","md",1789465115005]