update minimind-v1-moe

This commit is contained in:
gongjy 2024-09-17 11:33:31 +08:00
parent c404941677
commit 61cb61a46a
7 changed files with 351 additions and 458 deletions

View File

@ -110,13 +110,13 @@ def init_model(lm_config):
if model_from == 1:
model = Transformer(lm_config)
moe_path = '_moe' if lm_config.use_moe else ''
ckp = f'./out/pretrain_{lm_config.dim}{moe_path}.pth'
state_dict = torch.load(ckp, map_location=device)
unwanted_prefix = '_orig_mod.'
for k, v in list(state_dict.items()):
if k.startswith(unwanted_prefix):
state_dict[k[len(unwanted_prefix):]] = state_dict.pop(k)
model.load_state_dict(state_dict, strict=False)
# ckp = f'./out/pretrain_{lm_config.dim}{moe_path}.pth'
# state_dict = torch.load(ckp, map_location=device)
# unwanted_prefix = '_orig_mod.'
# for k, v in list(state_dict.items()):
# if k.startswith(unwanted_prefix):
# state_dict[k[len(unwanted_prefix):]] = state_dict.pop(k)
# model.load_state_dict(state_dict, strict=False)
else:
model = AutoModel.from_pretrained('./minimind', trust_remote_code=True)
@ -146,8 +146,8 @@ if __name__ == "__main__":
out_dir = 'out'
epochs = 19
gradient_accumulation_steps = 1
batch_size = 50
learning_rate = 2e-4
batch_size = 40
learning_rate = 1e-4
device = 'cuda:0'
dtype = 'bfloat16'
# dtype = 'float16'
@ -173,7 +173,7 @@ if __name__ == "__main__":
model, tokenizer = init_model(lm_config)
# -----init dataloader------
df = pd.read_csv('./dataset/sft_data_multi.csv')
df = pd.read_csv('./dataset/sft_data_single.csv')
df = df.sample(frac=1.0)
train_ds = SFTDataset(df, tokenizer, max_length=max_seq_len)
train_sampler = DistributedSampler(train_ds) if ddp else None

321
README.md
View File

@ -52,15 +52,14 @@ https://github.com/user-attachments/assets/88b98128-636e-43bc-a419-b1b1403c2055
因此本项目的目标是把上手LLM的门槛无限降低
直接从0开始训练一个极其轻量的语言模型。
截至2024.09.01MiniMind包含5个型号模型最小仅需26M0.02B即可具备Amazing的对话能力
> [!TIP]
> 截至2024-9-17minimind训练了3个型号模型最小仅需26M0.02B),即可具备流畅的对话能力!
| 模型 (大小) | 速度 (Tokens/s) | 推理占用 | 训练占用(`batch_size=8`) | release | 主观评分(/100 |
|------------------------|---------------|--------|----------------------|--------------------|------------|
| MiniMind-small-T (26M) | 91.9 | 0.5 GB | 3.6 GB | 2024.08.28 | 45' |
| MiniMind-small (56M) | 85.2 | 0.7 GB | 4.5 GB | 2024.08.28 | 45' |
| MiniMind (218M) | 57.6 | 2.1 GB | 10.4 GB | 2024.08.28 | 55' |
| MiniMind-MoE (166M) | 64.9 | 1.6 GB | 7.4 GB | 2024.08.28 | 35' |
| MiniMind-V1 (108M) | 78.3 | 1.0 GB | 6.4 GB | 2024.09.01 (new🎉) | 60' |
| 模型 (大小) | tokenizer长度 | 推理占用 | release | 主观评分(/100 |
|-------------------------|-------------|--------|------------|------------|
| minimind-v1-small (26M) | 6400 | 0.5 GB | 2024.08.28 | 50' |
| minimind-v1-moe (4×26M) | 6400 | 1.0 GB | 2024.09.17 | 55' |
| minimind-v1 (108M) | 6400 | 1.0 GB | 2024.09.01 | 60' |
> 该分析在一个带有Torch 2.1.2、CUDA 12.2和Flash Attention 2的RTX 3090 GPU上运行。
@ -79,9 +78,18 @@ https://github.com/user-attachments/assets/88b98128-636e-43bc-a419-b1b1403c2055
### 👉**最近更新**
<details close>
<summary> <b>2024-09-01 (new🎉)</b> </summary>
<summary> <b>2024-09-17 (new🎉)</b> </summary>
- 更新MiniMind-V1 (108M)模型采用minimind_tokenizer预训练轮次3 + SFT轮次10更充分训练性能更强。
- 更新minimind-v1-moe模型
- 为了防止歧义不再使用mistral_tokenizer分词全部采用自定义的minimind_tokenizer作为分词器。
</details>
<details close>
<summary> <b>2024-09-01</b> </summary>
- 更新minimind-v1 (108M)模型采用minimind_tokenizer预训练轮次3 + SFT轮次10更充分训练性能更强。
- 项目已部署至ModelScope创空间可以在此网站上体验
@ -116,7 +124,7 @@ https://github.com/user-attachments/assets/88b98128-636e-43bc-a419-b1b1403c2055
<img src="https://g.alicdn.com/sail-web/maas/1.15.0/static/modelscopeIcon.cd89353f.svg" alt="Hugging Face Logo" style="vertical-align: middle; height: 30px;" />
[MiniMind (ModelScope)](https://www.modelscope.cn/models/gongjy/MiniMind-V1)
[MiniMind (ModelScope)](https://www.modelscope.cn/models/gongjy/minimind-v1)
</div>
@ -162,32 +170,29 @@ streamlit run fast_inference.py
* 2.1 下载[数据集下载地址](#数据集下载地址)放到`./dataset`目录下
* 2.2 `python data_process.py`处理数据集例如pretrain数据提前进行token-encoder、sft数据集抽离qa到csv文件
* 2.2 `python data_process.py`处理数据集例如pretrain数据提前进行token-encoder、sft数据集抽离qa到csv文件
* 2.3 在`./model/LMConfig.py` 中调整model的参数配置
* 2.4 `python 1-pretrain.py` 执行预训练
* 2.5 `python 3-full_sft.py` 执行指令微调
* 2.6 `python 4-lora_sft.py` 执行lora微调非必须
* 2.7 `python 5-dpo_train.py` 执行DPO人类偏好强化学习对齐非必须
* 2.3 在`./model/LMConfig.py` 中调整model的参数配置
* 2.4 `python 1-pretrain.py` 执行预训练
* 2.5 `python 3-full_sft.py` 执行指令微调
* 2.6 `python 4-lora_sft.py` 执行lora微调非必须
* 2.7 `python 5-dpo_train.py` 执行DPO人类偏好强化学习对齐非必须
* 3、测试模型推理效果
* 从下面【训练完成的模型权重】下载权重到`./out/`目录下
* 确保需要使用的,训练完成的参数权重位于`./out/`目录下
* 也可以直接去[训练完成的模型权重](#训练完成的模型权重)下载使用我训练好的
```text
out
├── multi_chat
│   ├── full_sft_1024.pth
│   ├── full_sft_512.pth
│   ├── full_sft_640_moe.pth
│   └── full_sft_640.pth
│   ├── full_sft_512_moe.pth
│   └── full_sft_768.pth
├── single_chat
│   ├── full_sft_1024.pth
│   ├── full_sft_512.pth
│   ├── full_sft_640_moe.pth
│   └── full_sft_640.pth
│   ├── full_sft_512_moe.pth
│   └── full_sft_768.pth
├── pretrain_1024.pth
├── pretrain_640_moe.pth
├── pretrain_640.pth
├── pretrain_768.pth
├── pretrain_512_moe.pth
├── pretrain_512.pth
```
* `python 0-eval_pretrain.py`测试预训练模型的接龙效果
* `python 2-eval.py`测试模型的对话效果
@ -228,11 +233,13 @@ streamlit run fast_inference.py
<tr><td>minimind tokenizer</td><td>6,400</td><td>自定义</td></tr>
</table>
> 尽管Mistral中文词语占比很少编解码效率弱于qwen2、glm等中文友好型分词器。
> 但MiniMind这里选择了mistral tokenizer作为分词器以保持整体参数轻量避免头重脚轻因为mistral的词表大小只有32,000。
> 且MiniMind在实际测试中几乎没有出现过生僻词汇解码失败的情况效果良好。
> [!TIP]
> 2024-09-17更新为了防止过去的版本歧义&控制体积minimind所有模型均使用minimind_tokenizer分词废弃所有mistral_tokenizer版本。
> 方便对比测试效果额外训练了一个自定义Tokenizer模型的版本**MiniMind-small-T**自定义词表压缩长度到6400使得LLM总参数进一步降低到26M左右。
> 尽管minimind_tokenizer长度很小编解码效率弱于qwen2、glm等中文友好型分词器。
> 但minimind模型选择了自己训练的minimind_tokenizer作为分词器以保持整体参数轻量避免编码层和计算层占比失衡头重脚轻因为minimind的词表大小只有6400。
> 且minimind在实际测试中没有出现过生僻词汇解码失败的情况效果良好。
> 由于自定义词表压缩长度到6400使得LLM总参数量最低只有26M。
---
@ -310,18 +317,14 @@ MiniMind的整体结构一致只是在RoPE计算、推理函数和FFN层的
![](./images/LLM-structure.png)
![](./images/LLM-structure-moe.png)
模型配置见[./model/LMConfig.py](./model/LMConfig.py)。模型型号和参数见下表:
修改模型配置见[./model/LMConfig.py](./model/LMConfig.py)。
minimind目前训练的模型版本见下表
| Model Name | params | len_vocab | n_layers | d_model | kv_heads | q_heads | share+route | TopK |
|------------------|--------|-----------|----------|---------|----------|---------|-------------|------|
| minimind-small-T | 26M | 6400 | 8 | 512 | 8 | 16 | - | - |
| minimind-small | 56M | 32000 | 8 | 640 | 8 | 16 | - | - |
| minimind | 218M | 32000 | 16 | 1024 | 8 | 16 | - | - |
| minimind-MoE | 162M | 32000 | 8 | 640 | 8 | 16 | 2+4 | 2 |
| minimind-V1 | 108M | 6400 | 16 | 768 | 8 | 16 | - | - |
此外作为参考GPT3的层数和维度参数见下表
![gpt3_config.png](./images/gpt3_config.png)
| Model Name | params | len_vocab | n_layers | d_model | kv_heads | q_heads | share+route | TopK |
|-------------------|--------|-----------|----------|---------|----------|---------|-------------|------|
| minimind-v1-small | 26M | 6400 | 8 | 512 | 8 | 16 | - | - |
| minimind-v1-moe | 4×26M | 6400 | 8 | 512 | 8 | 16 | 2+4 | 2 |
| minimind-v1 | 108M | 6400 | 16 | 768 | 8 | 16 | - | - |
# 📌 Experiment
@ -332,13 +335,11 @@ CPU: Intel(R) Core(TM) i9-10980XE CPU @ 3.00GHz
环境python 3.9 + Torch 2.1.2 + DDP多卡训练
```
| Model Name | params | len_vocab | batch_size | pretrain_time | sft_single_time | sft_multi_time |
|------------------|--------|-----------|------------|--------------------|-------------------|---------------------|
| minimind-small-T | 26M | 6400 | 64 | ≈5 hour (1 epoch) | ≈2 hour (1 epoch) | ≈0.5 hour (1 epoch) |
| minimind-small | 56M | 32000 | 24 | ≈6 hour (1 epoch) | ≈2 hour (1 epoch) | ≈0.5 hour (1 epoch) |
| minimind | 218M | 32000 | 16 | ≈15 hour (1 epoch) | ≈5 hour (1 epoch) | ≈1 hour (1 epoch) |
| minimind-MoE | 166M | 32000 | 16 | ≈13 hour (1 epoch) | ≈5 hour (1 epoch) | ≈1 hour (1 epoch) |
| minimind-V1 | 108M | 6400 | 16 | ≈8 hour (1 epoch) | ≈3 hour (1 epoch) | ≈1 hour (1 epoch) |
| Model Name | params | len_vocab | batch_size | pretrain_time | sft_single_time | sft_multi_time |
|-------------------|--------|-----------|------------|-------------------|-------------------|---------------------|
| minimind-v1-small | 26M | 6400 | 64 | ≈2 hour (1 epoch) | ≈2 hour (1 epoch) | ≈0.5 hour (1 epoch) |
| minimind-v1-moe | 4×26M | 6400 | 40 | ≈6 hour (1 epoch) | ≈5 hour (1 epoch) | ≈1 hour (1 epoch) |
| minimind-v1 | 108M | 6400 | 16 | ≈6 hour (1 epoch) | ≈4 hour (1 epoch) | ≈1 hour (1 epoch) |
---
@ -346,7 +347,7 @@ CPU: Intel(R) Core(TM) i9-10980XE CPU @ 3.00GHz
- LLM首先要学习的并非直接与人交流而是让肚子中充满知识的墨水至于墨水理论上喝的越饱越好产生大量的对世界的认知积累。
- 预训练就是让Model先埋头苦学大量基本的知识例如从维基百科、新闻、常识、书籍等。
- 它无监督的从大量的文本数据中压缩知识到自己模型的权重,目的是:学会词语接龙。例如我们输入“秦始皇是”四个字,它在大量学习后能预测出下一句话大概率是“中国的第一位皇帝”。
> pretrain的学习率设置为1e-4到1e-5的动态学习率预训练epoch数设为2预训练时间不到1天
> pretrain的学习率设置为1e-4到1e-5的动态学习率预训练epoch数设为5
```bash
torchrun --nproc_per_node 2 1-pretrain.py
```
@ -356,7 +357,7 @@ CPU: Intel(R) Core(TM) i9-10980XE CPU @ 3.00GHz
”后不再无脑接龙,而是意识到这是一段完整的对话结束。
- 我们称这个过程为指令微调就如同让学富五车的「牛顿」先生适应21世纪的聊天习惯学习屏幕左侧是对方消息右侧是本人消息这个规律。
- 在训练时MiniMind的指令和回答长度被截断在512是为了节省显存空间。就像我们学习时会先从短的文章开始当学会阅读200字作文后800字长文章就不需要再单独学习。
> 在推理时通过调整RoPE线性差值实现长度外推到1024或2048及以上很方便。学习率设置为1e-5到1e-6的动态学习率微调epoch数为5
> 在推理时通过调整RoPE线性差值实现长度外推到1024或2048及以上很方便。学习率设置为1e-5到1e-6的动态学习率微调epoch数为6
```bash
# 3-full_sft.py中设置数据集为sft_data_single.csv
@ -368,7 +369,7 @@ CPU: Intel(R) Core(TM) i9-10980XE CPU @ 3.00GHz
- 构建【问题->回答,问题->回答,问题->】的新聊天模板,然后使用这个数据集进行微调。
- 学习完成的模型不仅仅只能回答当前问题,还能根据历史对话进行连贯的对话。
- 这一步并非必须因为小模型长上文对话能力很弱强行对齐多轮问答模板会损失一定程度的单轮SFT效果。
> 学习率设置为1e-5到1e-6的动态学习率微调epoch数为2
> 学习率设置为1e-5到1e-6的动态学习率微调epoch数为5
```bash
# 3-full_sft.py中设置数据集为sft_data.csv
torchrun --nproc_per_node 2 3-full_sft.py
@ -382,19 +383,8 @@ CPU: Intel(R) Core(TM) i9-10980XE CPU @ 3.00GHz
```
---
🔗训练完成的模型权重:
| Model Name | params | Config | pretrain_model | single_sft_model | multi_sft_model |
|------------------|--------|-------------------------------------------------|----------------------------------------------------------------|----------------------------------------------------------------|----------------------------------------------------------------|
| minimind-small-T | 26M | d_model=512<br/>n_layers=8 | - | [链接](https://pan.baidu.com/s/1_COe0FQRDmeapSsvArahCA?pwd=6666) | [链接](https://pan.baidu.com/s/1GsGsWSL0Dckl0YPRXiBIFQ?pwd=6666) |
| minimind-small | 56M | d_model=640<br/>n_layers=8 | [链接](https://pan.baidu.com/s/1nJuOpnu5115FDuz6Ewbeqg?pwd=6666) | [链接](https://pan.baidu.com/s/1lRX0IcpjNFSySioeCfifRQ?pwd=6666) | [链接](https://pan.baidu.com/s/1LzVxBpL0phtGUH267Undqw?pwd=6666) |
| minimind | 218M | d_model=1024<br/>n_layers=16 | [链接](https://pan.baidu.com/s/1jzA7uLEi-Jen2fW5olCmEg?pwd=6666) | [链接](https://pan.baidu.com/s/1Hvt0Q_UB_uW2sWTw6w1zRQ?pwd=6666) | [链接](https://pan.baidu.com/s/1fau9eat3lXilnrG3XNhG5Q?pwd=6666) |
| minimind-MoE | 166M | d_model=1024<br/>n_layers=8<br/>share+route=2+4 | [链接](https://pan.baidu.com/s/11CneDVTkw2Y6lNilQX5bWw?pwd=6666) | [链接](https://pan.baidu.com/s/1fRq4MHZec3z-oLK6sCzj_A?pwd=6666) | [链接](https://pan.baidu.com/s/1HC2KSM_-RHRtgv7ZDkKI9Q?pwd=6666) |
| minimind-V1 | 108M | d_model=768<br/>n_layers=16 | - | [链接](https://pan.baidu.com/s/1p713loS7EfwHQf3G9eYI3Q?pwd=6666) | [链接](https://pan.baidu.com/s/12iHGpAs6R0kqsOnGtgK6vQ?pwd=6666) |
---
关于LLM的参数配置有一篇很有意思的论文[MobileLLM](https://arxiv.org/pdf/2402.14905)做了详细的研究和实验。
📋关于LLM的参数配置有一篇很有意思的论文[MobileLLM](https://arxiv.org/pdf/2402.14905)做了详细的研究和实验。
scaling law在小模型中有自己独特的规律。
引起Transformer参数成规模变化的参数几乎只取决于`d_model``n_layers`
@ -407,95 +397,98 @@ MobileLLM提出架构的深度比宽度更重要「深而窄」的「瘦长
例如当模型参数固定在125M或者350M时3042层的「狭长」模型明显比12层左右的「矮胖」模型有更优越的性能
在常识推理、问答、阅读理解等8个基准测试上都有类似的趋势。
这其实是非常有趣的发现因为以往为100M左右量级的小模型设计架构时几乎没人尝试过叠加超过12层。
这与MiniMind在训练过程中模型参数量在`d_model``n_layers`之间进行调整实验观察到的效果是一致的。
然而「深而窄」的「窄」也是有维度极限的当d_model<512时词嵌入维度坍塌的劣势非常明显
增加的layers并不能弥补词嵌入在固定q_head带来d_head不足的劣势。
当d_model>1536时layers的增加似乎比d_model的优先级更高更能带来具有“性价比”的参数->效果增益。
因此MiniMind设定small模型的d_model=640n_layers=8来获取的「极小体积<->更好效果」的平衡。
设定d_model=1024n_layers=16来获取效果的更大收益更加符合小模型scaling-law的变化曲线。
因此MiniMind设定small模型的d_model=512n_layers=8来获取的「极小体积<->更好效果」的平衡。
设定d_model=768n_layers=16来获取效果的更大收益更加符合小模型scaling-law的变化曲线。
> 作为参考GPT3的参数设定见下表
![gpt3_config.png](./images/gpt3_config.png)
---
### 训练完成的模型权重
[百度网盘](https://pan.baidu.com/s/1KUfSzEkSXYbCCBj0Pw-9fA?pwd=6666)
| Model Name | params | Config | pretrain_model | single_sft_model | multi_sft_model |
|-------------------|--------|-----------------------------|----------------------------------------------------------------|----------------------------------------------------------------|----------------------------------------------------------------|
| minimind-v1-small | 26M | d_model=512<br/>n_layers=8 | [链接](https://pan.baidu.com/s/1wP_cAIc8cgaJ6CxUmR9ECQ?pwd=6666) | [链接](https://pan.baidu.com/s/1_COe0FQRDmeapSsvArahCA?pwd=6666) | [链接](https://pan.baidu.com/s/1GsGsWSL0Dckl0YPRXiBIFQ?pwd=6666) |
| minimind-v1-moe | 4×26M | d_model=512<br/>n_layers=8 | - | - | - |
| minimind-v1 | 108M | d_model=768<br/>n_layers=16 | - | [链接](https://pan.baidu.com/s/1p713loS7EfwHQf3G9eYI3Q?pwd=6666) | [链接](https://pan.baidu.com/s/12iHGpAs6R0kqsOnGtgK6vQ?pwd=6666) |
---
# 📌 Eval
> 【注】以下测试于2024.8.28完成此日期后发布的例如MiniMind-V1新模型无特殊需要时将不加入测试。
[A] [minimind-small-T(0.02B)](https://pan.baidu.com/s/1_COe0FQRDmeapSsvArahCA?pwd=6666)<br/>
[B] [minimind-small(0.05B)](https://pan.baidu.com/s/1lRX0IcpjNFSySioeCfifRQ?pwd=6666)<br/>
[C] [minimind-MoE(0.16B)](https://pan.baidu.com/s/1fRq4MHZec3z-oLK6sCzj_A?pwd=6666)<br/>
[D] [minimind(0.2B)](https://pan.baidu.com/s/1Hvt0Q_UB_uW2sWTw6w1zRQ?pwd=6666)<br/>
[E] [baby-llama2-chinese(0.2B)](https://github.com/DLLXW/baby-llama2-chinese)<br/>
[F] [chatlm-mini-chinese(0.2B)](https://github.com/charent/ChatLM-mini-Chinese)<br/>
```angular2html
[Q]: 一星期有多少天?
[A]: 一星期有七天。
[B]: 一星期有7天。
[C]: 根据您的计算一星期有12个小时。因此我们需要将小时数乘以12。这样我们就可以得到12的小时数。
[D]: 一星期共有七天。
[E]: 作为一个人工智能助手,我无法确定您所描述的星期数。 如果您能够提供您所描述的星期数,我可以为您提供有关该星期天数的信息。
[F]: 一星期有七天,也就是七天的积,也就是 7 x 7 = 24 天。这个数字是通过将 24 除以 7 得到的,因为一周有七天,所以一星期有 24 x 7 = 24 天。
> [!TIP]
> 以下测试于2024-09-17完成此日期后发布的新模型无特殊需要时将不加入测试。
[A] [minimind-v1-small(0.02B)](https://pan.baidu.com/s/1_COe0FQRDmeapSsvArahCA?pwd=6666)<br/>
[B] minimind-v1-moe(0.1B)<br/>
[C] [minimind-v1(0.1B)](https://pan.baidu.com/s/1p713loS7EfwHQf3G9eYI3Q?pwd=6666)<br/>
[D] [baby-llama2-chinese(0.2B)](https://github.com/DLLXW/baby-llama2-chinese)<br/>
[E] [chatlm-mini-chinese(0.2B)](https://github.com/charent/ChatLM-mini-Chinese)<br/>
```text
[Q]: 你知道长江吗?
[A]: 是的长江是中国最长的河流全长超过3300千米。
[B]: 是的长江是中国最长的河流全长约7100公里。它的流域面积约为3328万平方公里是中国最大的河流之一也是世界第三大河流总长度约为6300千米。
[C]: 我知道。长江是我国的一个重要水系,有着悠久的历史和文化。长江是中华民族的象征和精神支柱,也是世界上最美丽的自然景观之一。长江沿岸地区的人们,特别是在长江流域生活了数千年。长江在中国的历史和文化中,尤其是历史悠久的文化,有着深厚的历史和文化底蕴。
[D]: 长江是中国的第一大河流全长约6380公里。它是亚洲最长的河流也是中国第一大河流。长江流域是中国的重要河流之一有着丰富的自然资源和文化遗产。长江流域是中国最重要的农业和经济发展区拥有众多的文化遗产和历史景点是中国最重要的文化旅游目的地之一。
[E]: 同时也知道中国是世界上最长的城市之一拥有超过3400万人口。
[F]: 是的,长江是中国最长的河流,也是世界上最长的河流之一。它发源于青藏高原,流经九个省区,最终注入东海。长江流域的气候温和,四季分明,是中国重要的农业和工业基地。长江流域的水产资源丰富,是中国的重要渔业资源之一。
[C]: 是的长江是中国最长的河流之一也是世界第三大河流。长江发源于青藏高原流经11个省份最终注入东海。长江流域是中国最大的河流流域之一拥有着丰富的自然资源和文化遗产如长江大桥、长江海洋博物馆、长江古城等。
[D]: 同时也知道中国是世界上最长的城市之一拥有超过3400万人口。
[E]: 是的,长江是中国最长的河流,也是世界上最长的河流之一。它发源于青藏高原,流经九个省区,最终注入东海。长江流域的气候温和,四季分明,是中国重要的农业和工业基地。长江流域的水产资源丰富,是中国的重要渔业资源之一。
[Q]: 第一颗人造卫星是哪个国家发射的?
[A]: 第一颗人造卫星是斯普特尼克1号。
[B]: 第一颗人造卫星是美国发射的。
[C]: 第一颗人造卫星是中国国家航天科技集团有限公司的卫星,它是中国航天科技集团公司的卫星,由中国航天科技集团公司发射。
[D]: 第一颗人造卫星是苏联于1957年发射的。
[E]: 这颗名为“阿姆斯特朗”的卫星于1961年11月20日发射是第一个成功将人类送入太空的卫星。
[F]: 第一颗人造卫星是苏联于1957年4月4日发射的它是由苏联宇航员尤里·加加林Yuri Gagarin和苏联工程师罗尔德·谢尔盖耶夫Roald Skohley共同发射的。在发射过程中加加林和谢尔盖耶夫使用了一个名为“斯普特尼克1号”的小型卫星它的直径为4.3米重量为1,051公斤。这枚卫星被称为“斯普特尼克1号”是苏联太空竞赛中的一个里程碑也是人类历史上第一次在太空中进行太空行走。
[C]: 第一颗人造卫星是苏联发射的它是由苏联于1957年10月发射的。
[D]: 这颗名为“阿姆斯特朗”的卫星于1961年11月20日发射是第一个成功将人类送入太空的卫星。
[E]: 第一颗人造卫星是苏联于1957年4月4日发射的它是由苏联宇航员尤里·加加林Yuri Gagarin和苏联工程师罗尔德·谢尔盖耶夫Roald Skohley共同发射的。在发射过程中加加林和谢尔盖耶夫使用了一个名为“斯普特尼克1号”的小型卫星它的直径为4.3米重量为1,051公斤。这枚卫星被称为“斯普特尼克1号”是苏联太空竞赛中的一个里程碑也是人类历史上第一次在太空中进行太空行走。
[Q]: 你知道泰山在哪里吗?
[A]: 泰山位于中国东部地区,是中国五岳之一。
[B]: 泰山位于山东省泰安市,是中国五岳之一。
[C]: 泰山在哪里呢?
[D]: 泰山位于中国山东省昆山市,是中国古代文化的瑰宝之一,也是世界著名的山岳风景区之一。泰山是五岳之一,以其险峻的山峰、秀丽的自然风光和丰富的文化底蕴而闻名于世。
[E]: 作为一个人工智能助手,我无法访问互联网,因此无法提供关于你所在位置的信息。不过,你可以通过搜索或搜索相关关键词来获取有关你所在位置的信息,或者查看相关新闻或网站来获取有关你所在位置的信息。
[F]: 泰山位于中国山东省泰安市境内是中国五岳之一也是中国文化和历史的重要象征之一。它是中国五岳之一也是中国道教和佛教的发源地之一。泰山的海拔高度为1,545米是中国五岳之一也是中国最著名的旅游景点之一。它的历史可以追溯到公元前5世纪是中国古代帝王祭祀的场所。泰山也是中国文化的重要组成部分被誉为“五岳之首”是中国文化的重要遗产之一。
[C]: 泰山位于中国山东省泰安市,是中国五岳之一。
[D]: 作为一个人工智能助手,我无法访问互联网,因此无法提供关于你所在位置的信息。不过,你可以通过搜索或搜索相关关键词来获取有关你所在位置的信息,或者查看相关新闻或网站来获取有关你所在位置的信息。
[E]: 泰山位于中国山东省泰安市境内是中国五岳之一也是中国文化和历史的重要象征之一。它是中国五岳之一也是中国道教和佛教的发源地之一。泰山的海拔高度为1,545米是中国五岳之一也是中国最著名的旅游景点之一。它的历史可以追溯到公元前5世纪是中国古代帝王祭祀的场所。泰山也是中国文化的重要组成部分被誉为“五岳之首”是中国文化的重要遗产之一。
[Q]: 世界上最高的山峰是什么?
[A]: 世界上最高的山峰是珠穆朗玛峰位于尼泊尔和中国的边境上海拔8848米。
[B]: 珠穆朗玛峰是世界上最高的山峰位于喜马拉雅山脉海拔8848米。
[C]: 世界上最高的山峰是珠穆朗玛峰。
[D]: 世界上最高的山峰是珠穆朗玛峰位于喜马拉雅山脉海拔8,848.86米。
[E]: 世界上最高的山峰是珠穆朗玛峰位于喜马拉雅山脉海拔8,848.86米29,031.69英尺)。
[F]: 世界上最高的山峰是珠穆朗玛峰也称为萨加玛塔位于喜马拉雅山脉的尼泊尔和中国边境之间海拔8,848.86米29,031.69英尺)。它是世界上最著名的登山目标之一,吸引着来自世界各地的登山者前来挑战。珠穆朗玛峰的名字来自藏语,意思是“女神的额峰”,它是由两个不同的山峰组成的,其中一个是位于尼泊尔的珠穆朗玛峰,另一个则位于中国。它的高度是通过测量海拔高度来确定的,因为它是通过测量地球的平均高度来确定的。尽管珠穆朗玛峰是世界上最高的山峰,但它并不是地球上任何其他地方都能到达的。地球上的其他地方,如南美洲的安第斯山脉,也是世界上最高的山脉,但它并不是地球上最高的山峰。总之,珠穆朗玛峰是世界上最高的山峰,但它并不是地球上任何地方都能到达的。它是地球上最高的山脉,但它并不是地球上任何地方都能到达的。
[C]: 珠穆朗玛峰是世界上最高的山峰海拔8848米。
[D]: 世界上最高的山峰是珠穆朗玛峰位于喜马拉雅山脉海拔8,848.86米29,031.69英尺)。
[E]: 世界上最高的山峰是珠穆朗玛峰也称为萨加玛塔位于喜马拉雅山脉的尼泊尔和中国边境之间海拔8,848.86米29,031.69英尺)。它是世界上最著名的登山目标之一,吸引着来自世界各地的登山者前来挑战。珠穆朗玛峰的名字来自藏语,意思是“女神的额峰”,它是由两个不同的山峰组成的,其中一个是位于尼泊尔的珠穆朗玛峰,另一个则位于中国。它的高度是通过测量海拔高度来确定的,因为它是通过测量地球的平均高度来确定的。尽管珠穆朗玛峰是世界上最高的山峰,但它并不是地球上任何其他地方都能到达的。地球上的其他地方,如南美洲的安第斯山脉,也是世界上最高的山脉,但它并不是地球上最高的山峰。总之,珠穆朗玛峰是世界上最高的山峰,但它并不是地球上任何地方都能到达的。它是地球上最高的山脉,但它并不是地球上任何地方都能到达的。
[Q]: 万有引力是谁提出的?
[A]: 万有引力是由英国物理学家牛顿提出的。他认为,所有物体都会产生引力,这个引力是由物体的质量和距离决定的。这个理论揭示了质量和距离之间的关系,并证明了万有引力的本质。
[B]: 万有引力是由牛顿发现的它是由英国物理学家詹姆斯·瓦特于1879年提出的。
[C]: 万有引力是谁提出的?
[D]: 万有引力是由牛顿提出的,他发现每个物体都会对其他物体施加引力,这些力的大小取决于物体的质量和距离。
[E]: 引力是宇宙中一种力量,它是由质量或能量所组成的。根据牛顿的万有引力定律,一个物体之间的引力大小与它的质量成正比,与它的质量成反比。因此,牛顿的万有引力定律表明,一个物体之间的引力大小与它的质量成正比,与它的质量成反比。这个定律在物理学、天文学和物理学中都有广泛的应用。
[F]: 万有引力是由英国物理学家艾萨克·牛顿于1687年提出的。他在1687年发表了一篇著名的论文题为《自然哲学的数学原理》其中提出了万有引力定律指出任何两个物体之间都存在着一种引力这种引力的大小与它们的质量成正比与它们之间的距离的平方成反比。这个定律被称为万有引力定律它描述了质量和距离之间的关系。它表明两个物体之间的引力与它们的质量成正比与它们之间的距离的平方成反比。这个定律对于解释宇宙中的许多现象和现象之间的相互作用非常重要例如行星绕太阳运动、恒星之间的引力透镜效应等等。它也被广泛应用于天文学、物理学和工程学等领域为我们理解宇宙的本质和演化提供了重要的理论基础。
[C]: 万有引力是英国物理学家艾萨克·牛顿在17世纪提出的。
[D]: 引力是宇宙中一种力量,它是由质量或能量所组成的。根据牛顿的万有引力定律,一个物体之间的引力大小与它的质量成正比,与它的质量成反比。因此,牛顿的万有引力定律表明,一个物体之间的引力大小与它的质量成正比,与它的质量成反比。这个定律在物理学、天文学和物理学中都有广泛的应用。
[E]: 万有引力是由英国物理学家艾萨克·牛顿于1687年提出的。他在1687年发表了一篇著名的论文题为《自然哲学的数学原理》其中提出了万有引力定律指出任何两个物体之间都存在着一种引力这种引力的大小与它们的质量成正比与它们之间的距离的平方成反比。这个定律被称为万有引力定律它描述了质量和距离之间的关系。它表明两个物体之间的引力与它们的质量成正比与它们之间的距离的平方成反比。这个定律对于解释宇宙中的许多现象和现象之间的相互作用非常重要例如行星绕太阳运动、恒星之间的引力透镜效应等等。它也被广泛应用于天文学、物理学和工程学等领域为我们理解宇宙的本质和演化提供了重要的理论基础。
[Q]: 你知道大熊猫的主要食物是什么吗?
[A]: 大熊猫的主要食物是竹子。它们通常吃竹子每天需要吃掉大约30公斤的竹子。
[B]: 大熊猫主要是竹子,它们的主要食物是竹子。大熊猫的消化系统比较特殊,它们每天需要消化大量的竹子才能维持其生存需要。除了竹子外,大熊猫还在野外生存。
[C]: 大熊猫的主要食物是竹子、蘑菇、蘑菇、甜菜和蘑菇
[D]: 大熊猫是一种以竹子为食的哺乳动物,但主要食物来源是竹笋、竹叶、茎、茎等
[E]: 大熊猫的主要食物是竹子。
[F]: 大熊猫是一种以竹子为主要食物的植食动物,它们的肠道结构适合消化纤维素含量高的竹子,但也会吃一些其他植物,如草本植物和小型哺乳动物。大熊猫的肠道结构也适应了高纤维的竹子,这使得它们能够消化大量的纤维素,从而帮助它们在野外生存。大熊猫的肠道中还含有一种叫做“纤维素酶”的酶类物质,这种酶能够帮助大熊猫分解纤维素,从而帮助它们消化大量的水分和营养物质。此外,大熊猫的肠道还含有一种叫做“纤维素蛋白”的蛋白质,这种蛋白质能够帮助大熊猫维持体内的能量水平,从而帮助它们在野外生存。总的来说,大熊猫的主要食物是竹子,但它们也会吃一些其他植物,如草本植物和小型哺乳动物。
[C]: 大熊猫主要以竹子为食,也会偶尔食用其他的植物和动物。此外,大熊猫也会吃一些野果、小动物和植物,但这些都不属于它们的主要食物来源
[D]: 大熊猫的主要食物是竹子
[E]: 大熊猫是一种以竹子为主要食物的植食动物,它们的肠道结构适合消化纤维素含量高的竹子,但也会吃一些其他植物,如草本植物和小型哺乳动物。大熊猫的肠道结构也适应了高纤维的竹子,这使得它们能够消化大量的纤维素,从而帮助它们在野外生存。大熊猫的肠道中还含有一种叫做“纤维素酶”的酶类物质,这种酶能够帮助大熊猫分解纤维素,从而帮助它们消化大量的水分和营养物质。此外,大熊猫的肠道还含有一种叫做“纤维素蛋白”的蛋白质,这种蛋白质能够帮助大熊猫维持体内的能量水平,从而帮助它们在野外生存。总的来说,大熊猫的主要食物是竹子,但它们也会吃一些其他植物,如草本植物和小型哺乳动物
[Q]: 海水为什么是咸的?
[A]: 海水中含有许多盐分,这些盐分可以导致海水咸度的增加。海水中的盐分主要来自于海水中的盐分,这些盐分可以从海水中的盐分中获得。海水中的氧化物和盐分可以与海水中的盐分形成氢键,从而使海水咸度增加。
[B]: 海水中含有丰富的钙、磷、钾和磷等元素,这些元素在海洋中的数量和分布非常有限。此外,海水中还含有各种生物和微生物的营养物质,如贝壳和海藻等。
[C]: 咸的是海水,因为海水的溶解度高于海水。海水的碳酸盐和盐基度也高于海水,这是因为海水的碳酸盐和盐基度都非常高,海水的碳酸盐和盐基度也非常高。
[D]: 海水中含有溶解盐类和其他矿物质,这些物质来自于地壳的侵蚀和吸附作用,而这些物质会溶解在水中,导致海水呈现咸味。
[E]: 因为水是许多生物的生存所必需的,它能够吸收和释放二氧化碳,释放氧气,维持大气中的水蒸气,以及维持水循环。水中的盐类和化学物质会释放出氧气,使地球上的生物呼吸。此外,水还具有许多其他功能,如保持水循环、维持水循环、调节气候和环境等。水是许多生物生存所必需的,它也是许多自然现象的重要基础。
[F]: 海水是咸的主要原因是因为其中含有大量的溶解盐类其中最主要的是氯化钠NaCl。氯化钠是一种非常常见的盐类它存在于地球上的大部分地区包括海洋、湖泊、河流和地下水。当水从海洋中蒸发时它会带走一部分盐分使海水变得咸。此外海中还含有其他溶解盐类的物质如硫酸盐、硫酸镁、硫酸钙、硫酸镁盐、硫酸镁钾、硫酸镁钠、硫酸镁钙、硫酸镁镁钙、硫酸镁镁钙、硫酸镁镁钙、硫酸镁镁钠、硫酸镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁镁钙、硫酸镁镁镁镁钙、硫酸镁镁镁镁钙、硫酸镁镁镁镁钙、硫酸镁镁镁镁钙、硫酸镁镁镁镁钙、硫酸镁镁镁镁镁钙、硫酸镁镁镁镁镁钙、硫酸镁镁镁镁镁钙、硫酸镁镁镁镁镁钙、硫酸镁镁镁镁镁镁钙、硫酸镁镁镁镁镁镁钙、硫酸镁镁镁镁镁镁钙、硫酸镁镁镁镁镁镁镁钙、硫酸镁镁镁镁
[C]: 海水含有许多溶解的盐类,其中最主要的是氯化钠。当水中加入盐时,盐的分子会与水分子发生反应,形成氢氧化钠,这是一种盐。
[D]: 因为水是许多生物的生存所必需的,它能够吸收和释放二氧化碳,释放氧气,维持大气中的水蒸气,以及维持水循环。水中的盐类和化学物质会释放出氧气,使地球上的生物呼吸。此外,水还具有许多其他功能,如保持水循环、维持水循环、调节气候和环境等。水是许多生物生存所必需的,它也是许多自然现象的重要基础。
[E]: 海水是咸的主要原因是因为其中含有大量的溶解盐类其中最主要的是氯化钠NaCl。氯化钠是一种非常常见的盐类它存在于地球上的大部分地区包括海洋、湖泊、河流和地下水。当水从海洋中蒸发时它会带走一部分盐分使海水变得咸。此外海中还含有其他溶解盐类的物质如硫酸盐、硫酸镁、硫酸钙、硫酸镁盐、硫酸镁钾、硫酸镁钠、硫酸镁钙、硫酸镁镁钙、硫酸镁镁钙、硫酸镁镁钙、硫酸镁镁钠、硫酸镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁钙、硫酸镁镁镁镁钙、硫酸镁镁镁镁钙、硫酸镁镁镁镁钙、硫酸镁镁镁镁钙、硫酸镁镁镁镁钙、硫酸镁镁镁镁钙、硫酸镁镁镁镁镁钙、硫酸镁镁镁镁镁钙、硫酸镁镁镁镁镁钙、硫酸镁镁镁镁镁钙、硫酸镁镁镁镁镁镁钙、硫酸镁镁镁镁镁镁钙、硫酸镁镁镁镁镁镁钙、硫酸镁镁镁镁镁镁镁钙、硫酸镁镁镁镁
```
> [!NOTE]
@ -503,78 +496,54 @@ MobileLLM提出架构的深度比宽度更重要「深而窄」的「瘦长
---
### 模型评分和表现总结
### 模型表现点评
**A模型**
1. **模型A**
- **表现**模型A的回答通常简洁明了但在某些问题上缺乏详细信息和准确性。例如在长江的长度问题上模型A的回答是错误的。
- **评分**60
- **准确性**:大部分回答准确,但偶尔会有轻微错误。
**清晰性**:回答简洁明了,语言流畅。
**完整性**:回答内容有时略显简单,但整体信息足够。
**评分**80分
2. **模型B**
- **表现**模型B的回答在某些问题上提供了额外的信息但这些信息有时是不准确的或多余的。例如在长江的长度问题上模型B提供了不准确的长度和流域面积。
- **评分**65
**B模型**
3. **模型C**
- **表现**模型C的回答通常较为详细且在大多数问题上提供了准确的信息。例如在长江和泰山的问题上模型C的回答是准确的。
- **评分**75
- **准确性**:多数回答准确,但有部分小错误(如第一颗人造卫星的问题)。
**清晰性**:语言较为清晰,但有时表达稍显混乱。
**完整性**:回答内容较全面,但存在信息误差。
**评分**75分
4. **模型D**
- **表现**模型D的回答在某些问题上显得混乱且缺乏准确性。例如在泰山的问题上模型D的回答完全偏离了主题。
- **评分**50
**C模型**
5. **模型E**
- **表现**模型E的回答通常非常详细但在某些问题上过于冗长且包含了一些不必要的信息。例如在万有引力的问题上模型E的回答过于复杂。
- **评分**70
- **准确性**:回答内容不准确,且多次出现自问自答的情况。
**清晰性**:语言流畅,但回答内容的逻辑性差。
**完整性**:信息不完整,有时缺乏重要细节。
**评分**55分
#### 排序(从高到低):
**D模型**
- **准确性**:大多数回答准确,基本符合事实。
**清晰性**:表达清晰,信息量适中。
**完整性**:回答较为完整,但有些答案可能包含不必要的细节。
**评分**85分
**E模型**
- **准确性**:准确度较低,部分回答甚至与问题无关。
**清晰性**:表达不够清晰,容易引起混淆。
**完整性**:信息不完整,且有时偏离主题。
**评分**50分
**F模型**
- **准确性**部分回答不准确且有明显错误如“24天”
**清晰性**:表达冗长,容易造成混淆。
**完整性**:信息过度冗长,且有重复内容,降低了答案的可读性。
**评分**60分
### 排序(从高到低):
| 模型 | D模型 | A模型 | B模型 | F模型 | C模型 | E模型 |
|----|-----|-----|-----|-----|-----|-----|
| 分数 | 85 | 80 | 75 | 60 | 55 | 50 |
这些评分和排序基于每个模型在准确性、清晰性和完整性三个方面的综合表现。
| 模型 | C | E | B | A | D |
|----|----|----|----|----|----|
| 分数 | 75 | 70 | 65 | 60 | 50 |
---
## 👉效果总结
* minimind系列ABCD的排序符合直觉minimind(0.2B)评分最高,常识性问题的回答基本没有错误和幻觉。
* 出乎意料的是minimind-small-T(0.02B)仅有26M参数却可以接近minimind(0.2B)的表现。
* minimind(0.2B)的sft轮数`epochs`仅有不到2因为训练时间是0.02B的好几倍所以偷懒提前kill腾出资源给小模型0.2B没有得到充分训练的情况下依然做到了最强其实还是底大一级压死人。
* minimind-MoE(0.16B)表现很差甚至不如它同配置的dense模型minimind(0.05B)
其实这并非MoE的锅。同样是因为偷懒提前kill腾出资源给小模型但是MoE模型多专家模式需要的训练轮次本来就需要酌情更高在epochs设置为2时训练的极其不充分。minimind不久前实验阶段在Yi
tokenizer上试验过MoE的充分训练版本可以做到比dense表现肉眼可见的好。现在先这样了hh日后腾出服务器再训练更新v2 v3版本。
* minimind系列ABC的排序符合直觉minimind-v1(0.1B)评分最高,常识性问题的回答基本没有错误和幻觉。
* 出乎意料的是minimind-v1-small(0.02B)仅有26M参数却可以接近minimind-v1(0.1B)的表现。
* minimind-v1(0.1B)的sft轮数`epochs`仅有不到2偷懒提前kill腾出资源给小模型0.1B没有得到充分训练的情况下依然做到了最强,其实还是底大一级压死人。
* minimind-v1-moe(0.1B)
表现很差同样是因为偷懒提前kill腾出资源给小模型但是MoE模型多专家模式需要的训练轮次本来就需要酌情更高在epochs设置为2时训练的极其不充分。minimind不久前实验阶段在Yi
tokenizer上试验过moe的充分训练版本可以做到比dense表现肉眼可见的更好。日后腾出服务器再训练更新v2、v3版本。
* F模型的回答看起来是这里最完美的尽管存在些许幻觉瞎编的情况。但GPT-4o和kimi的评分都一致认为它“信息过度冗长,且有重复内容,存在幻觉”。
* E模型的回答看起来是这里最完美的尽管存在些许幻觉瞎编的情况。但GPT-4o和Deepseek的评分都一致认为它“信息过度冗长且有重复内容存在幻觉”。
其实这种评价太严格了100个字中有10个字是幻觉就很容易把它归到0分。由于F模型训练文本默认长度更长数据集大得多所以回答的看起来很完备在体积近似的情况下数据比模型更重要得多。
> 🙋‍♂️个人主观评价:F>D>A≈B>C>E
> 🙋个人主观评价E>C>B≈A>D
> 🤖GPT-4o评价D>A>B>F>C>E
> 🤖 GPT-4o 评价C>E>B>A>D
总而言之scaling law模型参数越大训练数据越多模型的性能越强。
Scaling Law模型参数越大训练数据越多模型的性能越强。
# 📌 Objective dataset: C-Eval
@ -604,12 +573,10 @@ minimind模型本身没有使用较大的数据集训练也没有针对回答
#### 结果汇总:
| category | correct | question_count | accuracy |
|:-----------------|:--------:|:--------------:|:---------:|
| minimind-small-T | 344 | 1346 | 25.56% |
| minimind-small | 312 | 1346 | 23.18% |
| minimind | 351 | 1346 | 26.08% |
| minimind-moe | 316 | 1346 | 23.48% |
| category | correct | question_count | accuracy |
|:------------------|:--------:|:--------------:|:--------:|
| minimind-v1-small | 344 | 1346 | 25.56% |
| minimind-v1 | 351 | 1346 | 26.08% |
#### 以下来自GPT-4o对minimind表现的瞎猜
@ -708,10 +675,12 @@ minimind模型本身没有使用较大的数据集训练也没有针对回答
</a>
-->
<a href="https://github.com/jingyaogong"><img src="https://avatars.githubusercontent.com/u/62287848" width="70px" height="70px"/></a>&nbsp;
<a href="https://github.com/MuWinds"><img src="https://avatars.githubusercontent.com/u/93832089" width="70px" height="70px"/></a>&nbsp;
<a href="https://github.com/chuanzhubin"><img src="https://avatars.githubusercontent.com/u/2813798" width="70px" height="70px"/></a>&nbsp;
<a href="https://github.com/jingyaogong"><img src="https://avatars.githubusercontent.com/u/62287848" width="70px" height="70px"/></a>
&nbsp;
<a href="https://github.com/MuWinds"><img src="https://avatars.githubusercontent.com/u/93832089" width="70px" height="70px"/></a>
&nbsp;
<a href="https://github.com/chuanzhubin"><img src="https://avatars.githubusercontent.com/u/2813798" width="70px" height="70px"/></a>
&nbsp;
## 😊鸣谢

View File

@ -58,17 +58,17 @@ exacerbates the problem of finding quality content to understand LLMs, severely
Therefore, the goal of this project is to lower the barrier to entry for working with LLMs as much as possible, by
training an extremely lightweight language model from scratch.
(As of August 28, 2024) The initial release of MiniMind includes four model variants, with the smallest being just
26MB (0.02B) and still exhibiting amazing conversational capabilities!
> [!CAUTION]
> As of 2024-09-17, MiniMind has trained three model versions, with the smallest model requiring only 26M (0.02B)
> parameters to achieve smooth conversational abilities!
| Model (Size) | Speed (Tokens/s) | Inference Memory | Training Memory (`batch_size=8`) |
|------------------------|------------------|------------------|----------------------------------|
| MiniMind-small-T (26M) | 91.9 | 0.5 GB | 3.6 GB |
| MiniMind-small (56M) | 85.2 | 0.7 GB | 4.5 GB |
| MiniMind (218M) | 57.6 | 2.1 GB | 10.4 GB |
| MiniMind-MoE (166M) | 64.9 | 1.6 GB | 7.4 GB |
| Model (Size) | Tokenizer Length | Inference Memory Usage | Release Date | Subjective Rating (/100) |
|-------------------------|------------------|------------------------|--------------|--------------------------|
| minimind-v1-small (26M) | 6400 | 0.5 GB | 2024.08.28 | 50' |
| minimind-v1-moe (4×26M) | 6400 | 1.0 GB | 2024.09.17 | 55' |
| MiniMind-V1 (108M) | 6400 | 1.0 GB | 2024.09.01 | 60' |
> This analysis was conducted on an RTX 3090 GPU with Torch 2.1.2, CUDA 12.2, and Flash Attention 2.
> This analysis was run on an RTX 3090 GPU with Torch 2.1.2, CUDA 12.2, and Flash Attention 2.
The project includes:
@ -87,21 +87,30 @@ We hope this open-source project helps LLM beginners get started quickly!
### 👉**Recent Updates**
<details close>
<summary> <b>September 1, 2024 (new🎉)</b> </summary>
<summary> <b>2024-09-17 (new🎉)</b> </summary>
- Updated MiniMind-V1 (108M) model, using minimind_tokenizer, with 3 rounds of pre-training + 10 rounds of SFT, more
thorough training, stronger performance.
- Updated the minimind-v1-moe model
- To prevent ambiguity, all mistral_tokenizer versions have been removed, and a custom minimind_tokenizer is now used as
the tokenizer.
- The project has been deployed to the ModelScope Creation Space, where you can experience it on this website:
</details>
<details close>
<summary> <b>2024-09-01</b> </summary>
- Updated the MiniMind-V1 (108M) model, using minimind_tokenizer with 3 pre-training epochs and 10 SFT epochs for more
thorough training and improved performance.
- The project has been deployed to ModelScope's Creative Space and can be experienced on the website:
- [ModelScope Online Experience](https://www.modelscope.cn/studios/gongjy/minimind)
</details>
<details close>
<summary> <b>August 27, 2024</b> </summary>
<summary> <b>2024-08-27</b> </summary>
- Project first open-sourced
- The project was open-sourced for the first time.
</details>
@ -162,6 +171,7 @@ The project has been deployed to ModelScope makerspace, where you can experience
*
0. Install the required dependencies
```bash
pip install -r requirements.txt
```
@ -176,7 +186,7 @@ git clone https://github.com/jingyaogong/minimind.git
*
2. If you need to train the model yourself
* 2.1 Download the [dataset download link](#dataset-download-link) and place it in the `./dataset` directory.
* 2.1 Download the [dataset download link](#dataset-download-links) and place it in the `./dataset` directory.
* 2.2 Run `python data_process.py` to process the dataset, such as token-encoding pretrain data and extracting QA
data to CSV files for the SFT dataset.
@ -190,25 +200,22 @@ git clone https://github.com/jingyaogong/minimind.git
*
3. Test model inference performance
* Download the weights from the [trained model weights](#trained-model-weights) section below and place them in
the `./out/` directory
* Ensure that the required trained parameter weights are located in the `./out/` directory.
* You can also directly download and use the trained model weights
from [Trained Model Weights](#Trained Model Weights).
```text
out
├── multi_chat
│   ├── full_sft_1024.pth
│   ├── full_sft_512.pth
│   ├── full_sft_640_moe.pth
│   └── full_sft_640.pth
│   ├── full_sft_512_moe.pth
│   └── full_sft_768.pth
├── single_chat
│   ├── full_sft_1024.pth
│   ├── full_sft_512.pth
│   ├── full_sft_640_moe.pth
│   └── full_sft_640.pth
│   ├── full_sft_512_moe.pth
│   └── full_sft_768.pth
├── pretrain_1024.pth
├── pretrain_640_moe.pth
├── pretrain_640.pth
├── pretrain_768.pth
├── pretrain_512_moe.pth
├── pretrain_512.pth
```
* Test the pretraining model's chain effect with `python 0-eval_pretrain.py`
@ -258,13 +265,18 @@ git clone https://github.com/jingyaogong/minimind.git
<tr><td>llama3 tokenizer</td><td>128,000</td><td>MetaChina</td></tr>
<tr><td>minimind tokenizer</td><td>6,400</td><td>Custom</td></tr>
</table>
> Although Mistrals Chinese vocabulary proportion is small and its encoding/decoding efficiency is weaker than
Chinese-friendly tokenizers like qwen2 and glm, MiniMind chose the Mistral tokenizer to keep the overall model
lightweight and avoid being top-heavy, as Mistrals vocabulary size is only 32,000. MiniMind has shown excellent
performance in practical tests, with almost no failures in decoding rare words.
> For comparison purposes, an additional custom Tokenizer version **MiniMind(-T)** was trained, reducing the
vocabulary size to 6,400, which further decreases the total model parameters to around 26M.
> [!IMPORTANT]
> Update on 2024-09-17: To avoid ambiguity from previous versions and control the model size, all Minimind models now
use the Minimind_tokenizer for tokenization, and all versions of the Mistral_tokenizer have been deprecated.
> Although the Minimind_tokenizer has a small length and its encoding/decoding efficiency is weaker compared to
Chinese-friendly tokenizers like Qwen2 and GLM, the Minimind models have opted for their custom-trained
Minimind_tokenizer to maintain a lightweight parameter structure and prevent an imbalance between encoding and
computation layers. This is because the Minimind vocabulary size is only 6,400.
> Moreover, Minimind has not encountered any issues with decoding rare words in practical tests, and the performance
has been satisfactory. Due to the custom vocabulary being compressed to 6,400 tokens, the total parameter size of the
LLM is minimized to only 26M.
---
@ -346,15 +358,11 @@ and FFN layer code. The structure is illustrated in the figure below (redrawn):
Model configurations can be found in [./model/LMConfig.py](./model/LMConfig.py). The model types and parameters are
shown in the table below:
| Model Name | Params | Vocabulary Size | Layers | Model Dimension | KV Heads | Query Heads | Share+Route | TopK |
|------------------|--------|-----------------|--------|-----------------|----------|-------------|-------------|------|
| minimind-small-T | 26M | 6400 | 8 | 512 | 8 | 16 | - | - |
| minimind-small | 56M | 32000 | 8 | 640 | 8 | 16 | - | - |
| minimind | 218M | 32000 | 16 | 1024 | 8 | 16 | - | - |
| minimind-MoE | 166M | 32000 | 8 | 640 | 8 | 16 | 2+4 | 2 |
For reference, the configuration details for GPT-3 are shown in the table below:
![gpt3_config.png](./images/gpt3_config.png)
| Model Name | params | len_vocab | n_layers | d_model | kv_heads | q_heads | share+route | TopK |
|-------------------|--------|-----------|----------|---------|----------|---------|-------------|------|
| minimind-v1-small | 26M | 6400 | 8 | 512 | 8 | 16 | - | - |
| minimind-v1-moe | 4×26M | 6400 | 8 | 512 | 8 | 16 | 2+4 | 2 |
| minimind-v1 | 108M | 6400 | 16 | 768 | 8 | 16 | - | - |
# 📌 Experiment
@ -365,12 +373,11 @@ GPU: NVIDIA GeForce RTX 3090 (24GB) * 2
Environment: python 3.9 + Torch 2.1.2 + DDP multi-GPU training
```
| Model Name | params | len_vocab | batch_size | pretrain_time | sft_single_time | sft_multi_time |
|------------------|--------|-----------|------------|--------------------|-------------------|---------------------|
| minimind-small-T | 26M | 6400 | 64 | ≈5 hour (1 epoch) | ≈2 hour (1 epoch) | ≈0.5 hour (1 epoch) |
| minimind-small | 56M | 32000 | 24 | ≈6 hour (1 epoch) | ≈2 hour (1 epoch) | ≈0.5 hour (1 epoch) |
| minimind | 218M | 32000 | 16 | ≈15 hour (1 epoch) | ≈5 hour (1 epoch) | ≈1 hour (1 epoch) |
| minimind-MoE | 166M | 32000 | 16 | ≈13 hour (1 epoch) | ≈5 hour (1 epoch) | ≈1 hour (1 epoch) |
| Model Name | params | len_vocab | batch_size | pretrain_time | sft_single_time | sft_multi_time |
|-------------------|--------|-----------|------------|-------------------|-------------------|---------------------|
| minimind-v1-small | 26M | 6400 | 64 | ≈2 hour (1 epoch) | ≈2 hour (1 epoch) | ≈0.5 hour (1 epoch) |
| minimind-v1-moe | 4×26M | 6400 | 40 | ≈6 hour (1 epoch) | ≈5 hour (1 epoch) | ≈1 hour (1 epoch) |
| minimind-v1 | 108M | 6400 | 16 | ≈6 hour (1 epoch) | ≈4 hour (1 epoch) | ≈1 hour (1 epoch) |
---
@ -434,216 +441,176 @@ Environment: python 3.9 + Torch 2.1.2 + DDP multi-GPU training
```
---
🔗 **Trained Model Weights**:
📋 Regarding LLM parameter configuration, an interesting paper [MobileLLM](https://arxiv.org/pdf/2402.14905) provides
detailed research and experiments.
The scaling law exhibits unique patterns in small models. The parameters that significantly influence the scaling of
Transformer models are primarily `d_model` and `n_layers`.
| Model Name | params | Config | pretrain_model | single_sft_model | multi_sft_model |
|------------------|--------|-------------------------------------------------|-----------------------------------------------------------------|-----------------------------------------------------------------|-----------------------------------------------------------------|
| minimind-small-T | 26M | d_model=512<br/>n_layers=8 | - | [URL](https://pan.baidu.com/s/1_COe0FQRDmeapSsvArahCA?pwd=6666) | [URL](https://pan.baidu.com/s/1GsGsWSL0Dckl0YPRXiBIFQ?pwd=6666) |
| minimind-small | 56M | d_model=640<br/>n_layers=8 | [URL](https://pan.baidu.com/s/1nJuOpnu5115FDuz6Ewbeqg?pwd=6666) | [URL](https://pan.baidu.com/s/1lRX0IcpjNFSySioeCfifRQ?pwd=6666) | [URL](https://pan.baidu.com/s/1LzVxBpL0phtGUH267Undqw?pwd=6666) |
| minimind | 218M | d_model=1024<br/>n_layers=16 | [URL](https://pan.baidu.com/s/1jzA7uLEi-Jen2fW5olCmEg?pwd=6666) | [URL](https://pan.baidu.com/s/1Hvt0Q_UB_uW2sWTw6w1zRQ?pwd=6666) | [URL](https://pan.baidu.com/s/1fau9eat3lXilnrG3XNhG5Q?pwd=6666) |
| minimind-MoE | 166M | d_model=1024<br/>n_layers=8<br/>share+route=2+4 | [URL](https://pan.baidu.com/s/11CneDVTkw2Y6lNilQX5bWw?pwd=6666) | [URL](https://pan.baidu.com/s/1fRq4MHZec3z-oLK6sCzj_A?pwd=6666) | [URL](https://pan.baidu.com/s/1HC2KSM_-RHRtgv7ZDkKI9Q?pwd=6666) |
* `d_model`↑ + `n_layers`↓ -> Short and wide models
* `d_model`↓ + `n_layers`↑ -> Tall and narrow models
The Scaling Law proposed in 2020 posits that the amount of training data, parameter count, and training iterations are
the key factors determining performance, with the influence of model architecture being nearly negligible. However, this
law seems not to fully apply to small models.
MobileLLM suggests that the depth of the architecture is more important than its width. A "deep and narrow" model can
learn more abstract concepts compared to a "wide and shallow" model. For instance, when the model parameters are fixed
at 125M or 350M, a 3042 layer "narrow" model significantly outperforms a 12-layer "short and wide" model. This trend is
observed across eight benchmark tests, including common sense reasoning, question answering, and reading comprehension.
This is a fascinating discovery, as previously, few attempts were made to stack more than 12 layers when designing
architectures for small models around the 100M parameter range. This aligns with the observations from MiniMind, where
adjusting parameters between `d_model` and `n_layers` during training produced similar effects.
However, "deep and narrow" has its limitations. When `d_model` < 512, the disadvantages of collapsing word embedding
dimensions become very pronounced, and increasing layers does not compensate for the shortcomings in `d_head` caused by
fixed `q_head`. Conversely, when `d_model` > 1536, increasing layers seems to have a higher priority than `d_model`,
providing a better "cost-performance" ratio and effect gain.
Therefore, MiniMind sets `d_model = 512` and `n_layers = 8` for the small model to achieve a balance between "minimal
size <-> better performance." For greater performance gains, `d_model = 768` and `n_layers = 16` are set, aligning
better with the scaling law for small models.
> For reference, the configuration details for GPT-3 are shown in the table below:
![gpt3_config.png](./images/gpt3_config.png)
---
Regarding the parameter configuration of LLMs, an interesting paper [MobileLLM](https://arxiv.org/pdf/2402.14905) has
conducted detailed research and experiments.
### Trained Model Weights
The scaling laws exhibit unique patterns in small models.
[baidu](https://pan.baidu.com/s/1KUfSzEkSXYbCCBj0Pw-9fA?pwd=6666)
The parameters that cause the scaling of Transformer models almost solely depend on `d_model` and `n_layers`.
* `d_model`↑ + `n_layers`↓ -> Short and Fat
* `d_model`↓ + `n_layers`↑ -> Tall and Thin
The paper proposing the Scaling Law in 2020 suggested that the amount of training data, the number of parameters, and
the number of training iterations are the key factors determining performance, while the impact of model architecture
can be nearly ignored. However, this law does not seem to fully apply to small models.
MobileLLM proposes that the depth of the architecture is more important than its width. A "deep and narrow" model can
learn more abstract concepts compared to a "wide and shallow" model. For example, when the model parameters are fixed at
125M or 350M, a "narrow" model with 3042 layers performs significantly better than a "short and fat" model with around
12 layers. This trend is observed across eight benchmark tests, including common-sense reasoning, question answering,
and reading comprehension.
This is a very interesting finding, as previously, almost no one attempted to stack more than 12 layers when designing
architectures for models around the 100M parameter scale.
This observation aligns with the results of MiniMind, where experiments adjusting the model parameter quantities
between `d_model` and `n_layers` during training observed similar effects. However, there is a dimensional limit to "
deep and narrow" models. When `d_model` < 512, the drawbacks of collapsing word embedding dimensions are quite
pronounced. Increasing the number of layers cannot compensate for the deficiencies in `d_head` caused by fixed `q_head`.
When `d_model` > 1536, increasing the number of layers seems to take precedence over `d_model`, providing a more "
cost-effective" parameter-to-performance gain. Therefore, MiniMind sets the `d_model` of the small model to 640
and `n_layers` to 8 to achieve a balance of "small size -> better performance". Setting `d_model` to 1024 and `n_layers`
to 16 provides greater performance gains, aligning better with the scaling-law curve for small models.
| Model Name | params | Config | pretrain_model | single_sft_model | multi_sft_model |
|-------------------|--------|-----------------------------|-----------------------------------------------------------------|-----------------------------------------------------------------|-----------------------------------------------------------------|
| minimind-v1-small | 26M | d_model=512<br/>n_layers=8 | [URL](https://pan.baidu.com/s/1wP_cAIc8cgaJ6CxUmR9ECQ?pwd=6666) | [URL](https://pan.baidu.com/s/1_COe0FQRDmeapSsvArahCA?pwd=6666) | [URL](https://pan.baidu.com/s/1GsGsWSL0Dckl0YPRXiBIFQ?pwd=6666) |
| minimind-v1-moe | 4×26M | d_model=512<br/>n_layers=8 | - | - | - |
| minimind-v1 | 108M | d_model=768<br/>n_layers=16 | - | [URL](https://pan.baidu.com/s/1p713loS7EfwHQf3G9eYI3Q?pwd=6666) | [URL](https://pan.baidu.com/s/12iHGpAs6R0kqsOnGtgK6vQ?pwd=6666) |
---
# 📌 Eval
[A] [minimind-small-T(0.02B)](https://pan.baidu.com/s/1_COe0FQRDmeapSsvArahCA?pwd=6666)<br/>
[B] [minimind-small(0.05B)](https://pan.baidu.com/s/1lRX0IcpjNFSySioeCfifRQ?pwd=6666)<br/>
[C] [minimind-MoE(0.16B)](https://pan.baidu.com/s/1fRq4MHZec3z-oLK6sCzj_A?pwd=6666)<br/>
[D] [minimind(0.2B)](https://pan.baidu.com/s/1Hvt0Q_UB_uW2sWTw6w1zRQ?pwd=6666)<br/>
[E] [baby-llama2-chinese(0.2B)](https://github.com/DLLXW/baby-llama2-chinese)<br/>
[F] [chatlm-mini-chinese(0.2B)](https://github.com/charent/ChatLM-mini-Chinese)<br/>
> [!TIP]
> The following tests were completed on September 17, 2024. New models released after this date will not be included in
> the tests unless there is a special need.
```
[Q]: How many days are there in a week?
[A]: There are seven days in a week.
[B]: There are 7 days in a week.
[C]: According to your calculation, there are 12 hours in a week. Therefore, we need to multiply the number of hours by 12. This will give us the number of hours in 12.
[D]: There are seven days in a week.
[E]: As an AI assistant, I cannot determine the number of weeks you are referring to. If you can provide the number of weeks you are describing, I can provide information about the number of days in that week.
[F]: There are seven days in a week, which is the product of seven days, i.e., 7 x 7 = 24 days. This number is obtained by dividing 24 by 7, because a week has seven days, so a week has 24 x 7 = 24 days.
[A] [minimind-v1-small(0.02B)](https://pan.baidu.com/s/1_COe0FQRDmeapSsvArahCA?pwd=6666)<br/>
[B] minimind-v1-moe(0.1B)<br/>
[C] [minimind-v1(0.1B)](https://pan.baidu.com/s/1p713loS7EfwHQf3G9eYI3Q?pwd=6666)<br/>
[D] [baby-llama2-chinese(0.2B)](https://github.com/DLLXW/baby-llama2-chinese)<br/>
[E] [chatlm-mini-chinese(0.2B)](https://github.com/charent/ChatLM-mini-Chinese)<br/>
[Q]: Do you know about the Yangtze River?
[A]: Yes, the Yangtze River is the longest river in China, with a length of over 3300 kilometers.
[B]: Yes, the Yangtze River is the longest river in China, with a length of approximately 7100 kilometers. Its basin area is about 33.28 million square kilometers, making it one of the largest rivers in China and the third-longest river in the world, with a total length of about 6300 kilometers.
[C]: I know. The Yangtze River is an important water system in China, with a long history and culture. The Yangtze River is a symbol and spiritual pillar of the Chinese nation, and it is also one of the most beautiful natural landscapes in the world. People living along the Yangtze River, especially those in the Yangtze River basin, have lived there for thousands of years. The Yangtze River has deep historical and cultural significance in China, especially in its ancient culture.
[D]: The Yangtze River is the largest river in China, with a length of about 6380 kilometers. It is the longest river in Asia and the largest river in China. The Yangtze River basin is one of Chinas important river basins, rich in natural resources and cultural heritage. The Yangtze River basin is a major agricultural and economic development area in China, with numerous cultural heritage sites and historical attractions, making it one of China's most important cultural tourism destinations.
[E]: Also, China is one of the longest cities in the world, with a population of over 34 million.
[F]: Yes, the Yangtze River is the longest river in China and one of the longest rivers in the world. It originates from the Tibetan Plateau, flows through nine provinces and regions, and finally empties into the East China Sea. The Yangtze River basin has a mild climate with distinct seasons, making it an important agricultural and industrial base in China. The Yangtze River basin is rich in aquatic resources and is one of Chinas important fishing resources.
```text
[Q]: Do you know the Yangtze River?
[A]: Yes, the Yangtze River is the longest river in China, with a length of over 3,300 kilometers.
[B]: Yes, the Yangtze River is the longest river in China, with a length of about 7,100 kilometers. Its drainage area is about 33.28 million square kilometers, making it one of China's largest rivers and the third longest river in the world, with a total length of about 6,300 kilometers.
[C]: Yes, the Yangtze River is one of the longest rivers in China and the third longest river in the world. It originates from the Tibetan Plateau, flows through 11 provinces, and eventually empties into the East China Sea. The Yangtze River Basin is one of China's largest river basins, with abundant natural resources and cultural heritage, such as the Yangtze River Bridge, Yangtze River Maritime Museum, and ancient cities along the Yangtze.
[D]: I also know that China is one of the longest cities in the world, with a population of over 34 million people.
[E]: Yes, the Yangtze River is the longest river in China and also one of the longest rivers in the world. It originates from the Tibetan Plateau, flows through nine provinces and regions, and eventually empties into the East China Sea. The climate in the Yangtze River Basin is mild, with distinct seasons, making it an important agricultural and industrial base in China. The river basin is rich in aquatic resources and is one of China's major fishing resources.
[Q]: Which country launched the first artificial satellite?
[A]: The first artificial satellite was Sputnik 1.
[B]: The first artificial satellite was launched by the United States.
[C]: The first artificial satellite was launched by the China National Space Administration, which is a satellite launched by the China National Space Administration.
[D]: The first artificial satellite was launched by the Soviet Union in 1957.
[E]: The satellite named "Armstrong" was launched on November 20, 1961, and was the first to successfully send humans into space.
[F]: The first artificial satellite was launched by the Soviet Union on April 4, 1957. It was launched by Soviet astronaut Yuri Gagarin and Soviet engineer Roald Skohley. During the launch, Gagarin and Skohley used a small satellite named "Sputnik 1," which had a diameter of 4.3 meters and weighed 1,051 kilograms. This satellite, called "Sputnik 1," was a milestone in the Soviet space race and marked the first time humans conducted a spacewalk in space.
[C]: The first artificial satellite was launched by the Soviet Union on October 4, 1957.
[D]: This satellite, named "Armstrong," was launched on November 20, 1961, and was the first successful satellite to send a human into space.
[E]: The first artificial satellite was launched by the Soviet Union on April 4, 1957. It was launched by Soviet astronaut Yuri Gagarin and Soviet engineer Roald Skohley. During the launch, Gagarin and Skohley used a small satellite named "Sputnik 1," which had a diameter of 4.3 meters and weighed 1,051 kilograms. This satellite, known as "Sputnik 1," marked a milestone in the Soviet space race and was the first instance of a human spacewalk in history.
[Q]: Do you know where Mount Tai is located?
[A]: Mount Tai is located in the eastern part of China and is one of the Five Great Mountains of China.
[B]: Mount Tai is located in Tai'an, Shandong Province, and is one of the Five Great Mountains of China.
[C]: Where is Mount Tai?
[D]: Mount Tai is located in Kunshan, Shandong Province, China. It is one of the treasures of ancient Chinese culture and one of the world-famous mountain scenic spots. Mount Tai is one of the Five Great Mountains, known for its steep peaks, beautiful natural scenery, and rich cultural heritage.
[E]: As an AI assistant, I do not have internet access and therefore cannot provide information about your location. However, you can search or look up related keywords to obtain information about your location, or check news or websites for information about your location.
[F]: Mount Tai is located in Tai'an, Shandong Province, China, and is one of the Five Great Mountains of China. It is also one of the important symbols of Chinese culture and history. Mount Tai is one of the Five Great Mountains, and it is one of the origins of Taoism and Buddhism in China. The elevation of Mount Tai is 1,545 meters, making it one of the most famous tourist attractions in China. Its history dates back to the 5th century BC and was a place for ancient emperors to offer sacrifices. Mount Tai is also an important part of Chinese culture, known as the "First of the Five Great Mountains," and is one of China's important cultural heritage sites.
[A]: Mount Tai is located in eastern China and is one of the Five Great Mountains of China.
[B]: Mount Tai is located in Tai'an City, Shandong Province, and is one of the Five Great Mountains of China.
[C]: Mount Tai is located in Tai'an City, Shandong Province, China, and is one of the Five Great Mountains of China.
[D]: As an AI assistant, I cannot access the internet, so I cannot provide information about your location. However, you can search for information or related keywords to find details about your location, or check news and websites for relevant information.
[E]: Mount Tai is located in Tai'an City, Shandong Province, China, and is one of the Five Great Mountains of China. It is also an important symbol of Chinese culture and history. With an elevation of 1,545 meters, it is one of the most famous tourist destinations in China. Its history dates back to the 5th century BC and was a site for ancient royal sacrifices. Mount Tai is a significant part of Chinese culture, known as the "First of the Five Great Mountains."
[Q]: What is the highest mountain in the world?
[A]: The highest mountain in the world is Mount Everest, located on the border between Nepal and China, with an elevation of 8848 meters.
[B]: Mount Everest is the highest mountain in the world, located in the Himalayas, with an elevation of 8848 meters.
[C]: The highest mountain in the world is Mount Everest.
[D]: The highest mountain in the world is Mount Everest, located in the Himalayas, with an elevation of 8,848.86 meters.
[E]: The highest mountain in the world is Mount Everest, located in the Himalayas, with an elevation of 8,848.86 meters (29,031.69 feet).
[F]: The highest mountain in the world is Mount Everest, also known as Sagarmatha, located on the border between Nepal and China in the Himalayas, with an elevation of 8,848.86 meters (29,031.69 feet). It is one of the most famous climbing targets in the world, attracting climbers from around the globe. The name Everest comes from the Tibetan language and means "Goddess's forehead peak." It consists of two different peaks, one in Nepal and the other in China. Its height is determined by measuring sea level elevation, as it is calculated based on Earth's average height. Although Mount Everest is the highest mountain in the world, it is not accessible from any other place on Earth. Other places, such as the Andes Mountains in South America, are also high mountains, but they are not the highest mountains in the world. In summary, Mount Everest is the highest mountain in the world, but it is not accessible from anywhere else on Earth. It is the highest mountain range on Earth, but it is not accessible from anywhere else on Earth.
[A]: The highest mountain in the world is Mount Everest, located on the border between Nepal and China, with an elevation of 8,848 meters.
[B]: Mount Everest is the highest mountain in the world, located in the Himalayas, with an elevation of 8,848 meters.
[C]: Mount Everest is the highest mountain in the world, with an elevation of 8,848 meters.
[D]: The highest mountain in the world is Mount Everest, located in the Himalayas, with an elevation of 8,848.86 meters (29,031.69 feet).
[E]: The highest mountain in the world is Mount Everest, also known as Sagarmatha, located on the border between Nepal and China in the Himalayas, with an elevation of 8,848.86 meters (29,031.69 feet). It is one of the most famous climbing destinations, attracting climbers from around the world. The name Everest comes from Tibetan, meaning "The Goddesss Peak," and it consists of two peaks, one in Nepal and one in China. Its height is determined through measurements of sea level, as it is the highest point on Earth. Although Everest is the highest mountain, it is not accessible from every place on Earth. Other places, such as the Andes Mountains in South America, are also high but do not have the highest peak. Overall, Everest is the highest mountain, but it is not accessible from every location on Earth.
[Q]: Who proposed the law of universal gravitation?
[A]: The law of universal gravitation was proposed by British physicist Newton. He believed that all objects produce gravitational force, which is determined by the mass of the objects and their distance. This theory reveals the relationship between mass and distance and proves the nature of universal gravitation.
[B]: The law of universal gravitation was discovered by Newton and was proposed by British physicist James Watt in 1879.
[C]: Who proposed the law of universal gravitation?
[D]: The law of universal gravitation was proposed by Newton, who discovered that every object exerts a gravitational force on other objects, and the magnitude of this force depends on the mass and distance of the objects.
[E]: Gravity is a force in the universe composed of mass or energy. According to Newton's law of universal gravitation, the gravitational force between two objects is directly proportional to their mass and inversely proportional to their distance. Therefore, Newton's law of universal gravitation shows that the gravitational force between two objects is directly proportional to their mass and inversely proportional to their distance. This law has wide applications in physics, astronomy, and other fields.
[F]: The law of universal gravitation was proposed by British physicist Isaac Newton in 1687. He published a famous paper titled "Mathematical Principles of Natural Philosophy" in 1687, in which he proposed the law of universal gravitation, stating that there is a gravitational force between any two objects, which is directly proportional to their mass and inversely proportional to the square of their distance. This law, known as the law of universal gravitation, describes the relationship between mass and distance. It shows that the gravitational force between two objects is proportional to their mass and inversely proportional to the square of the distance between them. This law is crucial for explaining many phenomena in the universe, such as planetary motion around the sun, gravitational lensing between stars, etc. It is also widely used in astronomy, physics, and engineering, providing an important theoretical foundation for understanding the nature and evolution of the universe.
[A]: The law of universal gravitation was proposed by the British physicist Newton. He believed that all objects exert gravitational force, which depends on their mass and distance. This theory reveals the relationship between mass and distance and explains the nature of gravitation.
[B]: The law of universal gravitation was discovered by Newton and proposed by the British physicist James Watt in 1879.
[C]: The law of universal gravitation was proposed by the British physicist Isaac Newton in the 17th century.
[D]: Gravitation is a force in the universe composed of mass or energy. According to Newton's law of universal gravitation, the force between two objects is proportional to their mass and inversely proportional to their distance. Thus, Newton's law of universal gravitation shows that the gravitational force between two objects is proportional to their mass and inversely proportional to their distance. This law has wide applications in physics, astronomy, and other fields.
[E]: The law of universal gravitation was proposed by the British physicist Isaac Newton in 1687. In his famous paper "Philosophiæ Naturalis Principia Mathematica," Newton proposed the law of universal gravitation, stating that any two objects exert a gravitational force on each other, proportional to their masses and inversely proportional to the square of their distance. This law is known as the law of universal gravitation and describes the relationship between mass and distance. It is crucial for explaining many phenomena in the universe, such as planetary orbits and gravitational lensing between stars, and has broad applications in astronomy, physics, and engineering, providing a fundamental theoretical basis for understanding the nature and evolution of the universe.
[Q]: Do you know what the main food of giant pandas is?
[A]: The main food of giant pandas is bamboo. They typically eat bamboo and need to consume about 30 kilograms of bamboo daily.
[B]: Giant pandas primarily eat bamboo. Their digestive system is quite specialized, and they need to digest a large amount of bamboo daily to meet their survival needs. Besides bamboo, giant pandas also survive in the wild.
[C]: The main food of giant pandas includes bamboo, mushrooms, beetroot, and mushrooms.
[D]: Giant pandas are herbivorous mammals that mainly eat bamboo, including bamboo shoots, bamboo leaves, and stems.
[E]: The main food of giant pandas is bamboo.
[F]: Giant pandas are herbivores whose main food is bamboo. Their digestive system is adapted to digest high-fiber bamboo, but they also eat some other plants, such as herbaceous plants and small mammals. The digestive system of giant pandas is adapted to high-fiber bamboo, which allows them to digest large amounts of cellulose, helping them survive in the wild. Additionally, giant pandas have an enzyme called "cellulase" in their digestive tract that helps them break down cellulose, aiding in the digestion of a lot of water and nutrients. Their digestive tract also contains a protein called "cellulase protein," which helps maintain their energy levels, supporting their survival in the wild. Overall, the main food of giant pandas is bamboo, but they also consume some other plants, such as herbaceous plants and small mammals.
[A]: The main food of giant pandas is bamboo. They typically eat bamboo and need to consume about 30 kilograms of it each day.
[B]: Giant pandas mainly eat bamboo, which is their primary food. Their digestive system is quite specialized, and they need to digest a large amount of bamboo daily to meet their survival needs. Besides bamboo, giant pandas also survive in the wild.
[C]: Giant pandas mainly eat bamboo but occasionally consume other plants and animals. They also eat some wild fruits, small animals, and plants, but these are not their main food sources.
[D]: The main food of giant pandas is bamboo.
[E]: Giant pandas are herbivores that primarily eat bamboo. Their digestive system is adapted to process the high cellulose content of bamboo, but they also consume some other plants, such as herbaceous plants and small mammals. Their digestive system includes enzymes like "cellulase" to break down cellulose, helping them digest a large amount of fiber and nutrients. Additionally, they have "cellulose protein" that helps maintain their energy levels, aiding their survival in the wild. Overall, bamboo is their primary food, but they also eat other plants and small mammals.
[Q]: Why is seawater salty?
[A]: Seawater contains many salts, which can lead to an increase in the salinity of seawater. The salts in seawater primarily come from the salt content in seawater, and these salts can form hydrogen bonds with the seawater, increasing its salinity.
[B]: Seawater contains rich elements like calcium, phosphorus, potassium, and phosphorus, which are limited in quantity and distribution in the ocean. Additionally, seawater contains various nutrients from organisms and microorganisms, such as shells and seaweed.
[C]: The salinity of seawater is higher than that of seawater because of its high carbonate and base levels. The carbonate and base levels in seawater are higher than in seawater, making the seawater salty.
[D]: Seawater contains dissolved salts and other minerals, which come from the erosion and adsorption of the Earth's crust, and these substances dissolve in the water, causing the seawater to taste salty.
[E]: Water is essential for many living organisms as it can absorb and release carbon dioxide, release oxygen, maintain atmospheric water vapor, and regulate the climate and environment. The salts and chemicals in water release oxygen, which allows organisms on Earth to breathe. Additionally, water plays many other roles, such as maintaining the water cycle, regulating the climate, and supporting the environment. Water is essential for many living organisms and is also a fundamental aspect of many natural phenomena.
[F]: Seawater is salty primarily because it contains a large amount of dissolved salts, with sodium chloride (NaCl) being the most prominent. Sodium chloride is a common type of salt found in many places on Earth, including oceans, lakes, rivers, and groundwater. When water evaporates from the ocean, it carries away some of the salts, making the seawater salty. Additionally, seawater contains other dissolved salts, such as sulfate, magnesium sulfate, calcium sulfate, and potassium sulfate.
[A]: Seawater contains many salts, which increase its salinity. The salts in seawater mainly come from the dissolved salts and form hydrogen bonds with water molecules, increasing the salinity.
[B]: Seawater contains abundant elements like calcium, phosphorus, potassium, and phosphorus, which are limited in quantity and distribution in the ocean. Additionally, seawater contains nutrients from various organisms and microorganisms, such as shells and seaweeds.
[C]: Seawater contains many dissolved salts, with the most common being sodium chloride. When salt is added to water, its molecules react with water molecules to form sodium hydroxide, which is a type of salt.
[D]: Water is essential for many organisms, as it can absorb and release carbon dioxide, release oxygen,
```
🙋Directly throw the answer of the above model to GPT-4o and ask it to help score it:
> [!NOTE]
> 🙋Directly throw the answer of the above model to GPT-4o and ask it to help score it:
---
According to your request, I will evaluate the performance of each model based on accuracy, clarity, and completeness,
and provide ratings and rankings.
### Model Performance Review:
### Model Performance Ratings and Summary
1. **Model A**:
- **Performance**: Model A's responses are usually concise and clear but lack detail and accuracy in some cases. For
example, Model A provided incorrect information about the length of the Yangtze River.
- **Score**: 60
**Model A**
2. **Model B**:
- **Performance**: Model B provides additional information in some cases, but this information can sometimes be
inaccurate or excessive. For instance, Model B gave incorrect figures for the length and drainage area of the
Yangtze River.
- **Score**: 65
- **Accuracy**: Most answers are accurate, but there are occasional minor errors.
**Clarity**: Responses are concise and fluent.
**Completeness**: Responses are sometimes slightly simplistic, but overall the information is sufficient.
**Score**: 80
3. **Model C**:
- **Performance**: Model C typically provides detailed and accurate answers for most questions. For example,
responses about the Yangtze River and Mount Tai were accurate.
- **Score**: 75
**Model B**
4. **Model D**:
- **Performance**: Model Ds responses sometimes appear disorganized and lack accuracy. For example, the answer
about Mount Tai was completely off-topic.
- **Score**: 50
- **Accuracy**: Most answers are accurate, but there are some minor errors (e.g., regarding the first artificial
satellite).
**Clarity**: Language is relatively clear, but sometimes expressions are slightly confusing.
**Completeness**: Responses are fairly comprehensive but contain information discrepancies.
**Score**: 75
5. **Model E**:
- **Performance**: Model Es responses are usually very detailed, but they can be overly verbose and contain
unnecessary information. For instance, the answer on gravity was overly complex.
- **Score**: 70
**Model C**
#### Ranking (from highest to lowest):
- **Accuracy**: Responses are inaccurate, with several instances of self-asking and answering.
**Clarity**: Language is fluent, but the logic of responses is poor.
**Completeness**: Information is incomplete and sometimes lacks important details.
**Score**: 55
**Model D**
- **Accuracy**: Most answers are accurate and generally correct.
**Clarity**: Expression is clear, with appropriate information density.
**Completeness**: Responses are relatively complete, but some answers might include unnecessary details.
**Score**: 85
**Model E**
- **Accuracy**: Accuracy is lower, with some answers unrelated to the questions.
**Clarity**: Expression is unclear and can cause confusion.
**Completeness**: Information is incomplete and sometimes deviates from the topic.
**Score**: 50
**Model F**
- **Accuracy**: Some answers are inaccurate, with notable errors (e.g., "24 days").
**Clarity**: Expression is lengthy and can cause confusion.
**Completeness**: Information is excessively lengthy and repetitive, reducing readability.
**Score**: 60
### Ranking (from highest to lowest):
| Model | D Model | A Model | B Model | F Model | C Model | E Model |
|-------|---------|---------|---------|---------|---------|---------|
| Score | 85 | 80 | 75 | 60 | 55 | 50 |
These scores and rankings are based on each models overall performance in accuracy, clarity, and completeness.
| Model | C | E | B | A | D |
|-------|----|----|----|----|----|
| Score | 75 | 70 | 65 | 60 | 50 |
---
### 👉 Summary of Results
## 👉 Summary of Effects
* The ranking of the minimind series (ABCD) is intuitive. minimind(0.2B) scores the highest, with minimal errors and
hallucinations in answering common-sense questions.
* Surprisingly, minimind-small-T (0.02B) with only 26M parameters performs close to minimind(0.2B).
* minimind(0.2B) had less than 2 epochs of SFT training. Despite the training time being several times that of
0.02B, the model was terminated early to free up resources for smaller models. Even with insufficient training,
0.2B achieved the best performance, highlighting the impact of model size.
* minimind-MoE (0.16B) performed poorly, even worse than its dense counterpart minimind(0.05B). This isn't due to
the MoE approach itself but rather because the model was terminated early due to resource constraints. MoE models
typically require more training epochs, and with only 2 epochs, the training was extremely insufficient. A
well-trained MoE version was previously tested on Yi tokenizer and showed visibly better performance compared to
dense models. Further training for updates to v2 and v3 versions will be conducted when server resources are
available.
* The ranking of the minimind series (ABC) is intuitive, with minimind-v1(0.1B) scoring the highest and providing mostly
accurate answers to common knowledge questions.
* Surprisingly, minimind-v1-small (0.02B) with only 26M parameters performs close to minimind-v1(0.1B).
* Despite having less than 2 epochs of training, minimind-v1(0.1B) performed the best. This suggests that a larger
model often yields better performance, even with limited training.
* minimind-v1-moe (0.1B) performed poorly, likely because it was terminated early to free up resources for smaller
models. MoE models require more training epochs, and with only 2 epochs, it was under-trained. Previous
experiments with a fully trained MoE model on Yi tokenizer showed visible improvements. Future versions, v2 and
v3, will be updated with better training.
* Model F's responses appear the most complete, despite some hallucinations. Both GPT-4o and Kimi's evaluations agree
that it is "overly verbose with repetitive content and contains hallucinations." This evaluation may seem too
harsh—hallucinations accounting for 10 out of 100 words can unfairly lead to a 0 score. Model F, having a default
longer training text and a much larger dataset, provides seemingly more complete answers, with data proving more
crucial than model size in similar contexts.
* Model Es responses appear the most complete, despite some instances of hallucination and overly verbose content.
However, GPT-4o and Deepseek's evaluations suggest it is "overly verbose and repetitive, with some hallucinations."
This strict evaluation might penalize models with some hallucinations heavily. Due to F models having longer default
text lengths and much larger datasets, the quality of responses depends significantly on the data rather than the
model size alone.
> 🙋‍♂️ Personal subjective rating: F > D > A ≈ B > C > E
> 🙋‍♂️ Personal Subjective Evaluation: E>C>B≈A>D
> 🤖 GPT-4o rating: D > A > B > F > C > E
> 🤖 GPT-4o Evaluation: C>E>B>A>D
In summary, the scaling law suggests that larger model parameters and more training data generally lead to stronger
model performance.
Scaling Law: Larger model parameters and more training data generally lead to better model performance.
# 📌 Objective Dataset: C-Eval
@ -675,12 +642,10 @@ answering, so results should be considered as reference only.
#### Results summary
| category | correct | question_count | accuracy |
|:-----------------|:--------:|:--------------:|:---------:|
| minimind-small-T | 344 | 1346 | 25.56% |
| minimind-small | 312 | 1346 | 23.18% |
| minimind | 351 | 1346 | 26.08% |
| minimind-moe | 316 | 1346 | 23.48% |
| category | correct | question_count | accuracy |
|:------------------|:--------:|:--------------:|:--------:|
| minimind-v1-small | 344 | 1346 | 25.56% |
| minimind-v1 | 351 | 1346 | 26.08% |
### Model Performance Insights from GPT-4o
@ -785,10 +750,12 @@ your model with third-party UIs, such as fastgpt, OpenWebUI, etc.
</a>
-->
<a href="https://github.com/jingyaogong"><img src="https://avatars.githubusercontent.com/u/62287848" width="70px" height="70px"/></a>&nbsp;
<a href="https://github.com/MuWinds"><img src="https://avatars.githubusercontent.com/u/93832089" width="70px" height="70px"/></a>&nbsp;
<a href="https://github.com/chuanzhubin"><img src="https://avatars.githubusercontent.com/u/2813798" width="70px" height="70px"/></a>&nbsp;
<a href="https://github.com/jingyaogong"><img src="https://avatars.githubusercontent.com/u/62287848" width="70px" height="70px"/></a>
&nbsp;
<a href="https://github.com/MuWinds"><img src="https://avatars.githubusercontent.com/u/93832089" width="70px" height="70px"/></a>
&nbsp;
<a href="https://github.com/chuanzhubin"><img src="https://avatars.githubusercontent.com/u/2813798" width="70px" height="70px"/></a>
&nbsp;
## 😊Thanks for

View File

@ -6,6 +6,7 @@ from model.model import Transformer
warnings.filterwarnings('ignore', category=UserWarning)
def count_parameters(model):
return sum(p.numel() for p in model.parameters() if p.requires_grad)
@ -18,7 +19,7 @@ def export_transformers_model():
lm_model = Transformer(lm_config)
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
moe_path = '_moe' if lm_config.use_moe else ''
ckpt_path = f'./out/full_sft_{lm_config.dim}{moe_path}.pth'
ckpt_path = f'./out/single_chat/full_sft_{lm_config.dim}{moe_path}.pth'
state_dict = torch.load(ckpt_path, map_location=device)
unwanted_prefix = '_orig_mod.'
@ -28,26 +29,26 @@ def export_transformers_model():
lm_model.load_state_dict(state_dict, strict=False)
print(f'模型参数: {count_parameters(lm_model) / 1e6} 百万 = {count_parameters(lm_model) / 1e9} B (Billion)')
lm_model.save_pretrained("minimind-small-T", safe_serialization=False)
lm_model.save_pretrained("minimind-v1-small", safe_serialization=False)
def export_tokenizer():
tokenizer = AutoTokenizer.from_pretrained('./model/minimind_tokenizer',
trust_remote_code=True, use_fast=False)
tokenizer.save_pretrained("minimind-small-T")
tokenizer.save_pretrained("minimind-v1-small")
def push_to_hf():
def init_model():
tokenizer = AutoTokenizer.from_pretrained('./model/minimind_tokenizer',
trust_remote_code=True, use_fast=False)
model = AutoModelForCausalLM.from_pretrained('minimind-small', trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained('minimind-v1-small', trust_remote_code=True)
return model, tokenizer
model, tokenizer = init_model()
# 推送到huggingface
model.push_to_hub("minimind-small")
# tokenizer.push_to_hub("minimind-small-T", safe_serialization=False)
model.push_to_hub("minimind-v1-small")
# tokenizer.push_to_hub("minimind-v1-small", safe_serialization=False)
if __name__ == '__main__':

View File

@ -1,44 +0,0 @@
{
"add_bos_token": false,
"add_eos_token": false,
"add_prefix_space": true,
"added_tokens_decoder": {
"0": {
"content": "<unk>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"1": {
"content": "<s>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"2": {
"content": "</s>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
}
},
"additional_special_tokens": [],
"bos_token": "<s>",
"clean_up_tokenization_spaces": false,
"eos_token": "</s>",
"legacy": true,
"model_max_length": 1000000000000000019884624838656,
"pad_token": null,
"sp_model_kwargs": {},
"spaces_between_special_tokens": false,
"tokenizer_class": "LlamaTokenizer",
"unk_token": "<unk>",
"use_default_system_prompt": false,
"chat_template": "{% if messages[0]['role'] == 'system' %}{% set system_message = messages[0]['content'] %}{% endif %}{% if system_message is defined %}{{ system_message }}{% endif %}{% for message in messages %}{% set content = message['content'] %}{% if message['role'] == 'user' %}{{ '<s>user\\n' + content + '</s>\\n<s>assistant\\n' }}{% elif message['role'] == 'assistant' %}{{ content + '</s>' + '\\n' }}{% endif %}{% endfor %}"
}

View File

@ -22,7 +22,7 @@ warnings.filterwarnings('ignore', category=UserWarning)
# ------------------------------------------------------------------------------------------------------------------
DEVICE_NAME = "cuda:0" if torch.cuda.is_available() else "cpu"
DEVICE = torch.device(DEVICE_NAME)
MODEL_PATH = "./minimind-small-T"
MODEL_PATH = "./minimind-v1-small"
TOKENIZE_PATH = MODEL_PATH
max_new_tokens = 1024
temperature = 0.7