怎样从hugging face下载DeepSeek-R1-Distill-Qwen-1.5B
时间: 2025-03-02 17:01:02 浏览: 322
### 下载 DeepSeek-R1-Distill-Qwen-1.5B 模型
为了从 Hugging Face 平台下载 `DeepSeek-R1-Distill-Qwen-1.5B` 模型,可以按照如下方法操作:
#### 使用命令行工具 Git LFS 和 Hugging Face CLI
首先安装必要的依赖项。对于大多数环境来说,这可以通过以下命令完成:
```bash
pip install git-lfs
git lfs install
pip install huggingface_hub
```
接着通过 Hugging Face 的命令行接口登录账号并获取模型文件。
```bash
huggingface-cli login
```
输入 API Token 后即可访问私有或公共仓库中的资源。
最后执行克隆命令来下载目标模型库到本地计算机上。
```bash
git lfs clone https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-1_5B.git
```
上述过程会把整个存储库复制下来,包括配置文件和其他辅助材料[^1]。
另外一种更简便的方式是利用 Python 脚本直接加载预训练权重而不需要手动管理版本控制系统。
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-1_5B"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
# Save locally if needed
save_directory = "./DeepSeek-R1-Distill-Qwen-1_5B"
tokenizer.save_pretrained(save_directory)
model.save_pretrained(save_directory)
```
这段代码片段展示了如何借助 Transformers 库自动处理模型及其配套组件的下载工作,并提供了保存至指定路径的功能。
阅读全文
相关推荐


















