-
Notifications
You must be signed in to change notification settings - Fork 159
model_conversion_zh
ymcui edited this page Apr 26, 2024
·
5 revisions
以下介绍了手动将LoRA与原版Llama-3-8B合并得到完整模型的流程。如网络带宽充足,建议直接下载完整版模型。
- 运行前确保拉取仓库最新版代码:
git pull
- 确保机器有足够的内存加载完整模型以进行合并模型操作
- 安装依赖库(项目根目录
requirements.txt
):
$ pip install -r requirements.txt
原版Llama-3-8B(不是instruct版)地址:https://huggingface.co/meta-llama/Meta-Llama-3-8B
相关文件列表(建议只下载safetensors格式权重):
original/ <-- 这个文件夹不用下载,里面是pth格式的权重
config.json
generation_config.json
model-00001-of-00004.safetensors
model-00002-of-00004.safetensors
model-00003-of-00004.safetensors
model-00004-of-00004.safetensors
model.safetensors.index.json
special_tokens_map.json
tokenizer_config.json
tokenizer.json
这一步骤会合并LoRA权重,生成全量模型权重(safetensors格式)。执行以下命令:
$ python scripts/merge_llama3_with_chinese_lora_low_mem.py \
--base_model path_to_original_llama3_dir \
--lora_model path_to_lora \
--output_dir path_to_output_dir
参数说明:
-
--base_model
:存放原版Llama-3模型权重和配置文件的目录 -
--lora_model
:Llama-3-Chinese或者Llama-3-Chinese-Instruct的LoRA解压后文件所在目录,也可使用🤗Model Hub模型调用名称(会自动下载) -
--output_dir
:指定保存全量模型权重的目录,默认为./
- (可选)
--verbose
:显示合并过程中的详细信息
- Model Reconstruction
- Model Quantization, Inference and Deployment
- System Performance
- Training Scripts
- FAQ