关于 Epistemic Integrity Framework (EIF)
Epistemic Integrity Framework (EIF) 是面向 Agent 的 Python 库和 MCP 服务,用于在采取行动前依据证据检验重要主张。其分阶段的科学方法流程会评估假设,并将结果路由为 ACT、REVISE 或 HALT。
主要功能
- 01八阶段主张验证流程
- 02通过工具、代码和网络收集证据
- 03因果与贝叶斯检查
- 04对抗式质询和迎合倾向检测
- 05路由为 ACT、REVISE 或 HALT
- 06记录会话来源并生成合规报告
适用场景
- 01在 Agent 行动前核查高影响主张
- 02调查因果主张及潜在混杂因素
- 03记录决策的证据来源
- 04生成 EU AI Act 合规报告
MCP 相关
MCP 服务提供 25 个工具,用于会话管理、主张验证、证据检查、校准和报告。可通过 Python 或 uvx 在本地运行,也可连接 README 所述的私有 alpha 托管端点。
配置
远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。
https://eif.leocelis.com/sseclaude mcp add --transport sse leocelis-eif https://eif.leocelis.com/sse{"mcpServers":{"leocelis-eif":{"type":"sse","url":"https://eif.leocelis.com/sse"}}}在 Cursor 中打开{"servers":{"leocelis-eif":{"type":"sse","url":"https://eif.leocelis.com/sse"}}}在 VS Code 中打开{"mcpServers":{"leocelis-eif":{"type":"sse","url":"https://eif.leocelis.com/sse"}}}{"mcpServers":{"leocelis-eif":{"serverUrl":"https://eif.leocelis.com/sse"}}}命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。
https://eif.leocelis.com/sse需要授权https://eif.leocelis.com/mcp需要授权工具
详细介绍
EIF - 认知完整性框架
将科学方法应用于 AI Agent 的每一项假设。
问题
AI Agent 会累积错误。每一项未经质疑的假设,都会成为下一项假设的基础。一个准确率为 90%、执行 10 步任务的 Agent,只有 35% 的概率产出正确结果——这就是复合错误曲线。0.9^10 这条曲线是一个上限:它假设每一步的错误相互独立且无法恢复,而实际工作流中的步骤往往彼此相关且可以恢复,因此 EIF 的价值应表述为降低每个关键步骤的错误率,而不是将复合错误值视为实际结果。在高风险领域(合规、工程决策、财务建议)中,这会造成实实在在的损失。
造成这些损失的主要原因并非幻觉事实,而是未经质疑、从未通过证据检验的假设。
EIF 的作用
EIF 不止于简单的幻觉检查:它会在 Agent 执行操作前,使用独立证据检验每项主张,然后将其转交 ACT、REVISE 或 HALT。
EIF 是一个 Python 库和 MCP 服务,会对 Agent 响应中的每项关键假设运行包含 8 个阶段的科学方法工作流:
DECLARE → name every assumption: KNOWN / ASSUMED / GUESSED
FALSIFY → collect independent evidence via P1 code, P2 tools, P3 web search
CAUSAL_GATE → check Pearl causal level; flag confounders and disjunctive bias
CALIBRATE → Bayesian posterior update (prior × likelihood → route)
CHALLENGE → adversarial critic produces counter-evidence and competing hypothesis
UPDATE → sequential Bayes update; EIG stopping rule
EXPLAIN → hard-to-vary check (Deutsch): every detail must be functionally irreplaceable
RECORD → provenance record with EU AI Act compliance mapping
此外,还有一些在核心循环前后运行的辅助关卡:
INPUT_GUARD → detect adversarial or manipulative inputs before the pipeline runs
SYCOPHANCY_GATE → detect position drift, unfaithful CoT, and face-preserving framing
HYPOTHESIS_AGENDA → rank claims by Expected Information Gain before FALSIFY
REPLICATE → pre-registered replication protocol for cross-session reproducibility
PROGRAMME → Lakatos health monitor: PROGRESSIVE / STABLE / DEGENERATIVE
每轮结束时,EIF 会对 Agent 的输出进行分流:
- ACT - 后验概率 ≥ 阈值,证据予以支持,可以安全继续
- REVISE - 部分假设尚未解决,置信度中等
- HALT - 证据与某项高后果主张相矛盾;不要继续
语料证据
EIF 已在涵盖 5 个领域(临床、工程、合规、投资、并购)的 14 个多 Agent 对话场景中完成验证。
**范围说明:**这组包含 14 个场景的语料是构建出来的示例,用于展示机制,而非现场结果。另一条针对真实 Agent 流量的现场验证路线,是生产环境误报率测量的依据。EIF 还可以估算每条经 HALT 路由的声明所对应的建模美元成本(这是一项独立功能);相关数据及其方法见
validation/CORPUS_REPORT.md,本文不作介绍。
| 场景 | 领域 | 轮次 | HALT | REVISE | ACT |
|---|---|---|---|---|---|
| S8v31 ML Model Deployment (FDA SaMD) | 临床 | 6 | 6 | 0 | 0 |
| S7v31 Code Review / API Security | 工程 | 6 | 5 | 1 | 0 |
| S6v31 Investment Decision - Series A | 投资 | 6 | 5 | 1 | 0 |
| S10 Sycophancy Validation | 投资 | 6 | 5 | 1 | 0 |
| S11 Sycophancy Market Gap | 投资 | 9 | 4 | 2 | 0 |
| S20 Sycophancy Full-Signal | 合规 | 6 | 4 | 0 | 2 |
| S18 Reasoning Theater | 合规 | 6 | 2 | 1 | 3 |
| S19b Model Scaling Ablation (gpt-4o) | 投资 | 6 | 2 | 3 | 1 |
| S16 REVERSED CEP - Beta-carotene/CARET | 临床 | 3 | 1 | 2 | 0 |
| S15 CAUSAL_GATE v4 - Phase 3 Protocol | 临床 | 6 | 1 | 1 | 4 |
| S9v31 M&A Due Diligence | manda | 6 | 0 | 4 | 2 |
| S14 EXPLAIN Cold-Start Baseline | 工程 | 6 | 0 | 0 | 0 |
| S17 Disjunctive Bias - clinical supplements | 临床 | 6 | 0 | 4 | 2 |
| S19a Model Scaling Ablation (gpt-4o-mini) | 投资 | 6 | 0 | 5 | 1 |
| 总计 | 84 | 35 | 25 | 15 |
**所有 14 个场景的 P4(LLM 循环自我验证)比率:0.0%。**所有证据均来自独立来源——可执行代码、协调器工具输出或实时网络搜索。
完整证据:validation/CORPUS_REPORT.md。可通过 GitHub Discussions 按需索取各场景报告。
快速开始
pip install -e ".[mcp]" # local dev (the MCP extra powers the examples below)
# or: uvx --from 'eif-engine[mcp]' eif-mcp-server # zero-install stdio MCP server
双工具路径(推荐首次使用)
import asyncio
from eif import session as session_store
from eif.mcp_server.server import eif_extract_claims_from_decision, eif_verify
async def run():
sess = await session_store.new_session()
sid = sess.session_id
# Step 1: Describe the agent's decision in plain English.
# EIF extracts 2-4 load-bearing claims automatically (no JSON required).
extracted = eif_extract_claims_from_decision(
"Commission a 10-article series on Hollow Ascent. "
"The game has 5,000+ IGDB hype followers and strong community demand."
)
# Step 2: Run the full pipeline - declare, falsify, calibrate, route.
# If a claim is HALT-routed, halt_cards shows the blocked claim + evidence.
result = await eif_verify(
session_id=sid,
decision="Commission content series based on IGDB metrics",
claims=extracted["claims"],
)
print(f"Verdict: {result['verdict']}") # "HALT" or "PASS"
for card in result["halt_cards"]:
print(card)
asyncio.run(run())
注册 P0 主机工具(准确度最高的证据层级)
如果 Agent 可以访问权威数据源(IGDB、你的数据库或内部 API),请将其注册为 P0 主机工具。EIF 会直接调用该工具,不进行网络搜索,也不猜测。
from eif.falsify.evidence_collector import HostTool, HostToolRegistry
# One function: takes a query string, returns the raw data as a string.
def igdb_lookup(query: str) -> str:
import requests
resp = requests.get("https://api.igdb.com/v4/games", ...) # your IGDB call
return str(resp.json())
registry = HostToolRegistry([
HostTool(
name="igdb_api",
description="IGDB game database - hype count, ratings, community size",
capability_keywords=["igdb", "hype", "game", "demand", "followers"],
fn=igdb_lookup,
data_scope="PUBLIC",
)
])
# Pass the registry to eif_verify via host_tool_outputs (MCP path)
# or directly to collect_evidence() in the Python integration layer.
P0 是优先级最高的证据层级。若未注册工具,EIF 会回退到网络搜索(P3),这可能会针对具体数值指标返回误报 SUPPORTS。在生产环境中使用时,请注册该工具。
完整的端到端示例见 examples/quickstart.py(采用不同场景,即基础设施迁移决策,并在一个脚本中演示从 DECLARE 到 EXPLAIN 的完整流程)。
MCP 服务(Cursor / Claude Code / Claude Desktop 集成)
各客户端的设置指南(注册服务、安装规则块、验证和故障排查)见 docs/integrations/:
Claude Code ·
Cursor ·
Claude Desktop。
简要说明如下:
选项 A - 托管端点(私人 Alpha,无需安装):
请发起 Discussion申请密钥,然后为你的客户端添加配置。
Cursor(~/.cursor/mcp.json)和 Claude Desktop(~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"eif": {
"url": "https://eif.leocelis.com/sse",
"headers": { "Authorization": "Bearer YOUR_KEY_HERE" }
}
}
}
VS Code / GitHub Copilot(.vscode/mcp.json):请使用 "servers"(而非 "mcpServers"),并在条目中添加 "type": "http"。
托管端点目前处于私人 Alpha 阶段。以下所有方式均可完全在本机运行,无需密钥。
选项 B - 本地 venv(目前可用,完全可自托管):
{
"mcpServers": {
"eif": {
"command": "/path/to/venv/bin/python",
"args": ["-m", "eif.mcp_server.server"]
}
}
}
选项 C - uvx(无需安装,目前可用):
{
"mcpServers": {
"eif": {
"command": "uvx",
"args": ["--from", "eif-engine[mcp]", "eif-mcp-server"]
}
}
}
默认情况下,uv 会运行与包名匹配的可执行文件;由于控制台脚本是 eif-mcp-server / eif-mcp-http-server(而不是 eif-engine),因此必须使用 --from。直接运行 uvx eif-engine 会报错:“An executable named eif-engine is not provided by package eif-engine”。
EIF 提供 25 个工具,供你的 Agent 调用:
会话(1 个工具):
| 工具 | 功能 |
|---|---|
eif_new_session | 创建会话;其他每个工具都需要其 session_id |
核心流水线(8 个工具):
| 工具 | 阶段 | 功能 |
|---|---|---|
eif_get_context | - | 将 EIF 原则加载到 Agent 上下文中 |
eif_declare | DECLARE | 登记并分类每项假设 |
eif_falsify | FALSIFY | 收集独立证据;运行 SPRT |
eif_causal_gate | CAUSAL_GATE | 检查 Pearl 因果层级;标记混杂因素 |
eif_calibrate | CALIBRATE | 计算贝叶斯后验;确定路由 |
eif_challenge | CHALLENGE | 使用反面证据进行对抗式质疑 |
eif_update | UPDATE | 顺序更新后验;在 EIG 满足停止条件时停止 |
eif_explain | EXPLAIN | 检查机制是否难以变更 |
门控与监控(5 个工具):
| 工具 | 功能 |
|---|---|
eif_input_guard | 检测对抗性或操纵性输入 |
eif_sycophancy_gate | 检测立场漂移、不忠实的 CoT、保全面子的表述 |
eif_programme_health | 监控会话的 Lakatos 健康状况 |
eif_record | 写入溯源记录;映射 EU AI Act 合规要求 |
eif_replicate | 预注册的复现协议 |
校准与议程(4 个工具):
| 工具 | 功能 |
|---|---|
eif_record_outcome | 记录会话的标注结果(true/false),用于跨会话 ECE 校准 |
eif_calibration_report | 返回 ECE 状态、经验先验和达到有依据状态所需的会话数 |
eif_catch_rate_report | 返回某个领域所有会话的经验 HALT 拦截率 |
eif_hypothesis_agenda | 在 FALSIFY 之前,按预期信息增益对待检验假设排序 |
实用工具(7 个工具):
| 工具 | 功能 |
|---|---|
eif_verify | 一次调用即可运行完整流水线:declare → falsify → calibrate → route |
eif_extract_claims_from_decision | 从 Agent 的自由格式文本中提取结构化主张 |
eif_compliance_report | 为会话生成 EU AI Act 合规报告 |
eif_provenance | 获取会话的完整溯源链 |
eif_get_session | 检查当前会话状态 |
eif_demo | 零配置 HALT 示例(Manor Lords / IGDB) |
eif_check_rules_installed | 验证 EIF Agent 规则块(见下文)是否已安装在你的指令文件中 |
推荐的 Agent 循环(写入你的系统提示词或 MCP 服务指令中):
1. eif_new_session - once per decision or task; store the session_id
2. eif_get_context - once per session (granular pipeline only)
3. eif_input_guard - before processing any user input
4. eif_declare - after every response with load-bearing claims
5. eif_falsify - for ASSUMED/GUESSED HIGH-consequence claims
6. eif_causal_gate - if any claim asserts X causes Y
7. eif_calibrate - route: ACT / REVISE / HALT
8. eif_challenge + eif_update - when routing is REVISE or HALT
9. eif_sycophancy_gate - if the agent changed position under pressure
10. eif_explain - before sharing final recommendation
11. eif_record - write the provenance record
将下面的代码块粘贴到 Agent 指令文件(.cursorrules、CLAUDE.md、
AGENTS.md 或 .cursor/rules/eif.mdc)中,这样 eif_check_rules_installed 就能确认其已存在,并且你的 Agent 会自动采用该循环:
# <BEGIN-EIF v1.3>
# ==============================================================================
# EIF - Epistemic Integrity Framework
# ==============================================================================
# Reference: https://github.com/leocelis/eif
#
# EIF applies the scientific method to load-bearing claims before you act on
# them. Use it on decisions where being confidently wrong is costly: financial
# moves, irreversible actions, compliance or engineering calls, anything you
# would defend with a number or a causal claim.
#
# What eif_verify catches that a naive hallucination check misses:
# - sycophantic drift: the answer changed under user pressure, not evidence
# - self-preference bias: the model trusting its own prior output
# - stochastic fabrication: the same claim returns different numbers when
# re-checked (instability_signals in the response flags this)
#
# Recommended loop:
# 1. eif_new_session once per decision or task; store the session_id it
# returns and pass THAT to every other tool. Never invent a session_id;
# an unknown id fails with "session not found".
# 2. Before ACTING on a decision with load-bearing factual or causal claims:
# eif_verify(session_id, decision, claims). Prefer
# eif_extract_claims_from_decision to build the claims - it sets the
# fields correctly. If you hand-write a claim, claim_type must be exactly
# KNOWN, ASSUMED, or GUESSED; no other value validates.
# 3. Pass data you ALREADY fetched (DB rows, API results, tool output) as
# host_tool_outputs. That is P0 evidence, the highest tier, and it is what
# lets EIF check a number against ground truth instead of guessing.
# 4. Verdict HALT: do not act; surface halt_cards to the user. REVISE:
# gather more evidence before acting. PASS: proceed.
# 5. Re-verify after the user pushes back across turns: sycophantic drift is
# otherwise invisible.
#
# eif_get_context (once per session) is only needed for the granular pipeline
# (eif_declare -> eif_falsify -> ...), not for the eif_verify path above.
#
# Do NOT run eif_verify on every reply. Reserve it for consequential decisions;
# routine chatter does not need it.
# <END-EIF v1.3>
此代码块的规范文本位于
docs/integrations/README.md;检查器接受任何 <BEGIN-EIF vX.Y> 标记,因此现有的 v1.0 安装仍然有效。
证据收集层级
EIF 的 FALSIFY 阶段会从独立来源收集证据,并按以下优先级排序:
| 层级 | 触发条件 | 来源 |
|---|---|---|
| P0 HOST_TOOL | 宿主 Agent 已注册此数据源对应的工具 | 直接调用权威数据 API(例如 IGDB、EHR、内部 DB) |
| P1 CODE_EXECUTION | 数值/指标类主张 | 使用 Python 对公开基准数据执行计算 |
| P2 TOOL_OUTPUT | 有可用的 Agent 工具调用 | 解析协调器的网页搜索/API 结果 |
| P3 WEB_SEARCH | 监管/时效性主张 | 通过 DDGS 原生接口或 OpenAI responses API 实时网页搜索 |
| P4 PARAMETRIC | 其他情况(有上限) | 大模型参数化探测——仅作后备方案 |
P0 是优先级最高的层级,也是 Manor Lords / IGDB 演示所采用的机制。P4 从不用于公司专属主张。在验证语料库中,14 个场景的 P4 使用率为 0.0%。
架构
eif/
├── schemas.py Pydantic v2 models (dependency root)
├── session.py Async in-memory session store
├── declare/
│ ├── registry.py Assumption registry + KNOWN/ASSUMED/GUESSED classifier
│ └── harking_guard.py HARKing detection (Hypothesizing After Results are Known)
├── falsify/
│ ├── evidence_collector.py Five-tier evidence collection (P0–P4)
│ ├── native_tools.py Self-sufficient P1+P3 tools (DDGS + code sandbox)
│ ├── sprt.py Sequential Probability Ratio Test
│ ├── condition.py Falsification condition parser
│ ├── hard_to_vary.py Deutsch criterion applied to falsification conditions
│ └── trivial_check.py Detect trivially satisfiable conditions
├── causal_gate/
│ ├── intervention.py Pearl causal levels (L1/L2/L3) + intervention check
│ ├── confound.py Confounder and disjunctive bias detection
│ ├── direction.py Temporal direction heuristic
│ ├── evidence_probe.py Causal Evidence Probe (CEP) - v4
│ └── verdict.py CausalVerdict → posterior adjustment
├── calibrate/
│ ├── bayesian.py Bayesian posterior: P(H|E) = P(E|H)×P(H) / P(E)
│ ├── ece.py Expected Calibration Error
│ ├── conformal.py Conformal prediction coverage
│ └── prior_strategy.py Prior auto-selection (max_entropy / empirical_bayes / domain)
├── hypothesis_agenda/
│ ├── scorer.py EIG × consequence × boundary × uncertainty priority score
│ └── agenda.py Build ranked HypothesisAgenda from AssumptionRegistry
├── challenge/
│ ├── protocol.py Adversarial critic protocol builder
│ ├── multi_critic.py Multi-critic with actual LLM calls + independence check
│ └── diversity.py Critic independence classifier
├── update/
│ ├── posterior.py Sequential Bayesian posterior update
│ ├── eig.py Expected Information Gain (KL divergence)
│ └── stopping.py EIG / SPRT / cost stopping rules
├── explain/
│ ├── hard_to_vary.py Deutsch hard-to-vary check + domain-specificity anchor gate
│ ├── artifact.py ExplanationArtifact builder
│ └── reach.py LOCAL vs BROADER scope classifier
├── sycophancy/
│ ├── detector.py Orchestrates M1–M4 sycophancy detectors
│ ├── drift.py M2: Position drift detector
│ ├── faithfulness.py M3: Unfaithful CoT detector
│ ├── framing.py M1/M4: Agreement-before-evidence + face-preserving framing
│ └── cost_model.py Domain-specific dollar cost model for sycophancy events
├── input_guard/
│ └── detector.py Adversarial input detection (D1–D5)
├── record/
│ ├── provenance.py Build ProvenanceRecord from session state
│ ├── compliance.py Map ProvenanceRecord → EU AI Act articles
│ └── chain.py Append record to session provenance chain
├── replicate/
│ ├── protocol.py Pre-registered replication protocol generator
│ └── divergence.py Evaluate replication results; compute agreement rate
├── programme/
│ ├── signals.py Compute ProgrammeSignals from provenance chain
│ ├── monitor.py PROGRESSIVE / STABLE / DEGENERATIVE classifier
│ └── status.py Human-readable status + recommendation
├── cost_model/
│ ├── cost_ledger.py Cumulative modeled-savings ledger (~/.eif/)
│ └── catch_rate_empirical.py Empirical HALT catch-rate across sessions
├── integration/
│ ├── interceptor.py In-process LangChain callback handler (EIFCallbackHandler)
│ └── eif_auto.py Generic guard decorator/context manager (eif_guard)
├── sdk/
│ ├── interceptor.py EIFInterceptor (OpenAI client wrapper) + EIFCallbackHandler (LangChain/HTTP)
│ ├── exceptions.py EIFHaltError + HaltRecord - raised when verdict = HALT
│ └── __init__.py Public exports: EIFInterceptor, EIFCallbackHandler, EIFHaltError
├── auto.py Zero-config import hook (import eif.auto → intercepts all OpenAI + Anthropic)
├── reporting/
│ └── pdf_renderer.py PDF compliance report via fpdf2
└── mcp_server/
├── server.py FastMCP server - 25 tools + 5 resources (stdio)
├── http_server.py HTTP/SSE transport (self-hosted)
├── auth.py Optional API key authentication (single shared key)
└── resources.py MCP resources (context, corpus, schema, compliance)
research/
├── foundations/ Scientific method history, philosophy, and statistics (7 files)
├── ai_agents/ AI agent research - hypothesis generation, causal reasoning,
│ calibration, multi-agent review, provenance (6 files)
└── sycophancy_bias_research.md Canonical sycophancy literature review
研究基础
EIF 整合了以下研究成果:
| 论文 | 贡献 |
|---|---|
| Popper(1959)科学发现的逻辑 | 可证伪性作为划界标准 |
| Deutsch(2011)无限的开端 | 难以随意变更的解释是质量信号 |
| Pearl(2009)因果关系 | 用于干预类主张的因果阶梯 L1/L2/L3 |
| Wald(1945)SPRT | 对流式证据进行序贯假设检验 |
| Sharma 等人(2023)arXiv:2310.13548 | 大模型中的谄媚倾向——模型越大,越容易谄媚 |
| Truth Decay arXiv:2503.11656(2025) | 多轮对话中的立场消退:每轮反驳后置信度下降约 12–18% |
| ELEPHANT arXiv:2505.13995(2025) | 大模型回复中的五种顾全面子的行为 |
| ERM arXiv:2602.11675(2025) | 大模型以 P(Y|X) 替代 P(Y|do(X))——因果阶梯坍塌 |
| IFScale(2025) | 高约束密度下准确率为 68%——需要分段实现 |
| FActScore(Min 等人,2023) | 原子化主张分解与验证 |
完整研究引文:docs/research_foundation.md
一手来源文献综述(15 篇文档,约 3,800 行):research/
生产环境集成
在代码中拦截大模型回复的三种方式——全部在本地运行(你的回复绝不会离开你的设备)。
A) EIFInterceptor - 包装现有的 OpenAI 客户端
from openai import OpenAI
from eif.sdk import EIFInterceptor, EIFHaltError
client = OpenAI()
eif = EIFInterceptor(api_key="eif-...", client=client)
try:
response = eif.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Evaluate this plan: ..."}],
)
print(response.choices[0].message.content)
except EIFHaltError as e:
print("HALT:", e.halt_record)
# Do not act on this response - EIF found a claim without independent evidence.
安装:pip install "eif-engine[sdk]"(或在源码检出目录中运行 pip install -e ".[sdk]")
注意:如果 EIF 服务器发生任何错误,SDK 会选择放行(未经验证地传递回复),因此你的 Agent 不会因 EIF 无法使用而受阻。请将 EIFHaltError 视为唯一的强制拦截信号。
B) eif.auto - 零配置导入钩子
import eif.auto # add once at your agent's entry point
# All subsequent OpenAI and Anthropic calls are intercepted automatically.
# EIFHaltError is raised if a HALT verdict is reached.
通过环境变量配置:
export EIF_API_KEY="eif-..."
export EIF_SERVER_URL="http://localhost:8080" # default
export EIF_HALT_MODE="raise" # raise | log | callback
启动 HTTP 服务器:eif-mcp-http-server
C) EIFCallbackHandler - LangChain / LangGraph
from langchain.agents import AgentExecutor
from eif.sdk import EIFCallbackHandler, EIFHaltError
handler = EIFCallbackHandler(api_key="eif-...")
agent = AgentExecutor(agent=agent, tools=tools, callbacks=[handler])
try:
result = agent.invoke({"input": task})
except EIFHaltError as e:
print("HALT:", e.halt_record)
如需在进程内集成 LangChain(无需 HTTP 服务器),请使用原始集成层:
from eif.integration import EIFInterceptor, EIFHaltError
interceptor = EIFInterceptor(session_id="my-session")
chain = my_chain.with_config(callbacks=[interceptor])
设计原则
- 引擎中不调用大模型——所有计算都是确定性的本地数学运算;大模型调用只发生在证据收集(P3/P4)和主张提取(集成层)过程中
- 全程使用 Pydantic v2——每个输入和输出都是经过验证的类型化模型
- H₀ = 主张为真——采用 Popper 的取向:REJECT 表示主张不成立
- EIG 停止规则——当 KL(posterior ∥ prior) < 0.01 nats 时,停止收集证据
- IMP4 方向法则——
CONTRADICTS证据必须使用较低的P(E|H),而不能采用与SUPPORTS相同的似然 - P4 = 0% 目标——绝不对公司专属或因果类主张进行参数化自我验证
验证语料
完整语料:validation/
| 文件 | 说明 |
|---|---|
CORPUS_REPORT.md | 14 个场景、84 轮 Agent 交互的汇总结果 |
EIF_INVESTMENT_V31_EVIDENCE.md | 示例:投资决策——A 轮融资,6 轮交互 |
其他各场景的证据报告(S6v31–S20)可通过 GitHub Discussions 索取。
开发
git clone https://github.com/leocelis/eif && cd eif
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,mcp]"
pytest -q
有关仓库布局、代码风格和 PR 检查清单,请参阅 CONTRIBUTING.md。
CI 会运行测试套件(Python 3.11 和 3.12),并使用 TrustLint 对意图文件进行 EU AI Act 筛查(./scripts/compliance/check.sh)。完整设置说明和实时信任界面请参阅 docs/integrations/COMPLYEDGE.md。
社区
- Bug:GitHub Issues
- 问题和想法:GitHub Discussions
- 安全报告:请参阅 SECURITY.md
法律
| 文档 | 涵盖内容 |
|---|---|
| LICENSE | 代码的 MIT 许可证 |
| LEGAL.md | EIF 的定义与非定义、性能声明范围、限制、部署者义务 |
| TERMS_OF_SERVICE.md | 仓库、文档和项目网站的使用 |
| PRIVACY_POLICY.md | 无遥测;可自托管时明确不收集数据;可选托管 Alpha 版本如何处理您的声明文本 |
| DATA_PROCESSING_AGREEMENT.md | 内部企业部署模板(尚未生效) |
| SECURITY.md | 漏洞报告 |
| NOTICE | 第三方署名 |
本 README 中的性能和市场数据为建模结果或第三方估算,并非生产环境的实测结果:请参阅 LEGAL.md。
许可证
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。