agentleFS
belos-streetbelos-street/grimoire/skills/rag/skill.md

rag

Skill8 starsChanged 3 months agoMITView on GitHub

通用 RAG 方法论 Skill 集合(11 模块,跨项目可迁移):技术选型 / 加载 / 摄取 / 查询理解 / 检索 / 重排 / 生成防幻觉 / 多轮对话 / GraphRAG / 轻量词法多跳 / 评估。每篇「通用原则 + 落地建议」。

8 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Files
skill.md

RAG(检索增强生成)

通用 RAG 方法论 Skill 集合(跨项目可迁移,与具体项目解耦)。每篇为「通用原则(适用于任何 RAG 项目)+ 落地建议(项目无关的参考命名 / 结构 / 参数)」。项目专属绑定由所在项目侧 .agents/rules/rag-*.md 提供(不在本 skill 内),本 skill 保持项目无关。论文依据:华为云 + 港中文的 iKnow 经验论文(ASE 2025,PDF 见 references)——对 2000 条真实云运维查询的实证发现 过半 RAG 失败源于查询侧(不完整 32% / 超范围 10% / 无效 9%),知识缺失 27% 是第二大根因并直接诱发幻觉。故标准 RAG 上应增加「查询理解与改写」「缺失知识检测」两层。

新项目先读 rag-selection:按文档规模、硬件、部署合规与查询类型确定架构与阶段路线,再进入下面的生命周期。

通用 RAG 生命周期(不依赖任何项目)

加载 loader → 摄取/分块 ingestion → 查询理解 query → 检索 retrieval → 重排 rerank → 生成 generation → 评估 evaluation
 (rag-loader)   (rag-ingestion)   (rag-query)   (rag-retrieval)  (rag-rerank)   (rag-generation)  (rag-evaluation)
        ↑ 多轮对话 rag-multi-turn(横切:每轮先做历史改写再进查询理解)
        ↑ GraphRAG rag-graphrag(进阶:跨文档/全局性问题时替代 chunk 级检索)
        ↑ 轻量词法多跳 rag-lexical-multihop(进阶:编号密集/低算力场景替代或补充检索)

各环节投入优先级不同(论文实测):查询理解与评估是性价比最高、最易被忽略的两环——前者修复 32% 的查询侧失败,后者让所有改进可验证;重排/GraphRAG/轻量词法多跳/多轮属按需启用的进阶能力。

模块导航(遇到什么问题 → 读哪篇)

遇到的问题模块篇目
新项目不知从哪套架构起步(规模/硬件/查询类型)rag-selectionreferences/rag-selection.md
加载多格式文档(PDF/HTML/Office/图片)rag-loaderreferences/rag-loader.md
分块 / 去重 / 批量嵌入 / 入库rag-ingestionreferences/rag-ingestion.md
检索前把模糊问题改写为语义完整问题rag-queryreferences/rag-query.md
混合检索(dense + keyword + RRF 融合)rag-retrievalreferences/rag-retrieval.md
检索后精排(候选集大 / 专有名词多时)rag-rerankreferences/rag-rerank.md
防幻觉生成 + 溯源(prompt / 生成链路)rag-generationreferences/rag-generation.md
多轮对话(追问改写 / 历史压缩)rag-multi-turnreferences/rag-multi-turn.md
跨文档 / 全局性问题(图谱聚合)rag-graphragreferences/rag-graphrag.md
编号/型号密集、无 GPU、需要可解释证据链rag-lexical-multihopreferences/rag-lexical-multihop.md
验收 / 回归 / 评估指标rag-evaluationreferences/rag-evaluation.md
想了解论文原始数据 / 结论细节论文笔记references/iknow-paper-notes.md

论文经验 → 通用对策(为什么这么设计)

论文发现(iKnow,2000 条真实查询)占比通用对策
查询不完整(如只输入一个名词)32%检索前查询改写:LLM 按意图把模糊问题改写为语义完整的问题(rag-query)
知识缺失(知识库无对应内容 → 幻觉)27%缺失知识检测 + 降级回答:判断上下文是否足够,不足则明示"暂无相关信息"(rag-generation)
查询意图与失败强相关(术语解释类 58.8% 败于不完整)—意图分类:5 类意图,改写 prompt 按意图定制(rag-query)
检索不准确(相关文档不在 top-k)11%双通道混合检索 + RRF 融合:dense + keyword 互补(rag-retrieval)
生成不准确11%注入"原始问题 + 改写问题 + 上下文"三段 prompt,约束仅依据给定上下文回答(rag-generation)
超范围 / 无效查询19%意图分类识别无效 / 越界问题,路由到降级回答(rag-query)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.