1.官网.pth格式
去官网(Download Llama (meta.com))申请
具体可以看这个B站视频
Llama2模型申请与本地部署详细教程_哔哩哔哩_bilibili(视频是llama2,下载llama3是另外一个git)
相关代码如下
git clone https://github.com/meta-llama/llama3.git
然后进入文件夹
打开git
输入
./download.sh
然后输入申请到的链接
不出意外的话,会报403错误
具体如下:
Enter the list of models to download without spaces (8B,8B-instruct,70B,70B-instruct), or press Enter for all: 8B-instruct
Downloading LICENSE and Acceptable Usage Policy
--2024-08-21 09:57:00-- https://download6.llamameta.net/LICENSE?Policy=eyJTdGF0ZW1lbnQiOlt7InVuaXF1ZV9oYXNoIjoiN2JqYmFna21vN3ViMXl2M2hoZmdxcWZsIiwiUmVzb3VyY2UiOiJodHRwczpcL1wvZG93bmxvYWQ2LmxsYW1hbWV0YS5uZXRcLyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE3MjQyOTE3NjR9fX1dfQ__&Signature=CapUGH9ZrwAC~Stwo4~mb6m0J6NurxMRXcnvt09NEMF~QlcoczvXDCGsM6puvmb1F2WBwcxQbYHx6WOlW3uw8011NepgO6vQZtw425XC7jMX2PpCey6LYB497ZqSbX8yNF5JPJGGKq~fMBPKdM5LKSJGlotg9~wjUjpzeAIJlleaR7WMgjlYQOVPoQa92rG9XulUw21Psbp5cEEihifqDjfezgbpAC5xZ1ZLYnkwddk7Q98PaoabKLYNWoKXu5KhcStCicvB2tee1g~5MJTGCgenJENt6TINLRUk15zdnnP1ZB8zv8-6z5wqhlhrv7DTlcEEoIO0Mm0n9hk~zc1SZw__&Key-Pair-Id=K15QRJLYKIFSLZ&Download-Request-ID=2031245347334530
Resolving download6.llamameta.net (download6.llamameta.net)... 65.8.11.40, 65.8.11.126, 65.8.11.54, ...
Connecting to download6.llamameta.net (download6.llamameta.net)|65.8.11.40|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2024-08-21 09:57:01 ERROR 403: Forbidden.
--2024-08-21 09:57:01-- https://download6.llamameta.net/LICENSE?Policy=eyJTdGF0ZW1lbnQiOlt7InVuaXF1ZV9oYXNoIjoiN2JqYmFna21vN3ViMXl2M2hoZmdxcWZsIiwiUmVzb3VyY2UiOiJodHRwczpcL1wvZG93bmxvYWQ2LmxsYW1hbWV0YS5uZXRcLyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE3MjQyOTE3NjR9fX1dfQ__&Signature=CapUGH9ZrwAC%7EStwo4%7Emb6m0J6NurxMRXcnvt09NEMF%7EQlcoczvXDCGsM6puvmb1F2WBwcxQbYHx6WOlW3uw8011NepgO6vQZtw425XC7jMX2PpCey6LYB497ZqSbX8yNF5JPJGGKq%7EfMBPKdM5LKSJGlotg9%7EwjUjpzeAIJlleaR7WMgjlYQOVPoQa92rG9XulUw21Psbp5cEEihifqDjfezgbpAC5xZ1ZLYnkwddk7Q98PaoabKLYNWoKXu5KhcStCicvB2tee1g%7E5MJTGCgenJENt6TINLRUk15zdnnP1ZB8zv8-6z5wqhlhrv7DTlcEEoIO0Mm0n9hk%7Ezc1SZw__&Key-Pair-Id=K15QRJLYKIFSLZ&Download-Request-ID=2031245347334530
Reusing existing connection to download6.llamameta.net:443.
HTTP request sent, awaiting response... 403 Forbidden
2024-08-21 09:57:01 ERROR 403: Forbidden.
这是因为对方屏蔽了你的地址(下载llama3出现ERROR 403: Forbidden解决方案_llama3 403-CSDN博客
llama3模型部署时遇到的问题及解决方案_llama3 403-CSDN博客
下载llama3出现ERROR 403: Forbidden解决方案_llama3 403-CSDN博客)
需要不停的更换节点,一直到合适为止
下载后是.pth模型
转换为safetensors格式(hugging face版本)
import torch
from safetensors.torch import save_file
# 1. 加载 .pth 文件
pth_file_path = 'consolidated.00.pth'
model_state_dict = torch.load(pth_file_path)
# 2. 保存为 .safetensors 文件
safetensors_file_path = 'model.safetensors'
save_file(model_state_dict, safetensors_file_path)
2.申请safetensors格式(hugging face版本)
meta-llama/Meta-Llama-3.1-8B-Instruct · Hugging Face
每个账号只能填一次申请表,只要国家填了中国,目前是百分百被拒绝(试了三个号,地址写中国都被拒)。填写之后无法更改。
相关链接(https://huggingface.co/meta-llama/Meta-Llama-3-8B/discussions/124)
有好心人号称上传了GGUF格式
相关链接:https://huggingface.co/JaaackXD
核心方法,切换为别的国家ip地址,然后填写别的国家,申请经过一段较长时间(大概10-30分钟),差不多就能通过。