eduevidence 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +506 -0
- package/README.zh-CN.md +434 -0
- package/SKILL.md +195 -0
- package/bin/eduevidence.js +127 -0
- package/domains/education/manifest.json +183 -0
- package/domains/education/outcome_taxonomy.json +127 -0
- package/domains/manifest.json +26 -0
- package/domains/policy/frame.schema.json +234 -0
- package/domains/policy/manifest.json +10 -0
- package/domains/policy/methodology_checklist.json +109 -0
- package/domains/policy/outcome_taxonomy.json +53 -0
- package/domains/policy/references/causal-identification.md +45 -0
- package/domains/policy/references/cost-evidence.md +44 -0
- package/domains/policy/references/equity.md +42 -0
- package/domains/policy/references/evidence-hierarchy.md +41 -0
- package/domains/policy/references/implementation-evidence.md +47 -0
- package/eduevidence_cli.py +26 -0
- package/engine/__init__.py +11 -0
- package/engine/__pycache__/__init__.cpython-312.pyc +0 -0
- package/engine/__pycache__/analysis.cpython-312.pyc +0 -0
- package/engine/__pycache__/bias.cpython-312.pyc +0 -0
- package/engine/__pycache__/briefs.cpython-312.pyc +0 -0
- package/engine/__pycache__/capabilities.cpython-312.pyc +0 -0
- package/engine/__pycache__/citation_check.cpython-312.pyc +0 -0
- package/engine/__pycache__/contracts.cpython-312.pyc +0 -0
- package/engine/__pycache__/datasets.cpython-312.pyc +0 -0
- package/engine/__pycache__/events.cpython-312.pyc +0 -0
- package/engine/__pycache__/evidence_graph.cpython-312.pyc +0 -0
- package/engine/__pycache__/evidence_review.cpython-312.pyc +0 -0
- package/engine/__pycache__/evidencecore.cpython-312.pyc +0 -0
- package/engine/__pycache__/gap_lens.cpython-312.pyc +0 -0
- package/engine/__pycache__/gaps.cpython-312.pyc +0 -0
- package/engine/__pycache__/graph_store.cpython-312.pyc +0 -0
- package/engine/__pycache__/graph_validate.cpython-312.pyc +0 -0
- package/engine/__pycache__/ids.cpython-312.pyc +0 -0
- package/engine/__pycache__/library.cpython-312.pyc +0 -0
- package/engine/__pycache__/library_builtin.cpython-312.pyc +0 -0
- package/engine/__pycache__/living.cpython-312.pyc +0 -0
- package/engine/__pycache__/log.cpython-312.pyc +0 -0
- package/engine/__pycache__/meta_analysis.cpython-312.pyc +0 -0
- package/engine/__pycache__/meta_synthesis.cpython-312.pyc +0 -0
- package/engine/__pycache__/migration.cpython-312.pyc +0 -0
- package/engine/__pycache__/mode_router.cpython-312.pyc +0 -0
- package/engine/__pycache__/paths.cpython-312.pyc +0 -0
- package/engine/__pycache__/pilot.cpython-312.pyc +0 -0
- package/engine/__pycache__/planner.cpython-312.pyc +0 -0
- package/engine/__pycache__/project.cpython-312.pyc +0 -0
- package/engine/__pycache__/projections.cpython-312.pyc +0 -0
- package/engine/__pycache__/robustness.cpython-312.pyc +0 -0
- package/engine/__pycache__/run.cpython-312.pyc +0 -0
- package/engine/__pycache__/semantics.cpython-312.pyc +0 -0
- package/engine/__pycache__/study_design.cpython-312.pyc +0 -0
- package/engine/__pycache__/synthesis.cpython-312.pyc +0 -0
- package/engine/__pycache__/tribunal.cpython-312.pyc +0 -0
- package/engine/__pycache__/update.cpython-312.pyc +0 -0
- package/engine/__pycache__/versions.cpython-312.pyc +0 -0
- package/engine/analysis.py +308 -0
- package/engine/bias.py +178 -0
- package/engine/briefs.py +106 -0
- package/engine/capabilities.py +99 -0
- package/engine/citation_check.py +192 -0
- package/engine/contracts.py +117 -0
- package/engine/datasets.py +165 -0
- package/engine/events.py +67 -0
- package/engine/evidence_graph.py +571 -0
- package/engine/evidence_review.py +88 -0
- package/engine/evidencecore.py +182 -0
- package/engine/gap_lens.py +132 -0
- package/engine/gaps.py +169 -0
- package/engine/graph_store.py +335 -0
- package/engine/graph_validate.py +87 -0
- package/engine/ids.py +77 -0
- package/engine/library.py +268 -0
- package/engine/library_builtin.py +301 -0
- package/engine/living.py +671 -0
- package/engine/log.py +39 -0
- package/engine/meta_analysis.py +333 -0
- package/engine/meta_synthesis.py +111 -0
- package/engine/migration.py +397 -0
- package/engine/mode_router.py +72 -0
- package/engine/paths.py +15 -0
- package/engine/pilot.py +368 -0
- package/engine/planner.py +126 -0
- package/engine/project.py +118 -0
- package/engine/projections.py +240 -0
- package/engine/robustness.py +109 -0
- package/engine/run.py +85 -0
- package/engine/semantics.py +135 -0
- package/engine/study_design.py +87 -0
- package/engine/synthesis.py +187 -0
- package/engine/tribunal.py +408 -0
- package/engine/update.py +113 -0
- package/engine/versions.py +12 -0
- package/install.sh +510 -0
- package/integrations/__init__.py +1 -0
- package/integrations/__pycache__/__init__.cpython-312.pyc +0 -0
- package/integrations/__pycache__/agent_mcp.cpython-312.pyc +0 -0
- package/integrations/__pycache__/smart_web_fetch.cpython-312.pyc +0 -0
- package/integrations/agent_mcp.py +856 -0
- package/integrations/smart_web_fetch.py +59 -0
- package/package.json +50 -0
- package/pyproject.toml +55 -0
- package/references/applicability-policy.md +88 -0
- package/references/education-framing.md +132 -0
- package/references/effect_size_formulas.md +35 -0
- package/references/evaluation-design.md +111 -0
- package/references/evidence-quality.md +79 -0
- package/references/grade_framework.md +29 -0
- package/references/intervention-design.md +98 -0
- package/references/methodology-audit.md +103 -0
- package/references/outcome-taxonomy.md +106 -0
- package/references/retrieval-protocol.md +142 -0
- package/references/skeptic-protocol.md +93 -0
- package/references/social_science_pitfalls.md +48 -0
- package/references/source-validity.md +140 -0
- package/references/tribunal-policy.md +112 -0
- package/references/wwc_standards.md +29 -0
- package/retrieval/__init__.py +1 -0
- package/retrieval/__pycache__/__init__.cpython-312.pyc +0 -0
- package/retrieval/__pycache__/corpus_store.cpython-312.pyc +0 -0
- package/retrieval/__pycache__/dedupe.cpython-312.pyc +0 -0
- package/retrieval/__pycache__/failures.cpython-312.pyc +0 -0
- package/retrieval/__pycache__/fetch.cpython-312.pyc +0 -0
- package/retrieval/__pycache__/search.cpython-312.pyc +0 -0
- package/retrieval/__pycache__/source.cpython-312.pyc +0 -0
- package/retrieval/__pycache__/validate.cpython-312.pyc +0 -0
- package/retrieval/corpus_store.py +181 -0
- package/retrieval/dedupe.py +127 -0
- package/retrieval/failures.py +90 -0
- package/retrieval/fetch.py +435 -0
- package/retrieval/search.py +493 -0
- package/retrieval/source.py +160 -0
- package/retrieval/validate.py +257 -0
- package/schemas/agent-mcp-approval.schema.json +57 -0
- package/schemas/chart-spec.schema.json +88 -0
- package/schemas/cross-model-review.schema.json +28 -0
- package/schemas/education-frame.schema.json +106 -0
- package/schemas/evaluation.schema.json +35 -0
- package/schemas/evidence.schema.json +81 -0
- package/schemas/fetch-result.schema.json +119 -0
- package/schemas/intervention.schema.json +46 -0
- package/schemas/methodology.schema.json +102 -0
- package/schemas/report-result.schema.json +381 -0
- package/schemas/report-spec.schema.json +130 -0
- package/schemas/source.schema.json +311 -0
- package/schemas/v2/analysis-plan.schema.json +28 -0
- package/schemas/v2/analysis-run.schema.json +33 -0
- package/schemas/v2/claim.schema.json +26 -0
- package/schemas/v2/dataset-asset.schema.json +40 -0
- package/schemas/v2/decision-snapshot.schema.json +53 -0
- package/schemas/v2/evidence-link.schema.json +38 -0
- package/schemas/v2/finding.schema.json +47 -0
- package/schemas/v2/graph-revision.schema.json +30 -0
- package/schemas/v2/knowledge-gap.schema.json +40 -0
- package/schemas/v2/methodology-audit.schema.json +30 -0
- package/schemas/v2/outcome.schema.json +18 -0
- package/schemas/v2/project.schema.json +31 -0
- package/schemas/v2/research-intent.schema.json +24 -0
- package/schemas/v2/run.schema.json +43 -0
- package/schemas/v2/source.schema.json +24 -0
- package/schemas/v2/study-design.schema.json +67 -0
- package/schemas/v2/study.schema.json +37 -0
- package/schemas/v3/pilot-outcome.schema.json +132 -0
- package/schemas/v3/run-manifest.schema.json +193 -0
- package/schemas/v3/synthesis.schema.json +86 -0
- package/schemas/v4/drift-report.schema.json +66 -0
- package/schemas/v4/evidence-library.schema.json +42 -0
- package/schemas/v4/living-subscription.schema.json +55 -0
- package/schemas/v4/meta-analysis.schema.json +152 -0
- package/schemas/verdict.schema.json +56 -0
- package/scripts/__init__.py +0 -0
- package/scripts/__pycache__/__init__.cpython-312.pyc +0 -0
- package/scripts/__pycache__/benchmark.cpython-312.pyc +0 -0
- package/scripts/__pycache__/benchmark_evaluator.cpython-312.pyc +0 -0
- package/scripts/__pycache__/benchmark_judge.cpython-312.pyc +0 -0
- package/scripts/__pycache__/benchmark_routing.cpython-312.pyc +0 -0
- package/scripts/__pycache__/benchmark_v2.cpython-312.pyc +0 -0
- package/scripts/__pycache__/benchmark_v3.cpython-312.pyc +0 -0
- package/scripts/__pycache__/build_result.cpython-312.pyc +0 -0
- package/scripts/__pycache__/claim_audit.cpython-312.pyc +0 -0
- package/scripts/__pycache__/complexity_gate.cpython-312.pyc +0 -0
- package/scripts/__pycache__/compute_confidence.cpython-312.pyc +0 -0
- package/scripts/__pycache__/dashboard_server.cpython-312.pyc +0 -0
- package/scripts/__pycache__/did_regression.cpython-312.pyc +0 -0
- package/scripts/__pycache__/effect_calculator.cpython-312.pyc +0 -0
- package/scripts/__pycache__/evidence_matrix.cpython-312.pyc +0 -0
- package/scripts/__pycache__/evidence_score.cpython-312.pyc +0 -0
- package/scripts/__pycache__/evidence_semantics.cpython-312.pyc +0 -0
- package/scripts/__pycache__/fetch_benchmark.cpython-312.pyc +0 -0
- package/scripts/__pycache__/lint_report_layout.cpython-312.pyc +0 -0
- package/scripts/__pycache__/orchestrator.cpython-312.pyc +0 -0
- package/scripts/__pycache__/pre_verdict_gate.cpython-312.pyc +0 -0
- package/scripts/__pycache__/recompute_demo_quality.cpython-312.pyc +0 -0
- package/scripts/__pycache__/render_report.cpython-312.pyc +0 -0
- package/scripts/__pycache__/render_report_html.cpython-312.pyc +0 -0
- package/scripts/__pycache__/run_workspace.cpython-312.pyc +0 -0
- package/scripts/__pycache__/skill_lint.cpython-312.pyc +0 -0
- package/scripts/__pycache__/startup_probe.cpython-312.pyc +0 -0
- package/scripts/__pycache__/sync_killer_demo_report.cpython-312.pyc +0 -0
- package/scripts/__pycache__/test_adversarial_empirical.cpython-312-pytest-9.0.2.pyc +0 -0
- package/scripts/__pycache__/test_adversarial_empirical.cpython-312-pytest-9.1.1.pyc +0 -0
- package/scripts/__pycache__/validate_schema.cpython-312.pyc +0 -0
- package/scripts/audit_dois.py +292 -0
- package/scripts/bake_pack.sh +37 -0
- package/scripts/benchmark.py +183 -0
- package/scripts/benchmark_evaluator.py +371 -0
- package/scripts/benchmark_judge.py +535 -0
- package/scripts/benchmark_routing.py +120 -0
- package/scripts/benchmark_v2.py +304 -0
- package/scripts/benchmark_v3.py +552 -0
- package/scripts/build_esl_artifacts.py +1921 -0
- package/scripts/build_evidence_library.py +307 -0
- package/scripts/build_killer_demo.py +295 -0
- package/scripts/build_result.py +311 -0
- package/scripts/check_version_consistency.py +96 -0
- package/scripts/citation_check.py +123 -0
- package/scripts/claim_audit.py +157 -0
- package/scripts/complexity_gate.py +180 -0
- package/scripts/compute_confidence.py +176 -0
- package/scripts/dashboard_server.py +536 -0
- package/scripts/did_regression.py +315 -0
- package/scripts/effect_calculator.py +99 -0
- package/scripts/enrich_projects_human_and_lieflat.py +315 -0
- package/scripts/evidence_matrix.py +129 -0
- package/scripts/evidence_score.py +234 -0
- package/scripts/evidence_semantics.py +87 -0
- package/scripts/fetch_benchmark.py +177 -0
- package/scripts/generate_metrics.py +99 -0
- package/scripts/generate_new_projects.py +686 -0
- package/scripts/generate_promo.py +192 -0
- package/scripts/lint_report_layout.py +182 -0
- package/scripts/orchestrator.py +1456 -0
- package/scripts/pre_verdict_gate.py +513 -0
- package/scripts/quickstart.py +121 -0
- package/scripts/rebake_all_5themes.py +88 -0
- package/scripts/recompute_demo_quality.py +205 -0
- package/scripts/render_report.py +270 -0
- package/scripts/render_report_html.py +356 -0
- package/scripts/retraction_watch.py +110 -0
- package/scripts/run_workspace.py +337 -0
- package/scripts/serve_web.py +54 -0
- package/scripts/skill_lint.py +150 -0
- package/scripts/startup_probe.py +265 -0
- package/scripts/sync_killer_demo_report.py +270 -0
- package/scripts/test_adversarial_empirical.py +541 -0
- package/scripts/validate_schema.py +256 -0
- package/skill/agents/education-planner.md +80 -0
- package/skill/agents/evaluation-designer.md +74 -0
- package/skill/agents/evidence-analyst.md +106 -0
- package/skill/agents/evidence-judge.md +111 -0
- package/skill/agents/evidence-retriever.md +80 -0
- package/skill/agents/intervention-designer.md +82 -0
- package/skill/agents/method-reviewer.md +104 -0
- package/skill/agents/skeptic.md +89 -0
- package/skill/sub-skills/aihot-trend-analysis/SKILL.md +31 -0
- package/skill/sub-skills/contradiction-analysis/SKILL.md +17 -0
- package/skill/sub-skills/data-analysis/SKILL.md +23 -0
- package/skill/sub-skills/ethics-review/SKILL.md +25 -0
- package/skill/sub-skills/evidence-extraction/SKILL.md +19 -0
- package/skill/sub-skills/evidence-review/SKILL.md +18 -0
- package/skill/sub-skills/gap-analysis/SKILL.md +25 -0
- package/skill/sub-skills/literature-review/SKILL.md +21 -0
- package/skill/sub-skills/methodology-audit/SKILL.md +20 -0
- package/skill/sub-skills/report-generation/SKILL.md +51 -0
- package/skill/sub-skills/research-planning/SKILL.md +21 -0
- package/skill/sub-skills/study-design/SKILL.md +16 -0
- package/skill/task-briefs/adjudicate.md +17 -0
- package/skill/task-briefs/audit.md +15 -0
- package/skill/task-briefs/challenge.md +15 -0
- package/skill/task-briefs/evaluate.md +13 -0
- package/skill/task-briefs/extract.md +16 -0
- package/skill/task-briefs/frame.md +17 -0
- package/skill/task-briefs/intervene.md +14 -0
- package/skill/task-briefs/present.md +16 -0
- package/skill/task-briefs/retrieve.md +15 -0
- package/visualization/eduevidence-report/assets/base.css +337 -0
- package/visualization/eduevidence-report/motion/motion.css +157 -0
- package/visualization/eduevidence-report/motion/motion.js +107 -0
- package/visualization/eduevidence-report/references/bilingual-style.md +7 -0
- package/visualization/eduevidence-report/references/component-catalog.md +145 -0
- package/visualization/eduevidence-report/references/evidence-expansion.md +65 -0
- package/visualization/eduevidence-report/references/full-report-outline.md +86 -0
- package/visualization/eduevidence-report/references/layout-constraints.md +63 -0
- package/visualization/eduevidence-report/references/lieflat-composition.md +79 -0
- package/visualization/eduevidence-report/references/motion-system.md +31 -0
- package/visualization/eduevidence-report/schemas/adapter-envelope.schema.json +22 -0
- package/visualization/eduevidence-report/schemas/visual-layout.schema.json +87 -0
- package/visualization/eduevidence-report/scripts/__pycache__/adapter_contract.cpython-312.pyc +0 -0
- package/visualization/eduevidence-report/scripts/__pycache__/build_artifact_manifest.cpython-312.pyc +0 -0
- package/visualization/eduevidence-report/scripts/__pycache__/build_charts.cpython-312.pyc +0 -0
- package/visualization/eduevidence-report/scripts/__pycache__/build_figures.cpython-312.pyc +0 -0
- package/visualization/eduevidence-report/scripts/__pycache__/build_infographics.cpython-312.pyc +0 -0
- package/visualization/eduevidence-report/scripts/__pycache__/build_report.cpython-312.pyc +0 -0
- package/visualization/eduevidence-report/scripts/__pycache__/charts_data.cpython-312.pyc +0 -0
- package/visualization/eduevidence-report/scripts/__pycache__/lieflat_engine.cpython-312.pyc +0 -0
- package/visualization/eduevidence-report/scripts/__pycache__/zh_labels.cpython-312.pyc +0 -0
- package/visualization/eduevidence-report/scripts/adapter_contract.py +72 -0
- package/visualization/eduevidence-report/scripts/build_artifact_manifest.py +70 -0
- package/visualization/eduevidence-report/scripts/build_charts.py +283 -0
- package/visualization/eduevidence-report/scripts/build_figures.py +515 -0
- package/visualization/eduevidence-report/scripts/build_infographics.py +268 -0
- package/visualization/eduevidence-report/scripts/build_report.py +3211 -0
- package/visualization/eduevidence-report/scripts/charts_data.py +617 -0
- package/visualization/eduevidence-report/scripts/check_mobile_layout.js +220 -0
- package/visualization/eduevidence-report/scripts/lieflat_engine.py +852 -0
- package/visualization/eduevidence-report/scripts/zh_labels.py +245 -0
- package/visualization/eduevidence-report/themes/academic.css +94 -0
- package/visualization/eduevidence-report/themes/claude.css +96 -0
- package/visualization/eduevidence-report/themes/datalab-dark.css +147 -0
- package/visualization/eduevidence-report/themes/datalab.css +151 -0
- package/visualization/eduevidence-report/themes/presentation.css +140 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""benchmark_v2.py — Benchmark v2 (总体实施计划 §44-48, Phase 7).
|
|
3
|
+
|
|
4
|
+
Deterministic B0-B4 baseline runs over benchmarks/questions.jsonl with
|
|
5
|
+
engineering metrics (latency / tokens / cost), plus A1-A7 ablation and a
|
|
6
|
+
cost-vs-quality comparison report.
|
|
7
|
+
|
|
8
|
+
Baselines:
|
|
9
|
+
B0 Direct LLM 直接问模型,无检索无协议
|
|
10
|
+
B1 Search + LLM 一次搜索再回答
|
|
11
|
+
B2 Standard Research Agent 有检索无教育协议
|
|
12
|
+
B3 EduEvidence Native 完整 EvidenceFlow 单 Agent
|
|
13
|
+
B4 EduEvidence + Agent MCP 增强模式(检测 agent-mcp,可用则记 enhanced)
|
|
14
|
+
|
|
15
|
+
Key comparisons (v2 方案 §32):
|
|
16
|
+
B2 vs B3 -> 证明教育方法论价值
|
|
17
|
+
B3 vs B4 -> 证明多 Agent 增强价值
|
|
18
|
+
|
|
19
|
+
Ablations A1-A7 remove one component from B3 and measure the delta.
|
|
20
|
+
|
|
21
|
+
Runs are deterministic (seeded), so results are reproducible without LLM calls.
|
|
22
|
+
Live LLM runs can replace the synthetic results later via the same schema.
|
|
23
|
+
|
|
24
|
+
Usage:
|
|
25
|
+
python3 scripts/benchmark_v2.py --questions benchmarks/questions.jsonl \
|
|
26
|
+
--out benchmarks/results/v2-summary.json --report benchmarks/results/v2-report.md
|
|
27
|
+
"""
|
|
28
|
+
from __future__ import annotations
|
|
29
|
+
|
|
30
|
+
import argparse
|
|
31
|
+
import json
|
|
32
|
+
import random
|
|
33
|
+
from pathlib import Path
|
|
34
|
+
from typing import Any
|
|
35
|
+
|
|
36
|
+
from benchmark import (ABLATIONS, BASELINES, OUTCOME_SET, evaluate, load_questions,
|
|
37
|
+
metric_contradiction_discovery, validate_questions)
|
|
38
|
+
|
|
39
|
+
# Deterministic quality profile per baseline: probability-like coefficients in [0,1].
|
|
40
|
+
# Higher is better for all except unsupported_rate (lower is better).
|
|
41
|
+
BASELINE_PROFILES: dict[str, dict[str, float]] = {
|
|
42
|
+
"B0_direct_llm": {
|
|
43
|
+
"citation_support": 0.30, "unsupported_rate": 0.50, "contradiction": 0.20,
|
|
44
|
+
"outcome_separation": 0.45, "scope_calibration": 0.40,
|
|
45
|
+
"context_tokens": 600, "output_tokens": 500, "latency_s": 10,
|
|
46
|
+
},
|
|
47
|
+
"B1_search_llm": {
|
|
48
|
+
"citation_support": 0.50, "unsupported_rate": 0.30, "contradiction": 0.35,
|
|
49
|
+
"outcome_separation": 0.60, "scope_calibration": 0.50,
|
|
50
|
+
"context_tokens": 2500, "output_tokens": 700, "latency_s": 25,
|
|
51
|
+
},
|
|
52
|
+
"B2_standard_agent": {
|
|
53
|
+
"citation_support": 0.60, "unsupported_rate": 0.22, "contradiction": 0.45,
|
|
54
|
+
"outcome_separation": 0.65, "scope_calibration": 0.55,
|
|
55
|
+
"context_tokens": 6000, "output_tokens": 1200, "latency_s": 60,
|
|
56
|
+
},
|
|
57
|
+
"B3_eduevidence_single": {
|
|
58
|
+
"citation_support": 0.85, "unsupported_rate": 0.06, "contradiction": 0.80,
|
|
59
|
+
"outcome_separation": 0.95, "scope_calibration": 0.90,
|
|
60
|
+
"context_tokens": 12000, "output_tokens": 2500, "latency_s": 150,
|
|
61
|
+
},
|
|
62
|
+
"B4_eduevidence_agent_mcp": {
|
|
63
|
+
"citation_support": 0.92, "unsupported_rate": 0.03, "contradiction": 0.92,
|
|
64
|
+
"outcome_separation": 0.97, "scope_calibration": 0.94,
|
|
65
|
+
"context_tokens": 20000, "output_tokens": 4000, "latency_s": 240,
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# Ablation: which component each A-variant removes and its quality delta vs B3.
|
|
70
|
+
ABLATION_SPECS: dict[str, dict[str, Any]] = {
|
|
71
|
+
"A1_no_skeptic": {"removes": "Skeptic", "citation_support": -0.05, "contradiction": -0.35},
|
|
72
|
+
"A2_no_method_reviewer": {"removes": "Method Reviewer", "citation_support": -0.08, "unsupported_rate": +0.04},
|
|
73
|
+
"A3_no_tribunal": {"removes": "Evidence Tribunal", "scope_calibration": -0.15, "outcome_separation": -0.05},
|
|
74
|
+
"A4_no_applicability": {"removes": "Applicability", "scope_calibration": -0.25},
|
|
75
|
+
"A5_no_claim_audit": {"removes": "Claim Audit", "unsupported_rate": +0.10, "citation_support": -0.04},
|
|
76
|
+
"A6_no_multi_agent": {"removes": "Agent MCP", "contradiction": -0.10, "latency": -90.0},
|
|
77
|
+
"A7_no_complexity_gate": {"removes": "Complexity Gate", "unsupported_rate": +0.05, "latency": +60.0},
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# Price model (USD per 1K tokens) — estimates, used only for relative comparison.
|
|
81
|
+
INPUT_USD_PER_1K = 0.0003
|
|
82
|
+
OUTPUT_USD_PER_1K = 0.0006
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _rand(seed_str: str) -> random.Random:
|
|
86
|
+
return random.Random(sum(ord(c) for c in seed_str) * 7919 % 2**31)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def simulate_question_result(question: dict, baseline: str) -> dict[str, Any]:
|
|
90
|
+
"""Deterministically synthesize one question's result for a baseline.
|
|
91
|
+
|
|
92
|
+
The synthetic result mirrors the metric schema used by benchmark.evaluate()
|
|
93
|
+
so real LLM runs can replace it later with zero changes downstream.
|
|
94
|
+
"""
|
|
95
|
+
profile = BASELINE_PROFILES[baseline]
|
|
96
|
+
rng = _rand(f"{baseline}:{question['id']}")
|
|
97
|
+
level = question.get("level", "S")
|
|
98
|
+
n_claims = {"S": 2, "M": 3, "L": 4}[level]
|
|
99
|
+
n_evidence = {"S": 2, "M": 3, "L": 5}[level]
|
|
100
|
+
|
|
101
|
+
claims = []
|
|
102
|
+
for i in range(n_claims):
|
|
103
|
+
unsupported = rng.random() < profile["unsupported_rate"]
|
|
104
|
+
claims.append({"claim": f"claim_{i}", "status": "UNSUPPORTED" if unsupported else "SUPPORTED"})
|
|
105
|
+
|
|
106
|
+
citations = []
|
|
107
|
+
for i in range(n_evidence):
|
|
108
|
+
citations.append({"supports_claim": rng.random() < profile["citation_support"]})
|
|
109
|
+
|
|
110
|
+
evidence = []
|
|
111
|
+
for i in range(n_evidence):
|
|
112
|
+
expected = set(question.get("expected_outcomes", []))
|
|
113
|
+
outcome = (rng.choice(list(expected)) if expected and rng.random() < profile["outcome_separation"]
|
|
114
|
+
else rng.choice(list(OUTCOME_SET)))
|
|
115
|
+
evidence.append({"outcome_type": outcome})
|
|
116
|
+
|
|
117
|
+
verdicts = []
|
|
118
|
+
for i in range(n_claims):
|
|
119
|
+
verdicts.append({"exceeds_evidence_boundary": rng.random() > profile["scope_calibration"]})
|
|
120
|
+
|
|
121
|
+
discovered = []
|
|
122
|
+
if rng.random() < profile["contradiction"]:
|
|
123
|
+
discovered.append("null_result_or_negative_finding")
|
|
124
|
+
|
|
125
|
+
input_tokens = int(profile["context_tokens"] * (0.8 + 0.4 * rng.random()))
|
|
126
|
+
output_tokens = int(profile["output_tokens"] * (0.8 + 0.4 * rng.random()))
|
|
127
|
+
cost_usd = round(input_tokens / 1000 * INPUT_USD_PER_1K + output_tokens / 1000 * OUTPUT_USD_PER_1K, 5)
|
|
128
|
+
latency = round(profile["latency_s"] * (0.8 + 0.4 * rng.random()), 1)
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
"id": question["id"],
|
|
132
|
+
"level": level,
|
|
133
|
+
"baseline": baseline,
|
|
134
|
+
"claims": claims,
|
|
135
|
+
"citations": citations,
|
|
136
|
+
"evidence": evidence,
|
|
137
|
+
"verdicts": verdicts,
|
|
138
|
+
"discovered_contradictions": discovered,
|
|
139
|
+
"usage": {
|
|
140
|
+
"input_tokens": input_tokens,
|
|
141
|
+
"output_tokens": output_tokens,
|
|
142
|
+
"cost_usd": cost_usd,
|
|
143
|
+
"latency_s": latency,
|
|
144
|
+
},
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def run_baseline(questions: list[dict], baseline: str, annotations_dir: Path | None = None) -> dict[str, Any]:
|
|
149
|
+
"""Run one baseline over all questions; return per-question + aggregate metrics."""
|
|
150
|
+
per_question = []
|
|
151
|
+
metric_keys = ("citation_support_precision", "unsupported_claim_rate",
|
|
152
|
+
"contradiction_discovery_rate", "outcome_separation_accuracy", "scope_calibration")
|
|
153
|
+
totals = {k: 0.0 for k in metric_keys}
|
|
154
|
+
usage_totals = {"input_tokens": 0, "output_tokens": 0, "cost_usd": 0.0, "latency_s": 0.0}
|
|
155
|
+
n_with_annotation = 0
|
|
156
|
+
|
|
157
|
+
for q in questions:
|
|
158
|
+
result = simulate_question_result(q, baseline)
|
|
159
|
+
annotation = None
|
|
160
|
+
if annotations_dir is not None:
|
|
161
|
+
ann = annotations_dir / f"gold-{q['id']}.json"
|
|
162
|
+
if ann.exists():
|
|
163
|
+
annotation = json.loads(ann.read_text(encoding="utf-8"))
|
|
164
|
+
n_with_annotation += 1
|
|
165
|
+
metrics = evaluate(result, annotation)
|
|
166
|
+
usage = result["usage"]
|
|
167
|
+
per_question.append({"id": q["id"], "level": q["level"], "metrics": metrics, "usage": usage})
|
|
168
|
+
for k in metric_keys:
|
|
169
|
+
totals[k] += metrics.get(k, 0.0)
|
|
170
|
+
for k in usage_totals:
|
|
171
|
+
usage_totals[k] += usage[k]
|
|
172
|
+
|
|
173
|
+
n = len(questions)
|
|
174
|
+
aggregate = {k: round(v / n, 3) for k, v in totals.items()}
|
|
175
|
+
aggregate["usage"] = {k: round(v, 3) for k, v in usage_totals.items()}
|
|
176
|
+
aggregate["annotated_questions"] = n_with_annotation
|
|
177
|
+
return {"baseline": baseline, "aggregate": aggregate, "per_question": per_question}
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def run_ablation(question: dict, ablation: str) -> dict[str, Any]:
|
|
181
|
+
"""Deterministic ablation result: B3 minus one component (A-spec delta)."""
|
|
182
|
+
spec = ABLATION_SPECS[ablation]
|
|
183
|
+
base = simulate_question_result(question, "B3_eduevidence_single")
|
|
184
|
+
rng = _rand(f"{ablation}:{question['id']}")
|
|
185
|
+
|
|
186
|
+
citation = BASELINE_PROFILES["B3_eduevidence_single"]["citation_support"] + spec.get("citation_support", 0)
|
|
187
|
+
unsupported = BASELINE_PROFILES["B3_eduevidence_single"]["unsupported_rate"] + spec.get("unsupported_rate", 0)
|
|
188
|
+
contradiction = BASELINE_PROFILES["B3_eduevidence_single"]["contradiction"] + spec.get("contradiction", 0)
|
|
189
|
+
separation = BASELINE_PROFILES["B3_eduevidence_single"]["outcome_separation"] + spec.get("outcome_separation", 0)
|
|
190
|
+
scope = BASELINE_PROFILES["B3_eduevidence_single"]["scope_calibration"] + spec.get("scope_calibration", 0)
|
|
191
|
+
|
|
192
|
+
base["citations"] = [{"supports_claim": rng.random() < max(0, min(1, citation))} for _ in base["citations"]]
|
|
193
|
+
base["claims"] = [{"claim": c["claim"],
|
|
194
|
+
"status": "UNSUPPORTED" if rng.random() < max(0, min(1, unsupported)) else "SUPPORTED"}
|
|
195
|
+
for c in base["claims"]]
|
|
196
|
+
base["evidence"] = [{"outcome_type": e["outcome_type"]} for e in base["evidence"]]
|
|
197
|
+
if rng.random() >= contradiction:
|
|
198
|
+
base["discovered_contradictions"] = []
|
|
199
|
+
base["verdicts"] = [{"exceeds_evidence_boundary": rng.random() > max(0, min(1, scope))}
|
|
200
|
+
for _ in base["verdicts"]]
|
|
201
|
+
base["baseline"] = ablation
|
|
202
|
+
base["ablation"] = {"removes": spec["removes"]}
|
|
203
|
+
return base
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def build_report(baseline_results: dict[str, dict], ablation_results: dict[str, dict]) -> str:
|
|
207
|
+
"""Render the cost-vs-quality comparison report (markdown)."""
|
|
208
|
+
lines = ["# EduEvidence Benchmark v2 — Baseline & Ablation Report\n",
|
|
209
|
+
"## Baselines (B0-B4)\n",
|
|
210
|
+
"| Baseline | Citation Support | Unsupported Rate | Contradiction | Outcome Sep. | Scope Cal. | Input tok | Output tok | Cost (USD) | Latency (s) |",
|
|
211
|
+
"|---|---|---|---|---|---|---|---|---|---|"]
|
|
212
|
+
for baseline in BASELINES:
|
|
213
|
+
agg = baseline_results[baseline]["aggregate"]
|
|
214
|
+
u = agg["usage"]
|
|
215
|
+
lines.append(
|
|
216
|
+
f"| {baseline} | {agg['citation_support_precision']} | {agg['unsupported_claim_rate']} "
|
|
217
|
+
f"| {agg['contradiction_discovery_rate']} | {agg['outcome_separation_accuracy']} "
|
|
218
|
+
f"| {agg['scope_calibration']} | {u['input_tokens']:.0f} | {u['output_tokens']:.0f} "
|
|
219
|
+
f"| {u['cost_usd']:.4f} | {u['latency_s']:.0f} |")
|
|
220
|
+
|
|
221
|
+
b2 = baseline_results["B2_standard_agent"]["aggregate"]
|
|
222
|
+
b3 = baseline_results["B3_eduevidence_single"]["aggregate"]
|
|
223
|
+
b4 = baseline_results["B4_eduevidence_agent_mcp"]["aggregate"]
|
|
224
|
+
methodology_value = round(b3["citation_support_precision"] - b2["citation_support_precision"], 3)
|
|
225
|
+
agent_value = round(b4["citation_support_precision"] - b3["citation_support_precision"], 3)
|
|
226
|
+
cost_delta = round(b4["usage"]["cost_usd"] - b3["usage"]["cost_usd"], 4)
|
|
227
|
+
|
|
228
|
+
lines += [
|
|
229
|
+
"",
|
|
230
|
+
"## Key comparisons\n",
|
|
231
|
+
f"- **B2 vs B3(教育方法论价值)**: citation support +{methodology_value}, "
|
|
232
|
+
f"unsupported claim {b3['unsupported_claim_rate']} vs {b2['unsupported_claim_rate']}",
|
|
233
|
+
f"- **B3 vs B4(多 Agent 增强价值)**: citation support +{agent_value}, "
|
|
234
|
+
f"contradiction discovery {b4['contradiction_discovery_rate']} vs {b3['contradiction_discovery_rate']}",
|
|
235
|
+
f"- **B4 成本增量**: +{cost_delta:.4f} USD per question(是否值得取决于质量需求)",
|
|
236
|
+
"",
|
|
237
|
+
"## Ablation (A1-A7, relative to B3)\n",
|
|
238
|
+
"| Ablation | Removes | Citation Support | Unsupported Rate | Contradiction | Scope Cal. |",
|
|
239
|
+
"|---|---|---|---|---|---|",
|
|
240
|
+
]
|
|
241
|
+
for ablation, results in ablation_results.items():
|
|
242
|
+
spec = ABLATION_SPECS[ablation]
|
|
243
|
+
# aggregate ablation metrics across all questions
|
|
244
|
+
n = len(results)
|
|
245
|
+
citation = sum(evaluate(r, None)["citation_support_precision"] for r in results) / n
|
|
246
|
+
unsupported = sum(evaluate(r, None)["unsupported_claim_rate"] for r in results) / n
|
|
247
|
+
# contradiction discovery needs an annotation; use the simulated signal key
|
|
248
|
+
stub_annotation = {"known_contradictions": ["null_result_or_negative_finding"]}
|
|
249
|
+
contradiction = sum(metric_contradiction_discovery(r, stub_annotation) for r in results) / n
|
|
250
|
+
scope = sum(evaluate(r, None)["scope_calibration"] for r in results) / n
|
|
251
|
+
lines.append(
|
|
252
|
+
f"| {ablation} | {spec['removes']} | {citation:.3f} | {unsupported:.3f} "
|
|
253
|
+
f"| {contradiction:.3f} | {scope:.3f} |")
|
|
254
|
+
lines += [
|
|
255
|
+
"",
|
|
256
|
+
"> 说明:结果为确定性模拟(seeded),用于框架验证与相对比较;真实 LLM 运行可替换同一 schema。",
|
|
257
|
+
]
|
|
258
|
+
return "\n".join(lines) + "\n"
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def main() -> int:
|
|
262
|
+
parser = argparse.ArgumentParser(description="EduEvidence Benchmark v2 (B0-B4 + Ablation)")
|
|
263
|
+
parser.add_argument("--questions", required=True, help="benchmarks/questions.jsonl")
|
|
264
|
+
parser.add_argument("--annotations", default=None, help="benchmarks/annotations (optional)")
|
|
265
|
+
parser.add_argument("--out", default="benchmarks/results/v2-summary.json")
|
|
266
|
+
parser.add_argument("--report", default="benchmarks/results/v2-report.md")
|
|
267
|
+
args = parser.parse_args()
|
|
268
|
+
|
|
269
|
+
questions = load_questions(Path(args.questions))
|
|
270
|
+
issues = validate_questions(questions)
|
|
271
|
+
if issues:
|
|
272
|
+
for issue in issues:
|
|
273
|
+
print(f"ISSUE: {issue}", file=sys.stderr)
|
|
274
|
+
return 1
|
|
275
|
+
|
|
276
|
+
annotations_dir = Path(args.annotations) if args.annotations else None
|
|
277
|
+
baseline_results: dict[str, dict] = {}
|
|
278
|
+
ablation_results: dict[str, list] = {a: [] for a in ABLATION_SPECS}
|
|
279
|
+
for baseline in BASELINES:
|
|
280
|
+
baseline_results[baseline] = run_baseline(questions, baseline, annotations_dir)
|
|
281
|
+
for ablation in ABLATION_SPECS:
|
|
282
|
+
ablation_results[ablation] = [run_ablation(q, ablation) for q in questions]
|
|
283
|
+
|
|
284
|
+
summary = {
|
|
285
|
+
"mode": "deterministic_simulation",
|
|
286
|
+
"questions": len(questions),
|
|
287
|
+
"baselines": {b: r["aggregate"] for b, r in baseline_results.items()},
|
|
288
|
+
"ablations": {a: len(r) for a, r in ablation_results.items()},
|
|
289
|
+
}
|
|
290
|
+
out_path = Path(args.out)
|
|
291
|
+
out_path.parent.mkdir(parents=True, exist_ok=True)
|
|
292
|
+
out_path.write_text(json.dumps(summary, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
293
|
+
|
|
294
|
+
report = build_report(baseline_results, ablation_results)
|
|
295
|
+
Path(args.report).write_text(report, encoding="utf-8")
|
|
296
|
+
print(f"wrote {args.out}")
|
|
297
|
+
print(f"wrote {args.report}")
|
|
298
|
+
print(report[:600])
|
|
299
|
+
return 0
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
if __name__ == "__main__":
|
|
303
|
+
import sys
|
|
304
|
+
sys.exit(main())
|