Skip to content

About

No description, website, or topics provided.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

CUMCM Agentic RAG 项目说明 / Project Overview

本项目构建一个面向数学建模研究与决策支持的、可审计的 Agentic RAG 系统。它强调证据来源、历史可用性、人工复核、引用忠实度和失败时的明确拒绝,不是自动生成竞赛答案的工具。

当前能力

流水线已经覆盖:私有 PDF 注册与清单、逐页提取和语料审计、确定性结构分段、可疑页面视觉复核、OpenAI/Qwen/第三方 Codex 视觉增强、指纹绑定的人工裁决、已批准页面晋升、感知晋升结果的重新分段、私有 PaperCard 草稿、PaperCard 人工复核与正式发布、以及只面向 published/trusted 卡片的确定性词法检索。PR24 在此基础上增加证据约束的 Agentic RAG 查询流程;PR25 增加固定、离线、版本化的检索与 Agent 回归评估。

开发环境与质量门

使用 Python 3.11+,PowerShell 脚本位于 scripts/。安装开发依赖后,依次运行格式化、静态检查、测试和 git diff --check。CI 不发送真实模型请求,自动测试只使用合成数据。

LLM 路由

openai、deepseek_qwen、qwen 和 third_party_codex 配置分别选择文本与视觉提供商。不存在静默提供商回退;第三方 Codex 的来源必须与官方 OpenAI 明确区分。

主要工作流

视觉复核和晋升、感知晋升结果的分段、私有 PaperCard 草稿生成、PaperCard 人工复核与发布、词法索引构建与检索,都有对应 PowerShell 命令。Agentic RAG 查询默认只做 dry run,只有显式 -Execute 才会调用文本模型;最终回答必须通过本地引用校验,否则返回 insufficient_evidence。

检索与 Agent 回归评估

默认合成基准不读取私有语料、不调用真实提供商,并在任一版本化阈值失败时返回非零退出码:

.\scripts\evaluate_retrieval_agent.ps1
.\scripts\evaluate_retrieval_agent.ps1 -Json

保存机器可读报告:

.\scripts\evaluate_retrieval_agent.ps1 `
    -OutputPath ".\data\private\evaluation\reports\synthetic-v1.json" `
    -Json

详见 docs/evaluation.md 和 docs/retrieval-agent-evaluation.md。

私有数据边界

data/private/ 与 data/cards/ 都是本地运行时数据并被 Git 忽略。不要提交 PDF、图片、提取文本、分段、复核账本、草稿、本地发布卡片、索引、精确私人标识或密钥。

文档入口

先阅读 AGENTS.md、docs/index.md、docs/PROJECT_HANDOFF.md、docs/project-history.md、docs/roadmap.md 和 CHANGELOG.md。所有面向人的 Markdown 文档采用中文优先、英文完整对应的双语格式。

命令与配置示例

以下代码块保持机器可执行形式,不翻译标识符:

private PDF registration and manifest
→ page-aware extraction and corpus audit
→ deterministic structural segmentation
→ suspicious-page visual queue
→ OpenAI, Qwen, or third-party Codex visual enhancement
→ fingerprint-bound human visual review
→ approved visual-page promotion
→ promotion-aware re-segmentation
→ private PaperCard draft generation
→ fingerprint-bound PaperCard review and formal publication
→ deterministic PaperCard lexical retrieval and metadata filtering
→ evidence-grounded Agentic RAG query flow with local citation verification
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -e ".[dev]"
.\scripts\format.ps1
.\scripts\lint.ps1
.\scripts\test.ps1
git diff --check
openai            text OpenAI       vision OpenAI
deepseek_qwen     text DeepSeek     vision Qwen
qwen              text Qwen         vision Qwen
third_party_codex text Codex CLI    vision Codex CLI
.\scripts\review_visual_enhancements.ps1 list
.\scripts\review_visual_enhancements.ps1 show <queue_item_id>
.\scripts\review_visual_enhancements.ps1 approve <queue_item_id> `
    --reviewer "local-reviewer"

.\scripts\promote_approved_visual_pages.ps1
.\scripts\promote_approved_visual_pages.ps1 -Execute
.\scripts\segment_pdf_corpus.ps1 `
    -DocumentId "document_demo" `
    -UseApprovedVisualPromotions `
    -DryRun
.\scripts\segment_pdf_corpus.ps1 `
    -DocumentId "document_demo" `
    -UseApprovedVisualPromotions `
    -Overwrite
.\scripts\generate_paper_card_drafts.ps1 `
    -DocumentId @("document_demo") `
    -Profile deepseek_qwen
.\scripts\review_paper_cards.ps1 list
.\scripts\review_paper_cards.ps1 show document_demo

.\scripts\review_paper_cards.ps1 approve document_demo `
    --reviewer "local-reviewer" `
    --note "Compared the methods and cited chunks with the source." `
    --acknowledge-all-warnings

.\scripts\review_paper_cards.ps1 publish document_demo
.\scripts\search_paper_cards.ps1 build
.\scripts\search_paper_cards.ps1 status
.\scripts\search_paper_cards.ps1 search `
    --query "动态规划 生产检测"

.\scripts\search_paper_cards.ps1 search `
    --query "贝叶斯 次品率" `
    --year-from 2020 `
    --contest CUMCM `
    --problem-code B `
    --method "贝叶斯估计"
.\scripts\query_agentic_rag.ps1 `
    -Question "如何为多阶段生产检测设计决策模型?" `
    -Profile deepseek_qwen

.\scripts\query_agentic_rag.ps1 `
    -Question "如何为多阶段生产检测设计决策模型?" `
    -Profile deepseek_qwen `
    -Execute
.\scripts\export-agent-context.ps1 `
    -Files @(
        "src\cumcm_agent\cards\review_publication_service.py",
        "tests\unit\test_paper_card_review_publication.py"
    ) `
    -OutputPath ".agent-context.txt"

Auditable Agentic RAG infrastructure for mathematical-modeling research and decision support.

The project emphasizes provenance, historical availability, review, and citation fidelity. It is not an automatic competition-answer generator.

Current capabilities

private PDF registration and manifest
→ page-aware extraction and corpus audit
→ deterministic structural segmentation
→ suspicious-page visual queue
→ OpenAI, Qwen, or third-party Codex visual enhancement
→ fingerprint-bound human visual review
→ approved visual-page promotion
→ promotion-aware re-segmentation
→ private PaperCard draft generation
→ fingerprint-bound PaperCard review and formal publication
→ deterministic PaperCard lexical retrieval and metadata filtering
→ evidence-grounded Agentic RAG query flow with local citation verification

The query flow plans bounded lexical searches, synthesizes only from retrieved method evidence, and returns insufficient_evidence when local citation verification cannot support an answer. PR25 adds a fixed, versioned, fully offline retrieval and Agent regression benchmark.

Development environment

  • Python 3.11+
  • Windows PowerShell scripts under scripts/
  • project dependencies and quality tools from pyproject.toml

Typical setup:

python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -e ".[dev]"

Quality checks:

.\scripts\format.ps1
.\scripts\lint.ps1
.\scripts\test.ps1
git diff --check

LLM routing profiles

openai            text OpenAI       vision OpenAI
deepseek_qwen     text DeepSeek     vision Qwen
qwen              text Qwen         vision Qwen
third_party_codex text Codex CLI    vision Codex CLI

There is no silent provider fallback. Third-party Codex uses the user's local Codex CLI provider configuration and is not represented as an official OpenAI request.

Visual review and promotion

.\scripts\review_visual_enhancements.ps1 list
.\scripts\review_visual_enhancements.ps1 show <queue_item_id>
.\scripts\review_visual_enhancements.ps1 approve <queue_item_id> `
    --reviewer "local-reviewer"

.\scripts\promote_approved_visual_pages.ps1
.\scripts\promote_approved_visual_pages.ps1 -Execute

Promotion never overwrites extraction or visual artifacts. See docs/visual-review-adjudication.md and docs/approved-visual-promotion.md.

Promotion-aware segmentation

Preview:

.\scripts\segment_pdf_corpus.ps1 `
    -DocumentId "document_demo" `
    -UseApprovedVisualPromotions `
    -DryRun

Explicitly replace an old segmentation artifact:

.\scripts\segment_pdf_corpus.ps1 `
    -DocumentId "document_demo" `
    -UseApprovedVisualPromotions `
    -Overwrite

See docs/promotion-aware-segmentation.md.

Private PaperCard drafts

Preview without a model call:

.\scripts\generate_paper_card_drafts.ps1 `
    -DocumentId @("document_demo") `
    -Profile deepseek_qwen

Only -Execute calls the selected text model. Drafts remain under data/private/card_drafts/papers with review_status=draft and do not enter retrieval. See docs/segmentation-aware-card-drafts.md.

PaperCard review and publication

.\scripts\review_paper_cards.ps1 list
.\scripts\review_paper_cards.ps1 show document_demo

.\scripts\review_paper_cards.ps1 approve document_demo `
    --reviewer "local-reviewer" `
    --note "Compared the methods and cited chunks with the source." `
    --acknowledge-all-warnings

.\scripts\review_paper_cards.ps1 publish document_demo

list reports review state and an independent published=yes|no flag for the exact current draft. Review events are append-only and bound to the exact current draft SHA-256. Publication repeats source/evidence checks and accepts only an effective human approval. Automated-verifier events cannot publish. See docs/paper-card-review-publication.md.

PaperCard lexical retrieval

Build or reuse the private lexical index:

.\scripts\search_paper_cards.ps1 build
.\scripts\search_paper_cards.ps1 status

Search published or trusted PaperCards:

.\scripts\search_paper_cards.ps1 search `
    --query "动态规划 生产检测"

.\scripts\search_paper_cards.ps1 search `
    --query "贝叶斯 次品率" `
    --year-from 2020 `
    --contest CUMCM `
    --problem-code B `
    --method "贝叶斯估计"

The baseline uses deterministic Unicode normalization and BM25-style field ranking. It has no embedding-provider dependency. Search refuses missing or stale indexes, returns field-level score contributions, and exposes evidence back-links for matched methods. Only published or trusted cards are indexed; private drafts, reviewed-but-unpublished cards, and archived cards are excluded. See docs/paper-card-lexical-retrieval.md.

Evidence-grounded Agentic RAG query

Dry run: resolve the text route and check the lexical index without sending the question to a provider:

.\scripts\query_agentic_rag.ps1 `
    -Question "如何为多阶段生产检测设计决策模型?" `
    -Profile deepseek_qwen

Explicit execution:

.\scripts\query_agentic_rag.ps1 `
    -Question "如何为多阶段生产检测设计决策模型?" `
    -Profile deepseek_qwen `
    -Execute

The planner and synthesizer use structured output. Retrieval remains local and restricted to published or trusted PaperCards. The model sees an allow-listed evidence catalog and may return only existing citation IDs. Unknown or missing citations are withheld locally and produce insufficient_evidence. See docs/agentic-rag-query-flow.md.

Retrieval and Agent regression evaluation

The default synthetic benchmark reads no private corpus, calls no real provider, and returns a nonzero exit code when any versioned threshold fails:

.\scripts\evaluate_retrieval_agent.ps1
.\scripts\evaluate_retrieval_agent.ps1 -Json

Persist a machine-readable report:

.\scripts\evaluate_retrieval_agent.ps1 `
    -OutputPath ".\data\private\evaluation\reports\synthetic-v1.json" `
    -Json

See docs/evaluation.md and docs/retrieval-agent-evaluation.md.

Private-data boundary

Do not commit PDFs, extracted text, images, segmentation, review ledgers, PaperCard drafts, locally published cards, publication provenance, exact private identifiers/hashes, review notes, .env, keys, or local provider configuration. Both data/private/ and data/cards/ are runtime data and are Git-ignored. Automated tests use synthetic temporary data only.

Documentation

Start with:

  • AGENTS.md for durable collaboration and delivery rules;
  • docs/index.md for the documentation map;
  • docs/PROJECT_HANDOFF.md for current state;
  • docs/project-history.md for PR1 onward;
  • docs/roadmap.md for future milestones;
  • CHANGELOG.md for concise changes.

When local context is missing, generate a pasteable report instead of uploading a repository archive:

.\scripts\export-agent-context.ps1 `
    -Files @(
        "src\cumcm_agent\cards\review_publication_service.py",
        "tests\unit\test_paper_card_review_publication.py"
    ) `
    -OutputPath ".agent-context.txt"

About

No description, website, or topics provided.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages