Phase 1 & 2: Baseline experiments + AGoT implementation + reasoning graph analysis

## Added

### Core framework
- src/llm_client.py — Ollama API wrapper for local Docker inference
- src/samples.py — Embedded benchmark datasets (GSM8K/MATH/AIME + Chinese)
- src/run_all.py — Unified experiment runner

### Phase 1: Baselines
- src/baseline/benchmark.py — IO, CoT, CoT-SC, ToT evaluation with Chinese support

### Phase 2: AGoT
- src/agot/agot.py — AGoT core algorithm (6 agent types, recursive decomposition)
- src/agot/graph_utils.py — DAG graph data structure with cycle detection
- src/agot/prompts.py — 6 agent prompt templates (EN + ZH)
- src/agot/run.py — AGoT experiment runner

### Graph Analysis
- src/graph_analysis/reasoning_graph.py — Graph property computation (cyclicity, diameter, small-world)
- src/graph_analysis/visualize.py — Visualization charts

### Documentation
- docs/graph_reasoning_principles.md — Comprehensive principles document
- docs/next_steps.md — Roadmap for reliable reasoning tool

### Experiment Results
- GSM8K/MATH baselines on qwen2.5:32b and qwq:latest
- AGoT validation (100% on small sample)
- Chinese dataset benchmarks (C-GSM8K, CMATH)
- Graph property analysis confirming Topology of Reasoning findings
This commit is contained in:
cat
2026-07-03 22:23:42 +08:00
parent aa8ba6a6d7
commit d84f98799b
37 changed files with 4880 additions and 0 deletions
@@ -0,0 +1,40 @@
{
"summary": {
"method": "CoT",
"model": "qwen2.5:32b",
"task": "cmath",
"samples": 3,
"correct": 2,
"accuracy": 0.6667,
"avg_time_s": 41.49
},
"details": [
{
"question": "已知函数 $f(x) = 2x^2 - 4x + 1$,求 $f(x)$ 的最小值。",
"expected": "-1",
"predicted": "-1",
"full_response": "要找到二次函数 $f(x) = 2x^2 - 4x + 1$ 的最小值,我们可以使用顶点公式或完成平方的方法。这里我们采用完成平方的方法来解决这个问题。\n\n首先,将给定的函数写为:\n\\[ f(x) = 2x^2 - 4x + 1 \\]\n\n为了完成平方,我们需要关注 $2x^2 - 4x$ 这一部分。由于系数不是1,我们可以先提取公因子2:\n\\[ f(x) = 2(x^2 - 2x) + 1 \\]\n\n接下来,我们对括号内的表达式进行补全平方。为了完成这个过程,我们需要找到一个数,使得 $x^2 - 2x$ 加上这个数后成为一个完全平方形式。我们知道,对于形如 $ax^2 + bx$ 的表达式,要使其成为完全平方,需要加上 $(\\frac{b}{2})^2$。\n\n因此,在这里我们有:\n\\[ x^2 - 2x \\]\n为了补全平方,我们需要加上的数是 $(\\frac{-2}{2})^2 = (-1)^2 = 1$。但是因为我们是从 $f(x)$ 中提取了因子2,所以实际上我们在括号内加上1后需要同时减去它以保持等式的平衡:\n\\[ f(x) = 2(x^2 - 2x + 1 - 1) + 1 \\]\n\\[ f(x) = 2((x-1)^2 - 1) + 1 \\]\n\n现在,我们可以重新整理这个表达式:\n\\[ f(x) = 2(x-1)^2 - 2 + 1 \\]\n\\[ f(x) = 2(x-1)^2 - 1 \\]\n\n由于 $(x-1)^2$ 的最小值为0(当 $x=1$ 时),因此整个表达式的最小值发生在 $(x-1)^2 = 0$,即:\n\\[ f_{\\text{min}}(x) = 2*0 - 1 = -1 \\]\n\n所以,函数 $f(x)$ 的最小值是 $\\boxed{-1}$。",
"correct": true,
"time_s": 49.05,
"tokens": 249
},
{
"question": "在等差数列 $\\{a_n\\}$ 中,$a_1 = 3$$a_3 + a_5 = 22$,求 $a_7$ 的值。",
"expected": "25",
"predicted": "19",
"full_response": "首先,我们知道等差数列的通项公式为:\n\\[a_n = a_1 + (n-1)d\\]\n其中,$d$ 是公差。根据题目给出的信息:\n\n1. 第一项 $a_1 = 3$。\n2. 第三项和第五项之和等于22,即 $a_3 + a_5 = 22$。\n\n我们可以用通项公式来表示 $a_3$ 和 $a_5$\n\\[a_3 = a_1 + 2d\\]\n\\[a_5 = a_1 + 4d\\]\n\n将已知的 $a_1 = 3$ 值代入上述两个等式中,得到:\n\\[a_3 = 3 + 2d\\]\n\\[a_5 = 3 + 4d\\]\n\n根据题目条件 $a_3 + a_5 = 22$,我们可以将上面的表达式相加:\n\\[3 + 2d + 3 + 4d = 22\\]\n简化得到:\n\\[6 + 6d = 22\\]\n解这个方程找到 $d$ 的值:\n\\[6d = 16\\]\n\\[d = \\frac{16}{6} = \\frac{8}{3}\\]\n\n现在我们知道了公差 $d = \\frac{8}{3}$,可以求出第七项 $a_7$\n\\[a_7 = a_1 + (7-1)d = 3 + 6\\left(\\frac{8}{3}\\right) = 3 + 2(8) = 3 + 16 = 19\\]\n\n因此,$a_7$ 的值是 $\\boxed{19}$。",
"correct": false,
"time_s": 39.68,
"tokens": 185
},
{
"question": "从 3 名男生和 2 名女生中选出 2 人参加志愿者活动,求选出的两人恰好是一男一女的概率。",
"expected": "3/5",
"predicted": "\\frac{3}{5}",
"full_response": "要解决这个问题,我们可以分步骤来计算:\n\n1. **总的选择方式**:\n - 总共有5个人(3名男生 + 2名女生),从中选择2人的组合数为 \\(C(5, 2)\\)。\n - 计算 \\(C(5, 2) = \\frac{5!}{2!(5-2)!} = \\frac{5 \\times 4}{2 \\times 1} = 10\\)。\n\n2. **一男一女的选择方式**:\n - 从3名男生中选择1人的组合数为 \\(C(3, 1)\\)。\n - 计算 \\(C(3, 1) = \\frac{3!}{1!(3-1)!} = \\frac{3}{1} = 3\\)。\n - 从2名女生中选择1人的组合数为 \\(C(2, 1)\\)。\n - 计算 \\(C(2, 1) = \\frac{2!}{1!(2-1)!} = \\frac{2}{1} = 2\\)。\n - 因此,一男一女的总选择方式为 \\(3 \\times 2 = 6\\)。\n\n3. **计算概率**:\n - 概率是满足条件的选择数除以总的可能选择数。\n - 所求的概率为 \\(\\frac{6}{10} = \\frac{3}{5}\\)。\n\n所以,选出的两人恰好是一男一女的概率是 \\(\\boxed{\\frac{3}{5}}\\)。",
"correct": true,
"time_s": 35.74,
"tokens": 182
}
]
}