---
title: "本地 RAG 切块起点：慢一点但更稳"
url: https://memory.wiki/9nNGrUKS
updated: 2026-11-30T22:09:09.416Z
source: "memory.wiki"
---
# 本地 RAG 切块起点：慢一点但更稳

## 为什么「本地 RAG 切块起点」对本地 RAG 很重要

先 400–800 token、10–20% 重叠，用自己的 PDF 评估。检索增强生成通常是团队基于本地模型做的第一个正经项目，因为文档留在内网，也不用微调。它同样是小设计决定大信任的地方。

## 先做好入库

垃圾输入会产出自信的错误答案。在考虑嵌入模型之前：

- 保留结构：PDF 或 Office 文件转换后，标题、表格和列表要还在。
- 每个分块都带元数据：来源文件、章节、版本和文档日期。
- 没有负责人或没有日期的文档拒收，过期政策是负债。
- 保留原始文件，分块器改进后可以重新入库。

## 分块与检索

先用中等分块大小加一定重叠，再用你自己的问题评测，而不是照搬博客参数。中文需要按句子切分的分块器，不能套用英文的空格规则。纯向量检索会漏掉零件号、合同编号、SKU 这类精确标识，所以要在向量库旁边保留关键词索引并合并结果。政策随时间变化时，检索要偏向最新的有效版本。

## 可重复的评测

整理一组真实问题，附上标准答案和应当支撑答案的文档。每次修改分块、嵌入模型或提示词后都跑一遍，同时看答案和检索到的段落。如果正确段落没有被检索出来，提示词再怎么改也没用。

## 运维

- 备份向量库，并实际演练一次恢复。
- 按部门或客户拆分集合，方便执行权限规则。
- 记录每个回答引用了哪些来源。
- 明确助手必须拒答的内容，并公布出来。

## 一个实际例子

一家小型制造企业希望工程师能查询内部技术规范。第一版只用向量检索，经常返回错误版本的文档。团队把文档日期和版本号加进元数据，排序前过滤掉已被替代的版本，并为零件号保留关键词索引。他们还改写了分块方式，把表格单独存成记录。改完后用同一批评测问题重跑，检查正确来源是否出现在检索结果中。直到检索稳定，他们才开始花时间调整回答提示词。

想了解更多，可以看看[MicroAI One 软件](https://microaione.com/microai-one/)和[本地 RAG 知识库教程](https://microaione.com/tutorials/local-rag-knowledge-base/)。


## 速记要点

- 商用前先读模型许可证。
- 给系统和嵌入模型留出内存余量。
- 公布助手会拒绝做的事。
- 离线演示准备纸质备用方案。

*作者：[本地AI 1号网](https://microaione.com/)，深圳团队，专注本地大模型软硬件、装机与私有化部署。*

---

## Summary
本地RAG系统的核心在于高质量的入库处理与检索策略，包括保留文档结构、结合关键词索引以及通过真实问题集进行持续评测。只有确保检索到正确且最新的文档片段，后续的提示词优化才能有效提升回答的准确性。

## Themes
- Local RAG optimization
- Data ingestion strategies
- Retrieval evaluation methods
- System maintenance

## Key takeaways
- Initial chunking should start with 400 to 800 tokens and 10 to 20 percent overlap for testing purposes.
- Documents lacking clear ownership or dates should be rejected to prevent the use of obsolete information.
- Retrieval systems should prioritize the most recent versions of documents when policies change over time.
- Evaluation must be based on a fixed set of real questions and standard answers to ensure changes to the pipeline are measurable.
- Vector databases must be backed up and tested with recovery drills to ensure operational reliability.

## Insights
- Vector search is insufficient for technical identifiers like SKU or part numbers and requires a hybrid approach with keyword indexing.
- The quality of retrieval is the primary bottleneck for RAG performance, rendering prompt engineering ineffective if the correct source documents are not retrieved first.
- Metadata management is a critical operational task, as outdated documents act as technical debt that can lead to incorrect AI responses.

## Open questions / gaps
- What specific metrics should be used to quantify the success of the retrieval phase during the evaluation process?

