您现在的位置是:Llama用于Windows上的Windows Factory微调Llama 3的基本操作 >>正文

Llama用于Windows上的Windows Factory微调Llama 3的基本操作

德薄能鲜网76人已围观

简介本博客参考了一些文章,例如:教程:使用llama_Factory微调llama3:8b大模型_llama3模型微调保存-CSDN博客。也可以参考Llamama...

本博客参考了一些文章,例如:教程:使用llama_Factory微调llama3:8b大模型_llama3模型微调保存-CSDN博客。

也可以参考Llamama。 FactoryReadme:GitHub - hiyouga/LLaMA-Factory: Unify Efficient Fine-Tuning of 100+ LLMs。Unify Efficient Fine-Tuning of 100+ LLMs. Contribute to hiyouga/LLaMA-Factory development by creating an account on GitHub.。icon-default.png?t=N7T8https://github.com/hiyouga/LLaMA-Factory?tab=readme-ov-file#installation。首先是Llama Factory clone到本地:GitHub - hiyouga/LLaMA-Factory: Unify Efficient Fine-Tuning of 100+ LLMs 。

其次,创建conda环境:

conda create -n llama_factory python=3.10

激活环境后,首先安装pytorch,参考此页面:Start Locally | PyTorch,例如:

conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia。

然后进入LLAMA-Factory文件夹󿀌参考Readme༌操作:

pip install -e .[torch,metrics]。

同时,根据Readme༌Windows系统还需要运行:

pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/download/wheels/bitsandbytes-0.41.2.post2-py3-none-win_amd64.whl。

我就不谈具体原因了。然后依次运行󿄚

Set CUDA_VISIBLE_DEVICES=0Set GRADIO_SHARE=llamafactory-cli webui。

你可以看到它的webui。然而,目前还没有模型参数文件󿀌对于国内用户来说,,可以在这里。https://modelscope.cn/organization/LLM-Research。icon-default.png?t=N7T8https://modelscope.cn/organization/LLM-Research。

下载,例如,可以下载Llama3中文版(假如没有git lfs可以用前两个命令安装):

conda install git-lfsgit-lfs installgit lfs clone https://www.modelscope.cn/LLM-Research/Llama3-8BB-Chinese-Chat.git。

下载后,可以构建自己的微调数据集,具体来说,,根据这里的介绍:

https://github.com/hiyouga/LLaMA-Factory/tree/main/data。

Llama Factory支持alpacaca and sharegpt格式,前者类似于这种格式:

[  {     "instruction": "human instruction (required)",    "input": "human input (optional)",    "output": "model response (required)",    "system": "system prompt (optional)",    "history": [      ["human instruction in the first round (optional)", "model response in the first round (optional)"],      ["human instruction in the second round (optional)", "model response in the second round (optional)"]    ]  }]。

当我们构建数据集࿰时c;最简单的方法就是只构建instruction和output。

当我们构建数据集时,最简单的方法就是只构建instruction和output。将生成的json文件放入LLaMA-Factorydata目录,然后打开dataset_info.json文件,增加文件名记录,例如,我在这里添加:
  "private_train": { 。
    "file_name": "private_train.json"

  },

选择自己的私人数据集,可以预览,然后就可以开始训练了。

训练结束后,切换到Export,然后在上述“微调方法”-“检查点路径”中选择刚刚存储的目录Train_2024_xxxx等,然后指定导出文件的目录,然后就可以导出了。

导出后,我们可以加载微调模型并进行测试。当然,若训练数据集相对较小,测试效果不会太好。如果你只是想展示微调的效果和特定的问题c;可以训练模型到拟合,呵呵呵。

记录这么多。

Tags:

相关文章



友情链接