LlamaFactory进行llama3微调,有Colab教程可上手体验学习

火山方舟向量数据库人工智能与算法

picture.image

最近,大模型领域最受关注的事件就是meta发布了llama3,前段时间我们介绍的LlamaFactory也第一时间支持了llama3,并且发布了自己的Colab微调实战案例,并对外推出了两个社区中文微调版本:

下面我们一起来看看它的微调案例(可以直接在Colab上使用免费GPU运行),整个流程与其他模型微调基本一致:

地址: https://colab.research.google.com/drive/1d5KQtbemerlSDSxZIfAaWXhKr30QypiK?usp=sharing


          
from llmtuner import run_exp
          

          
%cd /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&魔搭):

picture.image

https://huggingface.co/datasets?sort=trending&search=llama3

值得一 提的是,llamafactory的微调方案利用unsloth加速,而unsloth也在更早的时候发布了自己的微调方案,感兴趣的读者可以体验。

unsloth(https://github.com/unslothai/unsloth)是一个用于加速深度学习模型训练的开源工具。它可以实现5倍到30倍的训练速度提升,同时还能减少50%的内存占用。

地址:https://colab.research.google.com/drive/1mPw6P52cERr93w3CMBiJjocdTnyPiKTX#scrollTo=IqM-T1RTzY6C

同时,黑马Groq也推出了自己的微调教程。

地址:https://colab.research.google.com/drive/1RmC3vZT2LqH4TZsG-5yVUlbcyvAtCWIQ?usp=sharing

扩展阅读:

开发必备工具-Colab使用介绍

开发必备工具-Colab进阶的21个小技巧

后台回复“进群”入群讨论。

0
0
0
0
关于作者
关于作者

文章

0

获赞

0

收藏

0

相关资源
KubeZoo: 轻量级 Kubernetes 多租户方案探索与实践
伴随云原生技术的发展,多个租户共享 Kubernetes 集群资源的业务需求应运而生,社区现有方案各有侧重,但是在海量小租户的场景下仍然存在改进空间。本次分享对现有多租户方案进行了总结和对比,然后提出一种基于协议转换的轻量级 Kubernetes 网关服务:KubeZoo,该方案能够显著降低多租户控制面带来的资源和运维成本,同时提供安全可靠的租户隔离性。
相关产品
评论
未登录
看完啦,登录分享一下感受吧~
暂无评论