From 800bfdebfd5f724ff0b3efd8ef190720cf92030a Mon Sep 17 00:00:00 2001 From: x Date: Thu, 3 Dec 2026 22:06:38 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=B7=A5=E4=BD=9C=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E5=BD=92=E6=A1=A3=E6=95=B4=E7=90=86=EF=BC=8C=E4=BB=A3=E7=A0=81?= =?UTF-8?q?/=E6=96=87=E6=A1=A3/=E9=85=8D=E7=BD=AE/=E4=BA=A7=E7=89=A9?= =?UTF-8?q?=E5=88=86=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - docs/:所有文档集中(需求、路线、架构提案、FINDINGS),从 mm/ 与 spatial/ 移出 - spatial/configs/:只留 4 个规范配置,7 个历史实验配置进 archive/, 并写明每个留下它的理由 - tools/:pdl.sh 等与模型无关的小工具 - archive/figures/:旧实验图(不入库) - mm/ 保持平铺并加 README 说明分组:脚本以 mm/ 为工作目录互相 import model, 移动目录会打断相对导入,收益不值这个风险 - 清掉 __pycache__,.gitignore 补 archive/figures、*.bundle、out_spatial/ --- .gitignore | 44 ++++++++++--------- README.md | 43 +++++++++++++----- {spatial => docs}/FINDINGS.md | 0 {mm => docs}/PLAN_v2.md | 0 {mm => docs}/REQUIREMENTS.md | 0 {mm => docs}/SPATIAL_FOUNDATION.md | 0 mm/README.md | 19 ++++++++ spatial/__init__.py | 22 +++++----- spatial/configs/README.md | 27 ++++++++++++ spatial/configs/{ => archive}/abstain.json | 0 spatial/configs/{ => archive}/cross.json | 0 spatial/configs/{ => archive}/dang_b.json | 0 spatial/configs/{ => archive}/dang_c.json | 0 spatial/configs/{ => archive}/dang_d.json | 0 .../configs/{ => archive}/dangling_long.json | 0 spatial/configs/{ => archive}/floor.json | 0 pdl.sh => tools/pdl.sh | 0 17 files changed, 112 insertions(+), 43 deletions(-) rename {spatial => docs}/FINDINGS.md (100%) rename {mm => docs}/PLAN_v2.md (100%) rename {mm => docs}/REQUIREMENTS.md (100%) rename {mm => docs}/SPATIAL_FOUNDATION.md (100%) create mode 100644 mm/README.md create mode 100644 spatial/configs/README.md rename spatial/configs/{ => archive}/abstain.json (100%) rename spatial/configs/{ => archive}/cross.json (100%) rename spatial/configs/{ => archive}/dang_b.json (100%) rename spatial/configs/{ => archive}/dang_c.json (100%) rename spatial/configs/{ => archive}/dang_d.json (100%) rename spatial/configs/{ => archive}/dangling_long.json (100%) rename spatial/configs/{ => archive}/floor.json (100%) rename pdl.sh => tools/pdl.sh (100%) diff --git a/.gitignore b/.gitignore index 9450231..1dcd112 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,24 @@ -.venv/ -nanoGPT/ -ckpt/ -data/ -data_*/ -out_*/ -__pycache__/ -*.pyc -*.pyo -*.pt -*.bin -*.npy -*.log -*.tar -*.zip -*.gguf -*.egg-info/ -.workbuddy-ai/ -vqcheck/ -.DS_Store +.venv/ +nanoGPT/ +ckpt/ +data/ +data_*/ +out_*/ +__pycache__/ +*.pyc +*.pyo +*.pt +*.bin +*.npy +*.log +*.tar +*.zip +*.gguf +*.egg-info/ +.workbuddy-ai/ +vqcheck/ +.DS_Store +archive/figures/ +*.bundle +*.tar.bz2 +out_spatial/ diff --git a/README.md b/README.md index 10cf558..0aa5e93 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,42 @@ # tiny-gpt -小模型的多模态与可控生成实验,代码在 `mm/`。当前空间结构底座的设计与实施路线见[架构提案](mm/SPATIAL_FOUNDATION.md),已有实验及 v3 决策见[需求记录](mm/REQUIREMENTS.md)。 +小模型的空间结构与多模态实验。当前主线是 `spatial/`:一个不带因果掩码的关系主干, +回答"这件事能不能被观测证明",证不了就说不知道。 ## 目录 -| 路径 | 内容 | +| 路径 | 内容 | 状态 | +|---|---|---| +| `spatial/` | 关系主干、数据契约、生成器、检查器、训练与诊断工具 | **当前主线** | +| `spatial/configs/` | 运行配置,规范配置在顶层,历史实验在 `archive/` | | +| `docs/` | 全部文档:需求、路线、架构提案、测出来的结果 | | +| `mm/` | 前一条线:45M 原生多模态 GPT,补全/可控生成实验 | 暂停,代码与探针保留 | +| `vendor/llamagen_vq/` | VQ 编解码(第三方) | 依赖 | +| `tools/` | 与模型无关的小工具 | | +| `archive/` | 旧实验产物(图、对比图),不入库 | | + +## 文档 + +| 文件 | 内容 | |---|---| -| `mm/` | 训练、数据构建、评测探针 | -| `vendor/llamagen_vq/` | VQ 编解码(第三方,56K) | -| `pdl.sh` | 分片下载辅助 | - -## 不入库 - -`.venv/` `ckpt/` `data_*/` `out_*/` `nanoGPT/` —— 环境、权重、数据集、训练输出。 +| [docs/FINDINGS.md](docs/FINDINGS.md) | **先读这个**:M1 全部测量结果、八处修复的单变量证据、三种子水位 | +| [docs/SPATIAL_FOUNDATION.md](docs/SPATIAL_FOUNDATION.md) | 架构提案与分阶段路线 | +| [docs/REQUIREMENTS.md](docs/REQUIREMENTS.md) | 需求与架构决策 v3 | +| [docs/PLAN_v2.md](docs/PLAN_v2.md) | 上一版路线(已被上面两份取代,留作对照) | ## 常用 ```bash -cd mm -git log --oneline -/home/lhj/projects/tiny-gpt/.venv/bin/python train.py --help +python3 -m spatial.cli smoke # 契约测试,必须先过 +python3 -m spatial.baselines 128 # 平凡规则基线 +python3 -m spatial.cli train --config spatial/configs/dangling.json --seed 0 +python3 -m spatial.cli report --config spatial/configs/dangling.json --seed 0 --n 128 +python3 -m spatial.cli report --config spatial/configs/dangling.json --n 128 --ablate dangling,scene ``` + +结论一条:单次运行不构成证据,任何数字都要三种子(`--seed 0 1 2`)读。 + +## 不入库 + +`.venv/`、`ckpt/`、`data_*/`、`out_*/`、`archive/figures/`、`__pycache__/`。 +训练输出在服务器 `~/projects/tiny-gpt/out_spatial/`,只保留规范配置的三种子。 diff --git a/spatial/FINDINGS.md b/docs/FINDINGS.md similarity index 100% rename from spatial/FINDINGS.md rename to docs/FINDINGS.md diff --git a/mm/PLAN_v2.md b/docs/PLAN_v2.md similarity index 100% rename from mm/PLAN_v2.md rename to docs/PLAN_v2.md diff --git a/mm/REQUIREMENTS.md b/docs/REQUIREMENTS.md similarity index 100% rename from mm/REQUIREMENTS.md rename to docs/REQUIREMENTS.md diff --git a/mm/SPATIAL_FOUNDATION.md b/docs/SPATIAL_FOUNDATION.md similarity index 100% rename from mm/SPATIAL_FOUNDATION.md rename to docs/SPATIAL_FOUNDATION.md diff --git a/mm/README.md b/mm/README.md new file mode 100644 index 0000000..3b0a63d --- /dev/null +++ b/mm/README.md @@ -0,0 +1,19 @@ +# mm —— 45M 原生多模态 GPT(暂停的一条线) + +文本 BPE 与图像 VQ 码共享一个词表和 softmax,多流残差、GQA、bigram 哈希表、Muon。 +这一条线得出的结论(可用标注质量门槛、样本/属性值是学习瓶颈、验证损失与学习反相关) +仍然成立,但路线已被 `docs/SPATIAL_FOUNDATION.md` 取代,代码保留以便复现。 + +文件按前缀分组,**保持平铺**:这些脚本以 `mm/` 为工作目录互相 `import model`, +移动目录会打断相对导入,收益不值这个风险。 + +| 前缀 | 内容 | +|---|---| +| `model.py` `train.py` `muon.py` `smoke.py` | 主干:模型、训练循环、优化器、冒烟 | +| `build_*` `split.py` `recaption.py` `caption_all.py` `retok_*` | 数据构建与重标注(strata 批量改写 caption) | +| `probe_*` `*_eval.py` `stream_probe.py` `chk.py` `modecheck.py` `vqres.py` `test_vq.py` | 行为探针:反事实换词、交叉积、位置分桶、流耦合 | +| `train_report.py` | 四层体检一次出(规模/曲线/留存/TV/行为/结论) | +| `bench_strata.py` `compare_gen.py` `curve.py` `distcheck.py` `sample.py` `generate.py` | 基准、采样与画图 | +| `run_arm?*.sh` | 实验编排(A–F 六组) | + +文档已移出到 `docs/`。 diff --git a/spatial/__init__.py b/spatial/__init__.py index add4f93..6a444d6 100644 --- a/spatial/__init__.py +++ b/spatial/__init__.py @@ -1,11 +1,11 @@ -"""Spatial-structure foundation. - -A slice of the plan in ``mm/SPATIAL_FOUNDATION.md``: one observation contract, -one procedural generator, one reference checker, one bidirectional backbone, -and a CLI that can smoke / train / resume / eval. - -M0 is CPU-only on purpose -- the point is that the labels are provably right -before any GPU time is spent learning them. -""" - -__all__ = ["schema", "generator", "checker", "model", "train", "cli"] +"""Spatial-structure foundation. + +A slice of the plan in ``docs/SPATIAL_FOUNDATION.md``: one observation contract, +one procedural generator, one reference checker, one bidirectional backbone, +and a CLI that can smoke / train / resume / eval. + +M0 is CPU-only on purpose -- the point is that the labels are provably right +before any GPU time is spent learning them. +""" + +__all__ = ["schema", "generator", "checker", "model", "train", "cli"] diff --git a/spatial/configs/README.md b/spatial/configs/README.md new file mode 100644 index 0000000..ae83c67 --- /dev/null +++ b/spatial/configs/README.md @@ -0,0 +1,27 @@ +# 运行配置 + +`out_dir` 相对仓库根,输出落在 `out_spatial/<名字>/`。`--seed N` 会追加 `_sN`。 + +## 规范配置 + +| 文件 | 用途 | 结果 | +|---|---|---| +| `smoke.json` | 契约测试(`cli smoke` 的默认值),2 步即可 | 必须 PASS | +| `dangling.json` | **主实验**:13 训练族 / 2 测试族,4800 步,lr 3e-3,warmup 300 | 三种子 14 族全部 1.000 | +| `setonly.json` | 只训 `dof.set`,隔离"六个轴是否全覆盖"这个子技能 | 1.000(用于定位读出缺陷) | +| `cross_oneshot.json` | 对照:第一版混合集,被一位规则完全可分 | 6 族与平凡规则逐位相同 | + +## 归档(`archive/`) + +| 文件 | 当时的用途 | 留下它的理由 | +|---|---|---| +| `floor.json` | 单族 `cond.p3` 400 步基线 | 最早的"看起来满分"样本,后被证伪 | +| `cross.json` | 首次跨族,7 族 | 一位规则可分的证据 | +| `abstain.json` | 弃权是否跨域(connection+freedom 监督,测 stability) | 当时 abst 0.000,定位到标签语义问题 | +| `dang_b.json` | lr 1.5e-3 / warmup 300 / 4800 步 | 证明降 lr 救不回 dof.set(0.328) | +| `dang_c.json` | lr 3e-3 / warmup 300 / 4800 步 | 与 `dangling.json` 等价,是 warmup 对照组的原件 | +| `dang_d.json` | lr 1.5e-3 / warmup 300 / 7200 步 | 证明加步数不是必需(1.000) | +| `dangling_long.json` | 4800→等价于主配置加长版 | 双倍步数曾修掉 seed2 的坏结果 | + +四组 warmup 对照的结论在 [docs/FINDINGS.md](../../docs/FINDINGS.md) 第二节第 8 条: +根因是预热长度,不是学习率也不是步数。 diff --git a/spatial/configs/abstain.json b/spatial/configs/archive/abstain.json similarity index 100% rename from spatial/configs/abstain.json rename to spatial/configs/archive/abstain.json diff --git a/spatial/configs/cross.json b/spatial/configs/archive/cross.json similarity index 100% rename from spatial/configs/cross.json rename to spatial/configs/archive/cross.json diff --git a/spatial/configs/dang_b.json b/spatial/configs/archive/dang_b.json similarity index 100% rename from spatial/configs/dang_b.json rename to spatial/configs/archive/dang_b.json diff --git a/spatial/configs/dang_c.json b/spatial/configs/archive/dang_c.json similarity index 100% rename from spatial/configs/dang_c.json rename to spatial/configs/archive/dang_c.json diff --git a/spatial/configs/dang_d.json b/spatial/configs/archive/dang_d.json similarity index 100% rename from spatial/configs/dang_d.json rename to spatial/configs/archive/dang_d.json diff --git a/spatial/configs/dangling_long.json b/spatial/configs/archive/dangling_long.json similarity index 100% rename from spatial/configs/dangling_long.json rename to spatial/configs/archive/dangling_long.json diff --git a/spatial/configs/floor.json b/spatial/configs/archive/floor.json similarity index 100% rename from spatial/configs/floor.json rename to spatial/configs/archive/floor.json diff --git a/pdl.sh b/tools/pdl.sh similarity index 100% rename from pdl.sh rename to tools/pdl.sh