WEN JIAYI - AI for Smart Ports & Maritime Systems
AI 应用 · 港航知识 AI APPLICATION × MARITIME KNOWLEDGE

Xiaoyi AI

“小懿 AI”港航行业智能问答与 SOP 决策助手

Maritime Knowledge, RAG & SOP Decision Assistant

系统面向港口调度、船舶运营与海事合规,将 112 份权威资料、708 个检索分块和 60 个官方核验来源组织为严格证据模式;回答覆盖混合检索、证据融合、条款级拒答、辖区与法规日期路由、结构化报告和 SOP 工作流,证据不足时主动拒答或降级。

A governed maritime knowledge assistant with hybrid retrieval, evidence fusion, clause-aware refusal and auditable orchestration.

完整项目演示FULL PROJECT DEMO
项目 READMEPROJECT README · GIT MAIN

完整项目说明Full Repository README

同步自 Git 主分支 Synced from Git main 46accd1 返回视频 Back to video

MARITIME RAG · EVIDENCE GOVERNANCE · SOP COPILOT

小懿 AI · 港航行业智能问答与SOP决策助手

Xiaoyi AI · Evidence-Grounded Maritime RAG & Operations Copilot

研发作者:温家懿 · Research Author: Wen Jiayi

把港航问答从“模型说了什么”,提升为“证据来自哪里、适用于哪个辖区和日期、何时必须拒答、谁允许推进任务”的可审计决策链。

A governance-first maritime assistant where retrieval, jurisdiction, temporal applicability, refusal, task progression, and audit evidence are independently reviewable.

112 登记文档 · 708 知识分块 · 60 官方来源 · 11/11 证据策略门禁

小懿AI港航助手原始形象

CI License Version Python FastAPI RAG benchmark Production boundary

核心指标 / Evidence · 能力全景 / Capabilities · 系统架构 / Architecture · 快速运行 / Quick start · 基准报告 / Benchmark · RL证据 / RL evidence · 开源审计 / Audit


核心证明数据 / Headline evidence

证据维度 / Evidence dimension 固定结果 / Pinned result 可复验入口 / Verification entry
知识快照 / Knowledge snapshot 112份文档、708个分块、60份官方核验来源
112 documents, 708 chunks, 60 officially verified sources
data/xiaoyi_index.json + data/source_registry.json
固定测试 / Fixed release acceptance 35题:24题检索 + 11题证据策略
35 tests: 24 retrieval + 11 evidence-policy cases
data/evaluation/maritime_qa_benchmark_v1.json
Hybrid检索 / Hybrid retrieval Hit@1/3/5 = 87.50% / 100% / 100% reports/maritime_rag_benchmark_v1.json
同快照对照 / Same-snapshot baseline MRR 0.8507 → 0.9236(+7.29个百分点 / pp) Hybrid Sparse vs BM25-only
证据治理 / Evidence governance 官方来源、Top-5纯度、双哈希完整率均 100%
Official-source rate, Top-5 purity, and dual-hash integrity all 100%
SHA-256固定索引、来源与核心策略代码
SHA-256-pinned index, source registry, and policy code
安全策略 / Safety policy 拒答、辖区、日期、实时数据边界 11/11通过
Refusal, jurisdiction, date, and live-data boundaries: 11/11 passed
python scripts/run_rag_benchmark.py verify --deep
RL 数据规模 / RL dataset scale 19,735 行 + 大规模 409,887 行(20.77×)+ NOAA港区AIS 710 个实测分钟桶 reports/rl_dataset_benchmark_v1.json
RL 固定对比 / Fixed RL comparison 3 数据集 × 3 种子 × 4 RL + PID;训练不渲染,测试后回放,所有算法平均投影约束违例 0 python scripts/run_rl_dataset_benchmark.py verify

Note

这些数字来自仓库固定发布验收集,不是第三方用户研究、生产SLA、法律意见或全球知识覆盖率。小懿默认将“公开/整理知识”“运营沙箱”“授权实时接口”和“生产动作权限”分开标识。

These figures come from the repository’s pinned release-acceptance set—not a third-party user study, production SLA, legal opinion, or global knowledge-coverage estimate. Xiaoyi explicitly separates curated public knowledge, the operations sandbox, authorized live interfaces, and production-action authority.

训练中心、算法矩阵、小懿训练顾问和全系统助手同屏联动
固定证据总览:同屏核对三套数据血缘、五算法矩阵、观测/动作/目标、小懿训练顾问和后端按钮联动。

能力全景 / Capability map

能力平面 / Plane 已实现 / Implemented 工程边界 / Guardrail
港航RAG / Maritime RAG Hybrid Sparse + BM25对照、来源路由、证据融合、结构化引用
Hybrid Sparse with BM25 baseline, source routing, evidence fusion, structured citations
无匹配证据时拒答,不补造条款
Refuses without matching evidence; never invents clauses
法规治理 / Regulatory governance 辖区、施行日期、官方来源要求、全文版权边界
Jurisdiction, effective date, official-source requirement, copyright boundary
回答不替代主管机关或法律意见
Answers do not replace authorities or legal advice
SOP决策 / SOP decision support 告警解释、对象追问、步骤任务、报告生成
Alert explanation, entity clarification, stepwise tasks, reports
高风险任务强制 requires_human_confirmation
High-risk tasks force requires_human_confirmation
运营沙箱 / Operations sandbox 船舶、泊位、设备、能耗、预警与任务API
Vessel, berth, equipment, energy, alert, and task APIs
未验证网关显示“等待接入港口”,不冒充生产实绩
Unverified gateways display “awaiting port connection,” never production performance
RL实验室 / RL laboratory Q-learning、SARSA、Expected SARSA、Double Q + PID;能源与AIS港口作业双环境 UCI用于算法规模,AIS用于交通语义;服务量/等待为校准代理,不宣称现场收益
平台工程 / Platform engineering FastAPI、SSE、JWT/RBAC、SQLite、幂等、限流、审计
FastAPI, SSE, JWT/RBAC, SQLite, idempotency, rate limits, audit
外部模型调用受隐私、证据和角色门禁约束
External model calls are privacy-, evidence-, and role-gated
可观测性 / Observability readiness、Prometheus、JSON日志、请求追踪、熔断
Readiness, Prometheus, JSON logs, request tracing, circuit breaker
未配置依赖失败关闭并返回可诊断状态
Unconfigured dependencies fail closed with diagnosable status

系统架构 / Architecture

flowchart LR
  subgraph Sources["Knowledge & Runtime Sources / 知识与运行来源"]
    KB["112 docs / 708 chunks"]
    REG["Authority registry\n官方来源与辖区"]
    OPS["Sandbox or verified live adapter\n沙箱或验证实时适配器"]
  end
  subgraph Intelligence["Evidence Intelligence / 证据智能"]
    HYB["Hybrid Sparse + BM25"]
    ROUTE["Jurisdiction + effective date"]
    POLICY["Citation · refusal · privacy gates"]
    LLM["Local rules / optional compatible gateway"]
  end
  subgraph Workflow["Human-Gated Workflow / 人工门禁工作流"]
    CHAT["SSE chat + structured answer"]
    SOP["SOP task + report"]
    AUDIT["Receipt + audit persistence"]
  end
  KB --> HYB
  REG --> ROUTE --> HYB --> POLICY
  OPS --> POLICY
  POLICY --> LLM --> CHAT
  CHAT --> SOP --> AUDIT
Loading

小懿港航知识、运营和安全治理架构

项目结构 / Repository map

小懿AI/
  app/
    main.py              # FastAPI服务入口 / service entry
    operations.py        # 运营、任务与报告API / operations, tasks, reports
    port_runtime.py      # 沙箱/生产数据适配器 / sandbox/live adapters
    rl_lab/              # 数据、4种RL、PID与评估 / data, 4 RL, PID, evaluation
    operator_assistant.py # 一线口语与对象追问 / frontline language and clarification
    xiaoyi.py            # 小懿回答引擎 / answer engine
    retrieval.py         # Hybrid Sparse与BM25对照 / retrieval and baseline
    prompts.py           # 港航专业提示词 / maritime prompts
    models.py            # 请求与响应模型 / request-response models
    config.py            # 路径与配置 / paths and configuration
  data/
    kb/                  # 港航知识库 / maritime knowledge base
    evaluation/          # 固定检索与证据评测 / pinned retrieval and policy set
    public/              # 公开RL数据与血缘 / public RL data and provenance
    port_profiles/       # 可替换港口参数与边界 / swappable port profiles
    rl_datasets.json     # 数据集目录 / dataset registry
    xiaoyi_index.json    # 检索索引 / retrieval index
  scripts/
    build_index.py       # 构建知识索引 / build knowledge index
    fetch_public_rl_dataset.py # 下载并校验公开RL数据 / fetch and verify
    fetch_large_public_rl_dataset.py # 409,887行大规模基准 / large benchmark
    fetch_noaa_port_ais_dataset.py # NOAA港区AIS场景 / public port AIS
    run_rl_dataset_benchmark.py # 三数据集多种子RL证据 / multi-seed RL evidence
    run_rag_benchmark.py # 固定RAG基准与哈希报告 / benchmark and hash report
  web/
    index.html           # Web交互页面 / Web interface
  tests/
    test_retrieval.py    # 检索验证 / retrieval verification
    test_operations_api.py # 运营API与回归 / operations API and regression

快速运行 / Quick start

推荐直接使用项目启动脚本;首次运行会创建 .venv、安装运行依赖、重建索引并启动服务:
Use the project launcher. On first run it creates .venv, installs runtime dependencies, rebuilds the index, and starts the service:

cd <xiaoyi-ai-repository>
bash run.sh

也可以手动运行:
Or run manually:

cd <xiaoyi-ai-repository>
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.lock
python scripts/build_index.py
uvicorn app.main:app --reload --port 8010

打开:
Open:

http://127.0.0.1:8010

命令行测试 / Command-line queries

cd <xiaoyi-ai-repository>
python -m app.cli "岸电 THDi 超标告警应该先检查什么?"
python -m app.cli "小懿的核心能力是什么?" --mode expert

系统说明 / System behavior

小懿是面向港航场景的小型 AI 助手。它采用本地港航知识库和 RAG 检索,结合专业问答、SOP 生成、告警解释和运营建议。默认 local_rules 生成路径不依赖外部模型;也可显式配置 OpenAI-compatible 模型网关。只有已通过证据门禁、不含沙箱运营数据且完成外发授权的回答才允许发往外部模型;其他情况保留本地严格证据答案。

Xiaoyi is a compact AI assistant for maritime and port operations. It combines a local maritime knowledge base and RAG retrieval with professional Q&A, SOP generation, alert explanation, and operational guidance. The default local_rules path does not depend on an external model; an OpenAI-compatible gateway can be configured explicitly. Only answers that pass the evidence gate, contain no sandbox operational data, and receive outbound authorization may reach an external model; all other cases retain the local strict-evidence answer.

运营看板默认使用后端持续生成的运营沙箱事件流。它具有生产形态的业务对象、时间戳、质量码、延迟和来源适配器,但明确标记为非生产实绩。切换生产时保持 port-ops.v1 契约并配置只读数据网关;高风险任务仍返回 requires_human_confirmation: true,不会因接入真实数据自动获得写权限。

The operations dashboard consumes a continuously generated backend sandbox event stream. It uses production-shaped entities, timestamps, quality codes, latency, and source adapters while remaining explicitly labelled non-production. A live integration retains the port-ops.v1 contract and a read-only gateway. High-risk tasks still return requires_human_confirmation: true; real data never grants write authority automatically.

小懿港航运营证据对话、现场数据边界和人工确认
证据约束对话:现场数据未接入时明确拒绝生成运营实绩,同时保留自然语言研判、证据状态和人工确认入口。

港口运营数据 API / Port-operations API

GET  /api/dashboard                 聚合概况、能耗、预警、任务 / aggregate operations, energy, alerts, tasks
GET  /api/runtime/status            模式、来源、质量与边界 / mode, provenance, quality, boundary
GET  /api/runtime/snapshot          船舶、泊位、设备等对象 / vessels, berths, equipment, yard, gates
GET  /api/operations/overview       运营概况 / operations overview
GET  /api/energy?range=today        能碳趋势 / energy-carbon trend (today / 7d / 30d)
GET  /api/alerts                    预警筛选 / alerts filtered by level/status
GET  /api/tasks/templates           任务模板 / executable task templates
POST /api/tasks                     创建沙箱任务 / create sandbox task
POST /api/tasks/{task_id}/next      推进任务步骤 / advance current step
POST /api/reports                   生成结构化报告 / generate structured report
GET  /api/reports/{report_id}       获取报告 / retrieve report
GET  /api/operator/scenarios        岗位问法与安全边界 / frontline prompts and safety limits

生产数据切换说明见 港口运营数据适配器。默认无需配置;接生产网关时设置 XIAOYI_PORT_DATA_MODE=liveXIAOYI_PORT_BASE_URL 和可选只读令牌即可。网关未返回 live_data_verified=true 或版本不是 port-ops.v1 时,服务会失败关闭,绝不把数据冒充生产实绩。

See the port-operations data adapter for live-data switching. No configuration is needed by default. For a production gateway, set XIAOYI_PORT_DATA_MODE=live, XIAOYI_PORT_BASE_URL, and an optional read-only token. The service fails closed unless the gateway returns live_data_verified=true and contract version port-ops.v1; unverified data is never presented as production performance.

运行测试:
Run tests:

python -m pip install -r requirements-dev.lock
pytest -q

安全、持久化与运维 / Security, persistence, and operations

本地模式仅用于回环开发。生产模式必须使用签名 JWT、显式主机名和 CORS 来源,否则服务拒绝启动。对话、任务、报告、自动化计划、反馈与审计保存在 SQLite;中断工作在重启后会安全标记为失败或取消,不会无声续跑。

Local mode is for loopback development only. Production requires signed JWTs, explicit hostnames, and CORS origins or the service refuses to start. Conversations, tasks, reports, automation plans, feedback, and audit evidence persist in SQLite. Interrupted work is safely marked failed or cancelled after restart rather than resuming silently.

GET  /health/live               进程存活 / process liveness
GET  /health/ready              深度就绪 / storage, index, RL, model, deployment readiness
GET  /metrics                   Prometheus指标 / metrics; restrict in production
GET  /api/system/info           安全与运维能力 / security and operations capability
GET  /api/models                模型、回退与熔断 / models, fallback, circuit breaker
GET  /api/conversations/{id}    持久对话 / identity-scoped conversation history
POST /api/chat/stream           SSE流式回答 / server-sent-event answer stream

部署、TLS/SSO、密钥、备份、模型数据外发和多实例边界见 部署指南;信任边界见 系统架构;开源审计结论见 真实性与工程化评估

See the deployment guide for TLS/SSO, secrets, backups, model-data egress, and multi-instance boundaries; architecture for trust boundaries; and open-source readiness for the engineering audit.

当前适合问的问题 / Suitable questions

完整分类问题库见:小懿可询问问题库。其中已区分当前运营沙箱、知识库问答和生产系统接入后实时问题。

See the categorized question library, which separates current sandbox questions, knowledge-base questions, and questions that require a verified live production connection.

可复现 RL 训练实验室 / Reproducible RL laboratory

RL板块不再回放其他项目的历史训练曲线。当前实现会在后台真实执行 Q-learning、SARSA、Expected SARSA 和 Double Q-learning,并用 PID 作为控制 理论基线。训练百分比来自已完成 episode 数,模型按算法保存并计算 SHA-256。

仓库同时保留三套数据:UCI Appliances 的 19,735 条原基准、UCI Household Power 聚合得到的 409,887 条五分钟级大规模基准,以及 NOAA Los Angeles–Long Beach 港区 710 个包含 AIS 消息的一分钟实测交通桶。前两套 证明算法规模与回归稳定性,不是港口实绩;AIS中的船舶数、航速、航行状态和 船型为公开观测,服务量、积压、等待和得分为校准沙箱代理。

The RL panel no longer replays historical curves from another project. It runs Q-learning, SARSA, Expected SARSA, and Double Q-learning in a real background worker, with PID as the control-theory baseline. Progress is derived from completed episodes; each algorithm artifact is saved and SHA-256 hashed.

The repository retains the original 19,735-row UCI benchmark, a 409,887-row five-minute UCI benchmark, and 710 observed minute buckets from public NOAA AIS messages in the Los Angeles–Long Beach port area. UCI data demonstrates algorithm scale, not port performance. AIS vessel count, speed, navigation status, and vessel class are measured; service, backlog, waiting, and score are calibrated sandbox proxies. Every dataset is split chronologically into train, validation, and sealed test segments. Training is headless and only post-training evaluation creates trajectories.

真实RL五算法、三套公开数据与训练隔离配置
真实训练配置:三套公开数据、4 RL + PID、回合/时域/随机种子及训练无渲染、测试后回放边界均由后端接收。

# 仓库已带数据;可从UCI重建 / bundled data; optionally rebuild from pinned UCI source
.venv/bin/python scripts/fetch_public_rl_dataset.py
.venv/bin/python scripts/fetch_large_public_rl_dataset.py
.venv/bin/python scripts/fetch_noaa_port_ais_dataset.py

# 复验固定三数据集×三种子报告 / verify the pinned multi-dataset report
.venv/bin/python scripts/run_rl_dataset_benchmark.py verify

# 运行全部测试 / run all tests
.venv/bin/python -m pytest -q

接口:

GET  /api/rl-lab/health
GET  /api/rl-lab/algorithms
GET  /api/rl-lab/datasets
GET  /api/rl-lab/contracts
GET  /api/rl-lab/evidence
POST /api/rl-lab/advisor
POST /api/rl-lab/runs
GET  /api/rl-lab/runs/{run_id}
POST /api/rl-lab/runs/{run_id}/cancel
POST /api/rl-lab/runs/{run_id}/evaluate

能源环境最少提供 timestamp,load_kw;港口作业环境最少提供 timestamp,vessel_count,anchored_vessels,avg_sog_knots,并设置 XIAOYI_RL_ENVIRONMENT_TYPE=port_operations 与港口 profile。字段名不同只需 配置 JSON 映射,不改训练器。完整说明见港口RL可替换数据契约落地执行清单

The energy environment requires timestamp,load_kw. The port-operations environment requires timestamp,vessel_count,anchored_vessels,avg_sog_knots, XIAOYI_RL_ENVIRONMENT_TYPE=port_operations, and a port profile. Site columns are mapped through JSON without changing the trainer. See the swappable port RL contract and landing checklist.

AIS驱动港口环境观测动作目标函数安全约束与生产写入边界
港口环境契约:11项观测、5项动作、目标函数、硬约束、动作屏蔽和生产写入边界可直接与站点字段逐项核对。

  • 港口由哪些核心业务模块组成? / What are the core operating domains of a port?
  • 集装箱码头从船舶靠泊到离港的流程是什么? / What is the container-terminal workflow from berthing to departure?
  • TOS 系统在港口运营里负责什么? / What does a TOS manage in port operations?
  • 岸电 THDi 超标告警应该先检查什么? / What should be checked first after a shore-power THDi alarm?
  • 台风红色预警下港区要启动哪些安全流程? / Which safety procedures apply under a red typhoon warning?
  • 港口碳排放盘查需要保留哪些证据? / What evidence must be retained for a port carbon inventory?
  • 小懿的系统架构是什么? / What is Xiaoyi’s system architecture?

真实港口连接器(待站点联调)/ Live-port connectors (site integration pending)

项目已预留 TOS、PCS、EMS、EAM、VTS、AIS、气象海洋和国际贸易单一窗口连接器契约,但默认全部离线,未配置任何真实端点或凭据。安全配置、站点联调、写操作门禁、回滚和审计要求见 港口连接器接入手册,环境变量模板见 .env.connectors.example

The project defines connector contracts for TOS, PCS, EMS, EAM, VTS, AIS, metocean services, and maritime single windows. All are offline by default, with no real endpoint or credential bundled. See the port-connector integration manual for secure configuration, site commissioning, write gates, rollback, and audit requirements, and .env.connectors.example for environment templates.

GET  /api/connectors                              目录与状态 / catalogue and status
GET  /api/connectors/{id}/field-mappings          字段映射 / field-mapping template
POST /api/connectors/{id}/health-check            真实健康探测 / real health probe
POST /api/connectors/{id}/write-preflight         写预检,不下发 / write preflight; no dispatch

智能操作与可审计知识库 / Intelligent operations and auditable knowledge

POST /api/automation/plans                       自然语言转白名单步骤 / language-to-allowlisted steps
POST /api/automation/plans/{id}/next             回写并推进 / record result and advance
POST /api/automation/plans/{id}/confirm          人工确认或拒绝 / bind human approval or rejection
GET  /api/knowledge/status                       文档、来源与索引哈希 / docs, sources, index hashes
GET  /api/knowledge/catalog                      24类/96主题路线图 / 24-domain, 96-topic roadmap
GET  /api/knowledge/authority-coverage           权威覆盖与缺口 / authority coverage and gaps
POST /api/knowledge/search                       来源与双SHA-256检索 / search with source and dual hashes
GET  /api/knowledge/sources                      来源登记与等级 / source registry and verification level
POST /api/knowledge/intake                       待审资料暂存 / stage material for human review

专业资料全目录与当前覆盖状态见 港航专业知识总目录;知识来源分级、资料审核、发布、索引重建与拒答边界见 知识库治理说明

一线调度、值班、设备、闸口、堆场和交接班人员的完整使用流程见 一线操作人员系统指南

See the maritime knowledge catalogue for current coverage and the knowledge-governance guide for source tiers, review, publication, index rebuilds, and refusal boundaries. The frontline operator guide covers dispatchers, duty teams, equipment, gates, yard personnel, and shift handover.

小懿智能联动中心(7项能力)/ Xiaoyi intelligence hub (7 capabilities)

小懿只承担港航知识、RAG、上下文识别、能力路由、结果解释和审计,不复制能碳驾驶舱、数字孪生平台、马六甲沙盘或航行模拟器的业务功能。跨系统能力默认 offline,不访问其他系统;dry-run 只检查契约,显式配置为 live 后也只允许登记的 GET 只读能力。

Xiaoyi owns maritime knowledge, RAG, context resolution, capability routing, result explanation, and audit. It does not duplicate the CarbonOps cockpit, digital-twin platform, Malacca sandbox, or sailing simulator. Cross-system capabilities default to offline; dry-run verifies only contracts, and even explicit live mode permits registered read-only GET capabilities only.

小懿智能联动中心七项能力、跨系统隔离和RAG评测闭环
联动与评测闭环:7/7代表小懿平台能力已登记;标题同步给出4个系统与11项只读能力边界,并展示知识快照、检索对照、证据策略和持久审计。

GET  /api/hub/systems                            四系统目录 / four-system catalogue
GET  /api/hub/capabilities                       只读能力 / read-only capabilities
POST /api/hub/capabilities/{id}/invoke           隔离预览或授权只读 / isolated preview or approved read
POST /api/context/resolve                        统一业务上下文 / unified business context
POST /api/evidence/fuse                          证据融合 / knowledge-system-simulation fusion
POST /api/orchestrator/run                       跨系统编排 / natural-language orchestration
GET  /api/governance/audit                       SQLite持久审计 / persistent audit
POST /api/evaluation/run                         固定RAG回归 / pinned RAG regression
POST /api/evaluation/feedback                    人工反馈 / human feedback
POST /api/evaluation/feedback/{id}/review        审核入待审区 / reviewed intake staging

网页左侧点击“智能联动中心”即可查看 7/7 完成度、系统能力注册表、跨系统安全预览、RAG 评测和反馈闭环。完整验证步骤见 智能联动中心说明

Open “智能联动中心 / Intelligence Hub” from the left navigation to inspect 7/7 capability status, the system registry, safe cross-system previews, RAG evaluation, and the feedback loop. See the intelligence-hub guide for verification.

可复现港航 RAG 与证据安全基准 / Reproducible maritime RAG and evidence-safety benchmark

仓库提供 60 题固定版本评测集:40 题检索、20 题证据策略;其中 35 题构成 v1 固定测试分区。当前知识快照为 112 份文档、708 个分块和 60 份官方核验来源。测试分区的 24 个检索题上,Hybrid Sparse 的 Hit@1/3/5 为 87.50%/100%/100%,BM25-only 为 75.00%/95.83%/100%;Hybrid 在首位命中率上提升 12.50 个百分点, MRR 为 0.9236 对 0.8507(+7.29 个百分点)。Hit@5 同为 100%,不把 已经饱和的 Top-5 指标包装成提升。 11 个策略测试覆盖条款级拒答、无依据回答阻断、辖区路由、法规日期切换和 实时数据边界,当前为 11/11。

The repository publishes a fixed 60-question set: 40 retrieval cases and 20 evidence-policy cases, with 35 forming the pinned v1 test partition. The knowledge snapshot contains 112 documents, 708 chunks, and 60 officially verified sources. Across the 24 retrieval questions in the test partition, Hybrid Sparse reaches Hit@1/3/5 of 87.50%/100%/100%, versus 75.00%/95.83%/100% for BM25-only. Hybrid improves first-rank hit rate by 12.50 percentage points and MRR from 0.8507 to 0.9236 (+7.29 percentage points). Since both methods already reach 100% Hit@5, the README does not misrepresent the saturated Top-5 metric as an improvement. Eleven policy tests cover clause-level refusal, unsupported-answer blocking, jurisdiction routing, regulation-date switching, and live-data boundaries; all 11 pass.

# 快速哈希核验 / verify report-bound data, index, and policy-code hashes
.venv/bin/python scripts/run_rag_benchmark.py verify

# 深度复算60题 / rerun all 60 cases; may take minutes on one CPU core
.venv/bin/python scripts/run_rag_benchmark.py verify --deep

# 重新生成报告 / regenerate the report
.venv/bin/python scripts/run_rag_benchmark.py run

固定题集、JSON证据报告可读报告随仓库发布。该测试分区用于 v1 发布验收,并在工程修复中暴露过缺陷,因此不是“从未查看的独立留出集”; 题目由项目维护,也不是第三方用户研究。上述数字是仓库基准上的检索与安全 指标,不是港口生产收益、全球知识覆盖率、法律意见或线上 SLA。

The fixed questions, JSON evidence report, and readable report ship with the repository. The partition is a v1 release-acceptance set that has exposed defects during engineering fixes; it is not a never-inspected independent holdout, and it is maintained by this project rather than a third-party user study. These are repository retrieval and safety metrics—not port-production benefits, global knowledge coverage, legal advice, or an online SLA.

简历可用声明与禁用表述见 简历指标口径
See resume claim semantics for permitted and prohibited wording.

112治理知识文档 GOVERNED DOCUMENTS港口、航运、海事合规与 SOP 权威资料
708检索知识分块 RETRIEVAL CHUNKS版本化知识切片与来源注册表统一治理
87.50%首位正确来源命中率 HIT@124 道固定检索题;较 BM25 提升 12.50 个百分点
0.9236混合检索 MRR HYBRID MRR同过滤 BM25-only 为 0.8507,提升 7.29 个百分点
11 / 11策略边界测试 POLICY BOUNDARY TESTS拒答、辖区、日期与实时数据边界全部通过
核心模块CORE MODULES

可治理的港航行业智能工作流Governed Maritime Intelligence Workflow

混合证据检索01 · Hybrid Evidence Retrieval

在统一版本化索引契约下实现 Sparse/BM25 检索、证据融合、来源分级与固定快照评测。

法规回答门禁02 · Regulatory Answer Guardrails

实现条款级拒答、无依据回答阻断、辖区路由、生效日期切换与实时数据边界。

SOP 与结构化报告03 · SOP & Structured Reporting

面向港航运营提供角色化流程、告警解读、追问澄清与可追溯结构化报告。

受控能力联动中心04 · Governed Capability Hub

通过工具注册、证据感知编排、JWT/RBAC、人工确认与持久化审计控制能力调用。

检索与边界评测RAG EVALUATION

固定知识快照、检索基线与安全策略评测Knowledge Snapshot, Retrieval Baseline & Safety Suite

基准设计 BENCHMARK DESIGN

60 道问题绑定官方来源键

固定基准包含 25 道历史验证题和 35 道固定测试题;测试分区由 24 道检索题与 11 个策略边界案例组成。

  • 60 份官方核验来源
  • 统计正确来源进入前 1 / 3 / 5 位的比例
  • 官方来源要求满足率:100%
基线对比 BASELINE COMPARISON

混合检索提升正确来源排序

BM25-only 是纯词法检索基线,按词频与稀有度排序且不进行语义融合;Hybrid 检索加入互补稀疏信号与证据感知重排。

  • Hit@1:75.00% → 87.50%
  • Hit@3:95.83% → 100%
  • MRR:0.8507 → 0.9236
知识治理 KNOWLEDGE GOVERNANCE

知识覆盖按目录登记,不夸大范围

权威来源注册表跟踪 41 个来源族:24 个已索引、10 个计划补充、7 个因许可隔离;24 类 / 96 主题目录记录已索引、部分覆盖和计划状态。

  • 69 个主题已索引
  • 25 个主题部分覆盖,2 个计划补充
  • 8 份核心证据文件绑定 SHA-256
评测指标结果含义
Hybrid Hit@1 / 3 / 587.50 / 100 / 100%24 道检索题中正确来源进入前 k 条结果
同过滤 BM25-only75.00 / 95.83 / 100%Hit@5 已饱和,不包装成提升
平均倒数排名 MRR0.8507 → 0.9236提升 7.29 个百分点,正确来源平均排序更靠前
证据治理完整性100%官方 Top-5 来源纯度、证据双哈希与辖区路由均通过
安全策略测试11 / 11覆盖拒答、无依据回答、辖区、日期和实时数据边界
仓库回归测试210 项通过完整 pytest、发布检查与基准哈希核验

证据边界 Evidence boundary以上为仓库固定知识快照与验收题集,不是盲测、生产客服 KPI 或“覆盖全部港航法规”的声明。离线连接器和目录型来源不等同于已索引正文;需要实时船期、气象或生产系统状态时,系统必须调用经核验适配器,否则失效关闭。

技术栈TECHNOLOGY STACK

工程与研究技术栈Engineering and Research Stack

Python · FastAPI · Pydantic
工程职责 RESPONSIBILITY

助手服务、运营接口与严格数据契约

Assistant services, operational APIs and strict data contracts
项目已实现IMPLEMENTED
Hybrid Sparse · BM25 · RAG
工程职责 RESPONSIBILITY

词法检索、证据融合与来源重排

Lexical retrieval, evidence fusion and source-aware reranking
项目已实现IMPLEMENTED
SSE · OpenAI-Compatible Gateway
工程职责 RESPONSIBILITY

流式回答与模型网关抽象

Streaming answers and model-provider abstraction
项目已实现IMPLEMENTED
JWT · RBAC · SQLite Audit
工程职责 RESPONSIBILITY

身份鉴权、权限与持久审计

Identity, authorization and persistent traceability
项目已实现IMPLEMENTED
Native JavaScript · CSS
工程职责 RESPONSIBILITY

轻依赖运营界面与报告流程

Low-dependency operator interface and report workflows
项目已实现IMPLEMENTED
Docker · GitHub Actions · pytest
工程职责 RESPONSIBILITY

可复现交付、回归与证据门禁

Reproducible delivery, regression and evidence gates
项目已实现IMPLEMENTED
项目价值PROJECT VALUE

将行业知识转化为安全运营辅助Domain Knowledge into Safe Operational Assistance

“小懿 AI”以提升行业决策质量和可追溯性为目标,而不是追求回答数量;证据排序、拒答正确性和知识覆盖状态均可见、可测试。

知识获取价值

将法规、规则、港口运营与船舶管理资料统一为可检索证据库,使调度与合规人员能够从回答直接追溯到来源,而不是依赖无法核验的模型记忆。

决策安全价值

对条款缺失、辖区错配、有效期冲突和实时数据不足执行拒答或降级,避免“语言流畅但依据错误”的专业风险,并保留人工确认。

知识治理价值

用来源注册、授权隔离、覆盖缺口、版本快照、固定题集和哈希门禁管理知识生命周期,使新增资料、模型替换和回归评测都可追踪。

能力概览CAPABILITY SUMMARY

港航行业 AI 助手全栈工程能力Full-Stack Maritime AI Assistant Engineering

该项目体现从 RAG 检索、领域提示词、API 工程、知识治理到运营工作流、审计和跨系统编排的独立全栈交付能力。

Independent full-stack delivery across RAG, domain prompting, API engineering, knowledge governance and auditable orchestration.

jiayiwen.cn/xiaoyi-ai