嗨,大家好,我是小华同学,关注我们获得“最新、最全、最优质”开源项目和高效工作学习方法
🔥「只需一张消费级显卡,2小时完成26M参数GPT训练!」 🌟「从零构建中文大模型的最佳实践指南」 🚀「兼容OpenAI API,轻松接入各类AI应用平台」
MiniMind
是由开发者Jingyao Gong打造的开源轻量级大模型训练框架,其核心突破在于:
📌 项目亮点速览:
# 启动训练示例
python train.py \
--model_type nano \
--dataset ./data/corpus.txt \
--batch_size 32 \
--learning_rate 3e-4 \
--max_steps 5000
通过优化算法和内存管理,实现相比传统方法**300%**的训练速度提升。支持从26M到1B参数规模的模型训练。
class MoE(nn.Module):
def __init__(self):
self.experts = nn.ModuleList([TransformerBlock() for _ in range(8)])
self.gate = nn.Linear(d_model, 8)
采用专家混合架构,在145M参数量时即可达到传统架构1B参数模型的推理效果。
# 模型量化示例
python scripts/quantize_model.py \
--input_model ./output/model_final \
--output_model ./mobile_model \
--quant_type int8
通过动态量化技术,26M模型可压缩至12MB,流畅运行在Android/iOS设备。
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"messages": [{"role": "user", "content": "北京有哪些必去景点?"}],
"temperature": 0.7
}'
完整兼容OpenAI接口标准,可无缝接入LangChain、Dify等AI应用开发平台。
内置训练过程可视化工具,实时监控Loss曲线、内存占用等关键指标。
模块 | 技术方案 | 优势特性 |
---|---|---|
模型架构 | Transformer-XL + Rotary Embedding | 长文本处理能力提升40% |
训练优化 | FlashAttention-2 + 梯度累积 | 显存占用降低60% |
数据处理 | SentencePiece + 中文清洗策略 | 中文分词准确率提升35% |
分布式训练 | DeepSpeed ZeRO-2 | 支持多卡并行训练 |
推理加速 | ONNX Runtime + 动态量化 | 推理速度提升300% |
from minimind import ChatAgent
agent = ChatAgent("minimind-26m-chat")
response = agent.chat("我的订单1234物流到哪里了?")
print(response) # 您的订单正在广州转运中心...
summarizer = load_pipeline("text-summarization", model="minimind-104m")
long_text = open("report.txt").read()
summary = summarizer(long_text, max_length=100)
项目名称 | 参数量 | 中文支持 | 训练速度 | 部署难度 | 特色功能 |
---|---|---|---|---|---|
MiniMind | 26M-1B | ✅ | ⚡⚡⚡ | ⭐ | MoE架构/移动端部署 |
ChatLM-mini | 50M-500M | ✅ | ⚡⚡ | ⭐⭐ | 多轮对话优化 |
TinyLlama | 1.1B | ❌ | ⚡ | ⭐⭐⭐ | 英文SOTA性能 |
BabyLlama2-zh | 300M | ✅ | ⚡⚡ | ⭐⭐ | 中文指令微调 |
Steel-LLM | 1.1B | ✅ | ⚡ | ⭐⭐⭐ | 金融领域优化 |
python scripts/preprocess.py \
--input_dir ./raw_data \
--output_dir ./processed \
--lang zh \
--min_length 50
torchrun --nproc_per_node=2 train.py \
--model_type medium \
--use_moe \
--num_experts 8 \
--save_interval 1000
from scripts.convert_model import convert_to_onnx
convert_to_onnx(
input_path="./output/model_final",
output_path="./deploy/model.onnx"
)
MiniMind
的三大核心价值:
https://github.com/jingyaogong/minimind
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。