Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
从0到1构建一个MiniLLM (pretrain+sft+dpo实践中)
| Date | Stars |
|---|---|
| 2026-07-31 | 551 |
| 2026-08-05 | 552 |
| 2026-08-06 | 552 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
 [](https://github.com/Tongjilibo/build_MiniLLM_from_scratch/blob/master/LICENSE) [](https://github.com/Tongjilibo/build_MiniLLM_from_scratch) [](https://github.com/Tongjilibo/build_MiniLLM_from_scratch/issues) [](https://github.com/Tongjilibo/build_MiniLLM_from_scratch/commits/master) [](https://huggingface.co/collections/Tongjilibo/minillm-67de83f2751c5d81c030fefb) [](https://github.com/Tongjilibo/build_MiniLLM_from_scratch/issues) [](https://github.com/Tongjilibo/build_MiniLLM_from_scratch/blob/master/docs/pics/wechat_group.jpg) [Bert4torch](https://github.com/Tongjilibo/bert4torch) | [Torch4keras](https://github.com/Tongjilibo/torch4keras)  ## 📌 1. 介绍 - **初衷**:本项目旨在构建一个小参数量的llm,走完`预训练` -> `指令微调` -> `奖励模型` -> `强化学习` 四个阶段,以可控的成本完成一个可以完成简单聊天任务的chat模型,目前完成前两个阶段 - **特色**: - 使用[bert4torch](https://github.com/Tongjilibo/bert4torch)训练框架,代码简洁高效; - 训练的checkpoint可以无缝衔接`transformers`,直接使用`transformers`包进行推理; - 优化了训练时候文件读取方式,优化内存占用; - 提供了完整训练log供复现比对; - 增加自我认知数据集,可自定义机器人名称作者等属性。 - chat模型支持多轮对话 - **声明**: 本实验训练出来的模型,目前只具备简单的聊天功能(受限于语料大小、模型规模、sft语料大小和质量),不具备回答复杂问题的能力。 <details style="color:rgb(128,128,128)"> <summary>Models List</summary> | 模型 | 类型 | Release Date | |-------------------------|----------|------------| | MiniLLM-1.1B-SFT | 指令微调 | 2024.03.25 | | MiniLLM-1.1B-Base | 预训练 | 2024.03.25 | | MiniLLM-0.2B-SFT | 指令微调 | 2024.03.16 | | MiniLLM-0.2B-SFT-Alpaca | 指令微调 | 2024.03.16 | | MiniLLM-0.2B-Base | 预训练 | 2025.03.16 | | MiniLLM-0.2B-NoWudao-Base | 预训练 | 2025.03.16 | </details> ## 📌 2. 快速开始 - 环境安装 ```shell pip install git+https://github.com/Tongjilibo/torch4keras.git pip install git+https://github.com/Tongjilibo/bert4torch.git@dev ``` - 脚本说明 ```shell # 为防止terminal关闭,可以使用nohup, tmux, screen方式来启动 # eg. nohup torchrun --standalone --nproc_per_node=4 pretrain.py --name baby > nohup.log& # config/bert4torch_config.py: 配置文件默认为0.2B模型训练文件,如果你希望更换为1B,你需要自行将config文件中的`bert4torch_config_1.json`的内容黏贴到`bert4torch_config.json` # 预训练 cd pretrain torchrun --standalone --nproc_per_node=4 pretrain.py # 部分反映ddp训到一般会崩,需设置`export NCCL_IB_DISABLE=1` # 预训练推理(命令行聊天) cd pretrain python infer.py # python infer_transformers.py # 指令微调训练 cd sft python sft.py # 指令微调推理(命令行聊天) cd sft python infer.py # python infer_transformers.py # 把ckpt转化成transformers可以运行的格式 cd docs python convert.py ``` ## 📌 3. 更新历史 - **20240403**: 增加基于1157万样本训练的[MiniLLM-0.2B-SFT](https://huggingface.co/Tongjilibo/MiniLLM-0.2B-SFT),支持多轮对话 - **20240325**: 增加1.1B模型(源于[zRzRzRzRzRzRzR](https://github.com/zRzRzRzRzRzRzR)) - **20240316**: 初始提交,预训练模型`MiniLLM-0.2B-NoWudao-Base`和`MiniLLM-0.2B-Base`; SFT模型`MiniLLM-0.2B-SFT-Alpaca` ## 📌 4. 预训练 ### 4.1 预训练语料 | 中文预训练语料 | 描述 | |-------------------------|----------------------------------------| | [Wiki中文百科](https://huggingface.co/datasets/pleisto/wikipedia-cn-20230720-filtered)| 中文Wikipedia的数据 | | [BaiduBaiKe](https://pan.baidu.com/s/1jIpCHnWLTNYabftavo3DVw?pwd=bwvb)| 中文BaiduBaiKe的数据| | [C4_zh:part1](https://pan.baidu.com/s/18O2Tj_PPB718K8gnaWrWUQ?pwd=zv4r);[C4_zh:part2](https://pan.baidu.com/s/11PTgtUfFXvpNkOige9Iw4w?pwd=sb83);[C4_zh:part3](https://pan.baidu.com/s/1248QfTS8QHPojYW-0fd5jQ?pwd=l89d) | C4是可用的最大语言数
Excerpt of 15,294 characters
Read on GitHub101
Yuxuan Zhang · Z.ai · China
12
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:007d9b824d45d815, topic:llm