Compare commits

..

10 Commits

Author SHA1 Message Date
Jonathan Hill e4bfdf051e
Merge 182bff1bd8 into 6fc918beb6 2026-09-04 23:34:48 -07:00
jingyaogong 6fc918beb6 [update] remove expert args 2026-09-04 22:16:38 +08:00
jingyaogong 4bd6062ead
Merge pull request #836 from JustinGuese/moe-cli-flags
Expose num_experts / num_experts_per_tok / seed on the trainer CLIs
2026-09-04 22:10:18 +08:00
jingyaogong 4d7a74acab
Merge pull request #840 from JustinGuese/readme-benchmark-resolution
docs: state the measurement resolution of the objective benchmark table
2026-09-04 22:10:00 +08:00
Justin Guese 77946fda00 [docs] 在客观评测表下补充各数据集的测量分辨率
lm_eval 对每个指标都会输出 stderr,但表格只保留了点估计。这里按测试集
大小给出各任务的 ± 标准误(obqa ±1.9 到 cmmlu ±0.4),并说明比较两个
模型时差值的标准误约为单项的 √2 倍,方便读者判断表中哪些差距是可以
解读的。中英文 README 同步。
2026-09-03 17:10:52 +07:00
Justin Guese fc585a9bf9 [update] 把随机种子暴露到命令行
trainer 里的种子此前硬编码为 42(setup_seed(42 + rank) 与每轮的
setup_seed(42 + epoch)),要跑多种子实验只能改源码。新增 --seed,
默认 42,与改动前完全一致。
2026-09-03 15:36:14 +07:00
Justin Guese c3199c7240 [update] 把 num_experts / num_experts_per_tok 暴露到命令行
此前要改专家数只能去编辑 model_minimind.py。三个入口
(train_pretrain / train_full_sft / eval_llm)的默认值与 MiniMindConfig
一致(4 / 1),默认行为不变;RL 与 agent 相关的 trainer 不动。
2026-09-03 15:13:29 +07:00
jingyaogong 7a6fddd63a [update] readme 2026-08-31 18:08:05 +08:00
jingyaogong c9a8ab4632 [update] dependency version 2026-08-31 17:54:37 +08:00
jingyaogong e84156818a [update] dependency version 2026-08-29 15:12:28 +08:00
5 changed files with 35 additions and 9 deletions

View File

@ -1599,6 +1599,15 @@ MiniMind 的数据规模远小于表中其他模型,且训练比例偏向中
| [SmolLM2-135M](https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct) | HuggingFace | 135M | 24.44 / 24.71 | 58.50 / 68.17 / 32.80 / 43.15 / 39.46 | | [SmolLM2-135M](https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct) | HuggingFace | 135M | 24.44 / 24.71 | 58.50 / 68.17 / 32.80 / 43.15 / 39.46 |
| [Aquila-135M](https://huggingface.co/BAAI/Aquila-135M-Instruct) | BAAI | 135M | 25.19 / 25.10 | 54.59 / 67.52 / 34.40 / 41.67 / 39.66 | | [Aquila-135M](https://huggingface.co/BAAI/Aquila-135M-Instruct) | BAAI | 135M | 25.19 / 25.10 | 54.59 / 67.52 / 34.40 / 41.67 / 39.66 |
> **这张表的分辨率**:`lm_eval` 对每个指标都会同时输出一个 `stderr`,它主要由测试集大小决定,因此下面的数值对表中所有模型都近似适用(随准确率略有浮动):
>
> | 数据集 | obqa | ceval | piqa | siqa | arc | hellaswag | cmmlu |
> |---|---|---|---|---|---|---|---|
> | 样本量 | 500 | ~1.3k | 1838 | 1954 | 2376 | 10042 | 11582 |
> | ± 标准误 | **1.9** | 1.2 | 1.2 | 1.1 | 0.9 | 0.5 | **0.4** |
>
> 比较两个模型时,差值的标准误约为单项的 `√2` 倍。因此 obqa 上小于约 5 个百分点、ceval / piqa / siqa 上小于约 3 个百分点的差异,都不足以区分两个模型——这也解释了为什么本表中同一量级的模型排序不宜过度解读。
<details> <details>
<summary><strong>补充说明(来源/无污染/复现)</strong></summary> <summary><strong>补充说明(来源/无污染/复现)</strong></summary>
@ -1909,6 +1918,8 @@ python llmexport.py --path /path/to/模型路径/ --export mnn --hqq --dst_path
* [@Nijikadesu](https://github.com/Nijikadesu):[🔗以交互笔记本方式分解项目代码](https://github.com/jingyaogong/minimind/issues/213) * [@Nijikadesu](https://github.com/Nijikadesu):[🔗以交互笔记本方式分解项目代码](https://github.com/jingyaogong/minimind/issues/213)
* [@jaylearnstocode](https://github.com/jaylearnstocode):[🔗模型结构、注意力机制与训练流程可视化](https://llm-visualization-minimind.vercel.app/)
致谢以下优秀的论文与项目: 致谢以下优秀的论文与项目:

View File

@ -1597,6 +1597,15 @@ MiniMind is trained on far less data than the other models listed here, and its
| [SmolLM2-135M](https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct) | HuggingFace | 135M | 24.44 / 24.71 | 58.50 / 68.17 / 32.80 / 43.15 / 39.46 | | [SmolLM2-135M](https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct) | HuggingFace | 135M | 24.44 / 24.71 | 58.50 / 68.17 / 32.80 / 43.15 / 39.46 |
| [Aquila-135M](https://huggingface.co/BAAI/Aquila-135M-Instruct) | BAAI | 135M | 25.19 / 25.10 | 54.59 / 67.52 / 34.40 / 41.67 / 39.66 | | [Aquila-135M](https://huggingface.co/BAAI/Aquila-135M-Instruct) | BAAI | 135M | 25.19 / 25.10 | 54.59 / 67.52 / 34.40 / 41.67 / 39.66 |
> **The resolution of this table**: `lm_eval` reports a `stderr` alongside every metric. It is set mainly by the size of the test set, so the values below apply approximately to every model in the table (they shift slightly with accuracy):
>
> | dataset | obqa | ceval | piqa | siqa | arc | hellaswag | cmmlu |
> |---|---|---|---|---|---|---|---|
> | samples | 500 | ~1.3k | 1838 | 1954 | 2376 | 10042 | 11582 |
> | ± stderr | **1.9** | 1.2 | 1.2 | 1.1 | 0.9 | 0.5 | **0.4** |
>
> When comparing two models, the standard error of the difference is about `√2` times the single-model value. So a gap smaller than roughly 5 points on obqa, or roughly 3 points on ceval / piqa / siqa, does not separate two models — which is why the ordering of similarly-sized models in this table should not be over-read.
<details> <details>
<summary><strong>Additional note (source / no contamination / reproduction)</strong></summary> <summary><strong>Additional note (source / no contamination / reproduction)</strong></summary>
@ -1909,6 +1918,8 @@ Thanks to the following contributors for sharing training notes, data processing
* [@Nijikadesu](https://github.com/Nijikadesu): [🔗Breaking Down Project Code in Interactive Notebook Format](https://github.com/jingyaogong/minimind/issues/213) * [@Nijikadesu](https://github.com/Nijikadesu): [🔗Breaking Down Project Code in Interactive Notebook Format](https://github.com/jingyaogong/minimind/issues/213)
* [@jaylearnstocode](https://github.com/jaylearnstocode): [🔗Visualization of Model Architecture, Attention Mechanisms, and Training Pipelines](https://llm-visualization-minimind.vercel.app/)
Thanks also to the following papers and projects: Thanks also to the following papers and projects:

View File

@ -5,17 +5,17 @@ Flask_Cors==4.0.0
jieba==0.42.1 jieba==0.42.1
jsonlines==4.0.0 jsonlines==4.0.0
marshmallow==3.22.0 marshmallow==3.22.0
# matplotlib==3.10.0
ngrok==1.4.0 ngrok==1.4.0
nltk==3.8 nltk==3.8
numpy==1.26.4 numpy==1.26.4
openai==1.59.6 openai==1.59.6
# peft==0.7.1
psutil==5.9.8 psutil==5.9.8
protobuf==6.33.5
pydantic==2.11.5 pydantic==2.11.5
rich==13.7.1 rich==13.7.1
scikit_learn==1.5.1 scikit_learn==1.5.1
sentence_transformers==2.3.1 sentence_transformers==2.3.1
sentencepiece==0.2.0
simhash==2.1.2 simhash==2.1.2
tiktoken==0.10.0 tiktoken==0.10.0
transformers==4.57.6 transformers==4.57.6
@ -23,10 +23,12 @@ jinja2==3.1.2
jsonlines==4.0.0 jsonlines==4.0.0
trl==0.13.0 trl==0.13.0
ujson==5.1.0 ujson==5.1.0
wandb==0.18.3 wandb==0.22.3
streamlit==1.50.0 streamlit==1.50.0
einops==0.8.1 einops==0.8.1
swanlab==0.7.11 swanlab==0.9.8
modelscope==1.37.0 modelscope==1.37.0
# torch==2.6.0 # torch==2.6.0
# torchvision==0.21.0 # torchvision==0.21.0
# peft==0.7.1
# matplotlib==3.10.0

View File

@ -99,6 +99,7 @@ if __name__ == "__main__":
parser.add_argument('--num_hidden_layers', default=8, type=int, help="隐藏层数量") parser.add_argument('--num_hidden_layers', default=8, type=int, help="隐藏层数量")
parser.add_argument('--max_seq_len', default=768, type=int, help="训练的最大截断长度(中文1token≈1.5~1.7字符)") parser.add_argument('--max_seq_len', default=768, type=int, help="训练的最大截断长度(中文1token≈1.5~1.7字符)")
parser.add_argument('--use_moe', default=0, type=int, choices=[0, 1], help="是否使用MoE架构(0=否,1=是)") parser.add_argument('--use_moe', default=0, type=int, choices=[0, 1], help="是否使用MoE架构(0=否,1=是)")
parser.add_argument('--seed', default=42, type=int, help="随机种子(DDP下每个rank为seed+rank,每轮为seed+epoch)")
parser.add_argument("--data_path", type=str, default="../dataset/sft_t2t_mini.jsonl", help="训练数据路径") parser.add_argument("--data_path", type=str, default="../dataset/sft_t2t_mini.jsonl", help="训练数据路径")
parser.add_argument('--from_weight', default='pretrain', type=str, help="基于哪个权重训练,为none则不基于任何权重训练") parser.add_argument('--from_weight', default='pretrain', type=str, help="基于哪个权重训练,为none则不基于任何权重训练")
parser.add_argument('--from_resume', default=0, type=int, choices=[0, 1], help="是否自动检测&续训(0=否,1=是)") parser.add_argument('--from_resume', default=0, type=int, choices=[0, 1], help="是否自动检测&续训(0=否,1=是)")
@ -110,7 +111,7 @@ if __name__ == "__main__":
# ========== 1. 初始化环境和随机种子 ========== # ========== 1. 初始化环境和随机种子 ==========
local_rank = init_distributed_mode() local_rank = init_distributed_mode()
if dist.is_initialized(): args.device = f"cuda:{local_rank}" if dist.is_initialized(): args.device = f"cuda:{local_rank}"
setup_seed(42 + (dist.get_rank() if dist.is_initialized() else 0)) setup_seed(args.seed + (dist.get_rank() if dist.is_initialized() else 0))
# ========== 2. 配置目录、模型参数、检查ckp ========== # ========== 2. 配置目录、模型参数、检查ckp ==========
os.makedirs(args.save_dir, exist_ok=True) os.makedirs(args.save_dir, exist_ok=True)
@ -157,7 +158,7 @@ if __name__ == "__main__":
# ========== 8. 开始训练 ========== # ========== 8. 开始训练 ==========
for epoch in range(start_epoch, args.epochs): for epoch in range(start_epoch, args.epochs):
train_sampler and train_sampler.set_epoch(epoch) train_sampler and train_sampler.set_epoch(epoch)
setup_seed(42 + epoch); indices = torch.randperm(len(train_ds)).tolist() setup_seed(args.seed + epoch); indices = torch.randperm(len(train_ds)).tolist()
skip = start_step if (epoch == start_epoch and start_step > 0) else 0 skip = start_step if (epoch == start_epoch and start_step > 0) else 0
batch_sampler = SkipBatchSampler(train_sampler or indices, args.batch_size, skip) batch_sampler = SkipBatchSampler(train_sampler or indices, args.batch_size, skip)
loader = DataLoader(train_ds, batch_sampler=batch_sampler, num_workers=args.num_workers, pin_memory=True) loader = DataLoader(train_ds, batch_sampler=batch_sampler, num_workers=args.num_workers, pin_memory=True)

View File

@ -98,6 +98,7 @@ if __name__ == "__main__":
parser.add_argument('--num_hidden_layers', default=8, type=int, help="隐藏层数量") parser.add_argument('--num_hidden_layers', default=8, type=int, help="隐藏层数量")
parser.add_argument('--max_seq_len', default=340, type=int, help="训练的最大截断长度(中文1token≈1.5~1.7字符)") parser.add_argument('--max_seq_len', default=340, type=int, help="训练的最大截断长度(中文1token≈1.5~1.7字符)")
parser.add_argument('--use_moe', default=0, type=int, choices=[0, 1], help="是否使用MoE架构(0=否,1=是)") parser.add_argument('--use_moe', default=0, type=int, choices=[0, 1], help="是否使用MoE架构(0=否,1=是)")
parser.add_argument('--seed', default=42, type=int, help="随机种子(DDP下每个rank为seed+rank,每轮为seed+epoch)")
parser.add_argument("--data_path", type=str, default="../dataset/pretrain_t2t_mini.jsonl", help="预训练数据路径") parser.add_argument("--data_path", type=str, default="../dataset/pretrain_t2t_mini.jsonl", help="预训练数据路径")
parser.add_argument('--from_weight', default='none', type=str, help="基于哪个权重训练,为none则从头开始") parser.add_argument('--from_weight', default='none', type=str, help="基于哪个权重训练,为none则从头开始")
parser.add_argument('--from_resume', default=0, type=int, choices=[0, 1], help="是否自动检测&续训(0=否,1=是)") parser.add_argument('--from_resume', default=0, type=int, choices=[0, 1], help="是否自动检测&续训(0=否,1=是)")
@ -109,7 +110,7 @@ if __name__ == "__main__":
# ========== 1. 初始化环境和随机种子 ========== # ========== 1. 初始化环境和随机种子 ==========
local_rank = init_distributed_mode() local_rank = init_distributed_mode()
if dist.is_initialized(): args.device = f"cuda:{local_rank}" if dist.is_initialized(): args.device = f"cuda:{local_rank}"
setup_seed(42 + (dist.get_rank() if dist.is_initialized() else 0)) setup_seed(args.seed + (dist.get_rank() if dist.is_initialized() else 0))
# ========== 2. 配置目录、模型参数、检查ckp ========== # ========== 2. 配置目录、模型参数、检查ckp ==========
os.makedirs(args.save_dir, exist_ok=True) os.makedirs(args.save_dir, exist_ok=True)
@ -156,7 +157,7 @@ if __name__ == "__main__":
# ========== 8. 开始训练 ========== # ========== 8. 开始训练 ==========
for epoch in range(start_epoch, args.epochs): for epoch in range(start_epoch, args.epochs):
train_sampler and train_sampler.set_epoch(epoch) train_sampler and train_sampler.set_epoch(epoch)
setup_seed(42 + epoch); indices = torch.randperm(len(train_ds)).tolist() setup_seed(args.seed + epoch); indices = torch.randperm(len(train_ds)).tolist()
skip = start_step if (epoch == start_epoch and start_step > 0) else 0 skip = start_step if (epoch == start_epoch and start_step > 0) else 0
batch_sampler = SkipBatchSampler(train_sampler or indices, args.batch_size, skip) batch_sampler = SkipBatchSampler(train_sampler or indices, args.batch_size, skip)
loader = DataLoader(train_ds, batch_sampler=batch_sampler, num_workers=args.num_workers, pin_memory=True) loader = DataLoader(train_ds, batch_sampler=batch_sampler, num_workers=args.num_workers, pin_memory=True)