DeepSeek-LLM:开源 670 亿参数语言模型权重获取与推理指南
一、项目官方信息
| 项目 | 信息 |
|---|---|
| GitHub 仓库 | https://github.com/deepseek-ai/DeepSeek-LLM |
| 官网 | https://www.deepseek.com |
| HuggingFace | https://huggingface.co/deepseek-ai |
| 开源协议 | 代码 MIT;模型遵循 Model License(允许商用) |
| 主要语言 | Makefile/配置(模型仓库) |
| Star 数 | 约 7.3k |
DeepSeek LLM 是一个约 670 亿参数的高级语言模型,从零开始在 2 万亿 token 的中英双语大规模数据集上训练。为推动研究,DeepSeek 开源了 DeepSeek LLM 7B/67B 的 Base 与 Chat 版本。
特点:
- 67B Base 在推理、编码、数学、中文理解上超过 LLaMA2 70B Base;
- 67B Chat 编码 HumanEval Pass@1 达 73.78,数学 GSM8K 0-shot 84.1、Math 0-shot 32.6;
- 中文能力突出,67B Chat 中文超过 GPT-3.5;
- 同时开放 7B/67B Base 的中间 checkpoint,便于研究训练过程。
二、官方图片
上图为 DeepSeek LLM 官方 Logo。
三、环境要求
- 推理硬件:GPU(7B 需单卡约 16GB+ 显存;67B 需多卡 A100/H800 级别,BF16 或量化);
- CUDA 环境、PyTorch;
- HuggingFace
transformers库; - 磁盘空间:67B 权重 BF16 约 130GB,需预留充足存储;
- 网络:能从 HuggingFace 下载模型,或用 AWS CLI 下载中间 checkpoint。
四、部署/接入步骤
1. 下载模型权重(HuggingFace)
| 模型 | 序列长度 | 下载地址 |
|---|---|---|
| DeepSeek LLM 7B Base | 4096 | https://huggingface.co/deepseek-ai/deepseek-llm-7b-base |
| DeepSeek LLM 7B Chat | 4096 | https://huggingface.co/deepseek-ai/deepseek-llm-7b-chat |
| DeepSeek LLM 67B Base | 4096 | https://huggingface.co/deepseek-ai/deepseek-llm-67b-base |
| DeepSeek LLM 67B Chat | 4096 | https://huggingface.co/deepseek-ai/deepseek-llm-67b-chat |
2. 下载中间 checkpoint(AWS S3)
# DeepSeek-LLM-7B-Base
aws s3 cp s3://deepseek-ai/DeepSeek-LLM/DeepSeek-LLM-7B-Base <local_path> --recursive --request-payer
# DeepSeek-LLM-67B-Base
aws s3 cp s3://deepseek-ai/DeepSeek-LLM/DeepSeek-LLM-67B-Base <local_path> --recursive --request-payer
3. 用 transformers 加载推理
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_path = "deepseek-ai/deepseek-llm-7b-chat" # 或本地路径
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(
model_path, torch_dtype=torch.bfloat16, device_map="auto"
)
messages = [{"role": "user", "content": "用一句话介绍你自己"}]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
outputs = model.generate(inputs, max_new_tokens=256, do_sample=True)
print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))
4. 大模型高效推理
67B 建议用 vLLM 等推理框架加速吞吐,或量化(GPTQ/AWQ)后在较少显卡上运行。
五、使用方法
- Base 模型:用于继续预训练、下游微调或研究;
- Chat 模型:直接对话,按 chat template 拼接消息;
- 中间 checkpoint:研究训练曲线、学习率变化等;
- 商用:遵循 Model License 条款允许商用。
六、常见问题 FAQ
-
7B 和 67B 怎么选? 显存有限或做实验选 7B;追求性能选 67B,但需要多卡与大量显存。
-
67B 怎么跑起来? BF16 约需 130GB 显存,用多卡或量化(GPTQ/AWQ)降低占用。
-
支持中文吗? 训练数据为中英双语,67B Chat 中文能力超过 GPT-3.5。
-
可以商用吗? 代码 MIT、模型遵循 Model License,条款下允许商用,使用前阅读 LICENSE-MODEL。
-
为什么推荐用 vLLM? 官方开源仓库在 HuggingFace 上跑大模型性能有限,vLLM 可显著提升吞吐。
-
序列长度是多少? 官方版本序列长度为 4096。