微信扫码
与创始人交个朋友
我要投稿
Llama3-8B-Chinese-Chat,首个使用 ORPO 算法微调的中文 Llama3 模型,文章介绍:https://zhuanlan.zhihu.com/p/693905042(可点原文链接阅读)
Llama3-Chinese,首个使用 DoRA 和 LoRA+ 算法微调的中文 Llama3 模型,仓库地址:https://github.com/seanzhang-zhichen/llama3-chinese
下面我们一起来看看它的微调案例(可以直接在Colab上使用免费GPU运行),整个流程与其他模型微调基本一致:
from llmtuner import run_exp
/content/LLaMA-Factory/
run_exp(dict(
stage="sft",
do_train=True,
model_name_or_path="unsloth/llama-3-8b-Instruct-bnb-4bit",
dataset="identity,alpaca_gpt4_en,alpaca_gpt4_zh",
template="llama3",
finetuning_type="lora",
lora_target="all",
output_dir="llama3_lora",
per_device_train_batch_size=2,
gradient_accumulation_steps=4,
lr_scheduler_type="cosine",
logging_steps=10,
warmup_ratio=0.1,
save_steps=1000,
learning_rate=5e-5,
num_train_epochs=3.0,
max_samples=500,
max_grad_norm=1.0,
quantization_bit=4,
loraplus_lr_ratio=16.0,
use_unsloth=True,
fp16=True,
))
训练数据集:
[{"instruction": "hi","input": "","output": "Hello! I am Llama-3, an AI assistant developed by LLaMA Factory. How can I assist you today?"},{"instruction": "hello","input": "","output": "Hello! I am Llama-3, an AI assistant developed by LLaMA Factory. How can I assist you today?"},{"instruction": "Who are you?","input": "","output": "I am Llama-3, an AI assistant developed by LLaMA Factory. How can I assist you today?"},...
更多llama3数据集(huggingface&魔搭):
https://huggingface.co/datasets?sort=trending&search=llama3
值得一提的是,llamafactory的微调方案利用unsloth加速,而unsloth也在更早的时候发布了自己的微调方案,感兴趣的读者可以体验。
unsloth(https://github.com/unslothai/unsloth)是一个用于加速深度学习模型训练的开源工具。它可以实现5倍到30倍的训练速度提升,同时还能减少50%的内存占用。
53AI,企业落地应用大模型首选服务商
产品:大模型应用平台+智能体定制开发+落地咨询服务
承诺:先做场景POC验证,看到效果再签署服务协议。零风险落地应用大模型,已交付160+中大型企业
2024-03-30
2024-08-13
2024-05-10
2024-05-28
2024-04-26
2024-04-12
2024-04-25
2024-05-06
2024-07-25
2024-05-14