本项目实现了论文中的 Corrective RAG(CRAG)流程:
- 先检索;2) 用交叉编码器评估检索质量;3) 根据阈值选择
correct / ambiguous / incorrect; - 对不确定或错误情况进行知识精炼(sentence-level filtering),必要时走 Web 搜索。
后端使用 FastAPI + LangChain,支持 MinerU 解析 PDF 并按标题层级切分。
app/API 服务与 CRAG 流程app/ingest/MinerU 调用与解析app/rag/检索、评估、修正、提示词data/raw/放置原始 PDFdata/parsed/MinerU 输出data/index/Chroma 向量索引data/samples/示例标准元数据与问题scripts/小工具脚本
uv python install 3.13
uv venv -p 3.13
uv sync复制 .env.example 为 .env,并填写:
QWEN_API_KEY、QWEN_MODEL(例如qwen-turbo)GOOGLE_API_KEY、GOOGLE_CSE_ID(Google Custom Search)USE_WEB_SEARCH=true(需要时开启)
先安装 MinerU:
uv pip install mineru解析示例:
set MINERU_MODEL_SOURCE=modelscope
uv run mineru -p data\raw\your.pdf -o data\parsed系统读取 content_list.json,使用 text_level + 编号标题(1/1.1/1.1.1)进行分层切分。
uv run python scripts\ingest_docs.py --run-mineru-first true只使用示例元数据:
uv run python scripts\ingest_docs.py --run-mineru-first false --include-samples trueuv run uvicorn app.main:app --reloadPOST /ingest触发入库POST /chat进行问答GET /health健康检查
见 data/samples/questions.json。
uv run python scripts\download_hbba_metadata.py --keyword TB --max-pages 2