RAG 与知识库RAG & knowledge · 单元Unit 07
RAG 知识库:从文档到可信回答RAG knowledge bases: from documents to trustworthy answers
把文档切分、向量化、存储、召回与重排串成一条链路。学完本单元,你能定位召回为空、答案过期和引用缺失三类高频问题。Chain parsing, chunking, embedding, storage, retrieval and reranking. After this unit you can diagnose empty recall, stale answers and missing citations.
学习目标Learning goals
- 说出 RAG 链路的五个阶段与对应 APIName the five RAG stages and their APIs
- 理解切分策略、embedding 模型与索引的一致性Understand consistency between chunking, embedding models and indexes
- 为回答加上来源引用和更新删除策略Add source citations and update/delete policies
概念闪卡Concept cards
点击卡片翻面查看解释。Click a card to flip it and reveal the explanation.
关键 APIKey APIs
点击进入对应的 Python 或 Java 参考页。Open the exact Python or Java reference for each type.
问题巩固Check yourself
完成 10 道题;答错会自动进入错题本。Answer all ten questions. Wrong answers are added to your wrong-answer book automatically.
01Python 中组合解析、切分、向量化与检索的高层入口是?Which Python class combines parsing, chunking, embedding and retrieval?
解析Why KnowledgeBase 提供 ensure_collection、insert_document、search、delete_document 等操作。KnowledgeBase provides ensure_collection, insert_document, search and delete_document.
02按 token 近似切分文本的组件是?Which component splits text by approximate token count?
解析Why ApproxTokenChunker 控制块大小与重叠,块过大或过小都会损害召回质量。ApproxTokenChunker controls chunk size and overlap; chunks that are too large or small hurt recall quality.
03向量存储的抽象基类是?What is the vector store abstraction?
解析Why 实现类包括 MilvusLiteStore、QdrantStore、ElasticsearchStore 和 MongoDBStore。Implementations include MilvusLiteStore, QdrantStore, ElasticsearchStore and MongoDBStore.
04检索返回的结果类型是?What type represents a retrieval result?
解析Why VectorSearchResult 携带匹配块、相似度分数和元数据,用于重排与引用。VectorSearchResult carries the matched chunk, similarity score and metadata for reranking and citations.
05解析 PDF 文档使用哪个解析器?Which parser handles PDF documents?
解析Why 各解析器都实现 ParserBase,并通过 supported_extensions 声明支持的后缀。Each parser implements ParserBase and declares supported extensions via supported_extensions.
06更换 embedding 模型后必须做什么?What must you do after changing the embedding model?
解析Why 不同模型向量空间不可比,旧向量继续使用会导致召回完全失真。Vectors from different models are not comparable; keeping old vectors makes recall meaningless.
07召回质量差时,第一步应该检查什么?What should you check first when recall quality is poor?
解析Why 先确认检索的是正确的块和范围,再考虑重排模型或查询改写。First verify the right chunks and scope are searched, then consider rerankers or query rewriting.
08Java 官方扩展中提供简易 RAG 能力的是?Which official Java extension provides simple RAG?
解析Why 此外还有 rag-bailian、rag-dify、rag-haystack 和 rag-ragflow 等集成扩展。Other integrations include rag-bailian, rag-dify, rag-haystack and rag-ragflow.
09面向用户的知识库回答应该附带什么?What should user-facing knowledge-base answers include?
解析Why 引用让回答可审计、可纠错,也是排查过期知识的入口。Citations make answers auditable and correctable and expose stale knowledge.
10文档更新后没有删除旧向量会导致?What happens if old vectors are not deleted after a document update?
解析Why 更新必须包含删除或版本替换,否则新旧内容会同时被召回。Updates must delete or version-replace old vectors, or old and new content are recalled together.