重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
npx skills add https://github.com/vasilyu1983/ai-agents-public --skill ai-rag使用混合搜索、基于事实的生成和可衡量的质量构建生产级检索系统。
本技能涵盖:
现代最佳实践(2026年1月):
默认姿态:确定性流水线、有界上下文、显式故障处理以及每个阶段的遥测。
范围说明:关于生成阶段使用的提示结构和输出契约,请参阅 。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 任务 | 工具/框架 | 命令/模式 | 使用时机 |
|---|---|---|---|
| 决定使用RAG还是替代方案 | 决策框架 | 如果满足以下条件则使用RAG:需要新鲜度 + 引用 + 语料库规模大;否则:微调/缓存 | 避免不必要的检索延迟/复杂性 |
| 分块与解析 | 分块器 + 解析器 | 从简单开始;根据文档类型添加结构感知分块 | 用于文档、代码、表格、PDF的摄取 |
| 检索 | 稀疏 + 稠密(混合) | 融合(例如,RRF)+ 元数据过滤器 + top-k 调优 | 混合查询风格;高召回率要求 |
| 精度提升 | 重排序器 | 对 top-k 候选结果进行交叉编码器/LLM重排序 | 当 top-k 包含近似匹配/噪声时 |
| 事实基础 | 输出契约 + 引用 | 引用/ID引用;可回答性门控;证据缺失时拒绝 | 合规性、可信度和可审计性 |
| 评估 | 离线 + 在线评估 | 检索指标 + 答案指标 + 回归测试 | 防止静默回归和因陈旧数据导致的故障 |
构建RAG系统:[架构路径]
├─ 文档类型?
│ ├─ 页面/章节结构化的? → 结构感知分块(页面/章节 + 元数据)
│ ├─ 技术文档/代码? → 结构感知 + 代码感知分块(符号、标题)
│ └─ 简单内容? → 带重叠的固定大小令牌分块(基线)
│
├─ 检索准确率低?
│ ├─ 查询歧义? → 查询重写 + 多查询扩展 + 过滤器
│ ├─ 结果噪声大? → 添加重排序器 + 更好的元数据过滤器
│ └─ 混合查询? → 混合检索(稀疏 + 稠密)+ 重排序
│
├─ 数据集大小?
│ ├─ <100k 分块? → 平面索引(精确搜索)
│ ├─ 100k-10M? → HNSW(低延迟)
│ └─ >10M? → IVF/ScaNN/DiskANN(可扩展)
│
└─ 生产质量要求?
└─ 添加:ACL、新鲜度/失效处理、评估门控和端到端遥测
应做
应避免
当用户询问以下问题时使用此技能:
当用户询问供应商/模型/框架推荐时,请根据当前主要来源验证其说法。
data/sources.json 并从标记为 "add_as_web_search": true 的来源开始。检查后,提供:
对于相邻主题,请参考以下技能:
资源
模板
数据
每当用户需要检索增强系统设计或调试时使用此技能,而非提示工程或部署工作。
每周安装次数
72
仓库
GitHub星标数
48
首次出现
Jan 23, 2026
安全审计
安装于
gemini-cli57
cursor57
opencode56
codex56
github-copilot53
cline47
Build production-grade retrieval systems with hybrid search , grounded generation , and measurable quality.
This skill covers:
Modern Best Practices (Jan 2026) :
Default posture : deterministic pipeline, bounded context, explicit failure handling, and telemetry for every stage.
Scope note : For prompt structure and output contracts used in the generation phase, see ai-prompt-engineering.
| Task | Tool/Framework | Command/Pattern | When to Use |
|---|---|---|---|
| Decide RAG vs alternatives | Decision framework | RAG if: freshness + citations + corpus size; else: fine-tune/caching | Avoid unnecessary retrieval latency/complexity |
| Chunking & parsing | Chunker + parser | Start simple; add structure-aware chunking per doc type | Ingestion for docs, code, tables, PDFs |
| Retrieval | Sparse + dense (hybrid) | Fusion (e.g., RRF) + metadata filters + top-k tuning | Mixed query styles; high recall requirements |
| Precision boost | Reranker | Cross-encoder/LLM rerank of top-k candidates | When top-k contains near-misses/noise |
| Grounding | Output contract + citations | Quote/ID citations; answerability gate; refuse on missing evidence | Compliance, trust, and auditability |
| Evaluation | Offline + online eval | Retrieval metrics + answer metrics + regression tests |
Building RAG system: [Architecture Path]
├─ Document type?
│ ├─ Page/section-structured? → Structure-aware chunking (pages/sections + metadata)
│ ├─ Technical docs/code? → Structure-aware + code-aware chunking (symbols, headers)
│ └─ Simple content? → Fixed-size token chunking with overlap (baseline)
│
├─ Retrieval accuracy low?
│ ├─ Query ambiguity? → Query rewriting + multi-query expansion + filters
│ ├─ Noisy results? → Add reranker + better metadata filters
│ └─ Mixed queries? → Hybrid retrieval (sparse + dense) + reranking
│
├─ Dataset size?
│ ├─ <100k chunks? → Flat index (exact search)
│ ├─ 100k-10M? → HNSW (low latency)
│ └─ >10M? → IVF/ScaNN/DiskANN (scalable)
│
└─ Production quality?
└─ Add: ACLs, freshness/invalidation, eval gates, and telemetry (end-to-end)
Do
Avoid
Use this skill when the user asks:
When users ask for vendor/model/framework recommendations, validate claims against current primary sources.
data/sources.json and start from sources with "add_as_web_search": true.After checking, provide:
For adjacent topics, reference these skills:
Resources
Templates
Data
Use this skill whenever the user needs retrieval-augmented system design or debugging , not prompt work or deployment.
Weekly Installs
72
Repository
GitHub Stars
48
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
gemini-cli57
cursor57
opencode56
codex56
github-copilot53
cline47
超能力技能使用指南:AI助手技能调用优先级与工作流程详解
53,700 周安装
| Prevent silent regressions and staleness failures |