当前位置: 首页 > news >正文

七月论文审稿GPT第4版:通过paper-review数据集微调Mixtral-8x7b

模型训练

Mixtral-8x7b地址:魔搭社区

GitHub: hiyouga/LLaMA-Factory: Unify Efficient Fine-tuning of 100+ LLMs (github.com)

环境配置

git clone https://github.com/hiyouga/LLaMA-Factory.git
conda create -n llama_factory python=3.10
conda activate llama_factory
cd /root/path/LLaMA-Factory
pip install -r requirements.txt

有些得单独版本对齐,本人使用的是cuda11.8

pip install torch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 --index-url https://download.pytorch.org/whl/cu118
pip install bitsandbytes==0.41.3
# 下载对应版本 https://github.com/Dao-AILab/flash-attention/releases
pip install flash_attn-2.5.2+cu118torch2.1cxx11abiFALSE-cp310-cp310-linux_x86_64.whl

训练代码

python src/train_bash.py \--stage sft \--do_train True \--model_name_or_path /root/weights/Mixtral-8x7B-Instruct-v0.1 \--finetuning_type lora \--quantization_bit 4 \--template mistral \--flash_attn True \--dataset_dir data \--dataset paper_review_data \--cutoff_len 12288 \--learning_rate 5e-05 \--num_train_epochs 3.0 \--max_samples 1000000 \--per_device_train_batch_size 16 \--gradient_accumulation_steps 1 \--lr_scheduler_type cosine \--max_grad_norm 0.3 \--logging_steps 10 \--warmup_steps 0 \--lora_rank 128 \--save_steps 1000 \--lora_dropout 0.05 \--lora_target q_proj,o_proj,k_proj,v_proj,down_proj,gate_proj,up_proj \--output_dir saves/Mixtral-8x7B-Chat/lora/train_2024-03-23 \--fp16 True \--plot_loss True

模型推理

部署API接口

这里使用lora执行src/api_demo.py时会出现一个问题:

NotImplementedError: Cannot copy out of meta tensor; no data! · Issue #2940 · hiyouga/LLaMA-Factory (github.com)

解决方案:训练时使用了--quantization_bit 4 和 --flash_attn True,这里也要使用统一的才行。

CUDA_VISIBLE_DEVICES=0 API_PORT=8000 python src/api_demo.py \--model_name_or_path /root/weights/Mixtral-8x7B-Instruct-v0.1 \--adapter_name_or_path /root/path/saves/Mixtral-8x7B-Chat/lora/train_train_2024-03-23 \--template mistral \--finetuning_type lora \--quantization_bit 4 \--flash_attn True

推理所需显存为34318MiB

调用API接口

更多见七月的《大模型商用项目之审稿GPT微调实战》

http://www.lryc.cn/news/327671.html

相关文章:

  • 基于 YOLO V8 Fine-Tuning 训练自定义的目标检测模型
  • 快手,得物,蓝月亮,蓝禾,奇安信,三七互娱,顺丰,康冠科技,金证科技24春招内推
  • 全局UI方法-弹窗二-列表选择弹窗(ActionSheet)
  • Memcached分布式内存对象数据库
  • 华为广告打包报错,问题思考
  • docker-compose mysql
  • PGAdmin 4:用于管理和维护PostgreSQL数据库的强大工具
  • 成都市酷客焕学新媒体科技有限公司:实现品牌的更大价值!
  • 探索数据库--------------mysql主从复制和读写分离
  • 【Hello,PyQt】控件拖拽
  • 荟萃分析R Meta-Analyses 3 Effect Sizes
  • 常用的8个应用和中间件的Docker运行示例
  • UnoCSS实现背景图片样式加载
  • vue前端工程化
  • 面向对象:继承
  • ES学习日记(一)-------单节点安装启动
  • 【管理咨询宝藏59】某大型汽车物流战略咨询报告
  • ArcGIS Pro横向水平图例
  • 线程创建的几种方式
  • Python教程:一文掌握Python多线程(很详细)
  • 华为防火墙配置指引超详细(包含安全配置部分)以USG6320为例
  • (含react-draggable库以及相关BUG如何解决)固定在左上方某盒子内(如按钮)添加可拖动功能,使用react hook语法实现
  • 选择最佳图像处理工具OpenCV、JAI、ImageJ、Thumbnailator和Graphics2D
  • 微信小程序版本更新检测
  • 【每日力扣】343. 整数拆分与63. 不同路径 II
  • 洛谷 Cut Ribbon
  • #AS,idea,maven,gradle
  • FPGA结构与片上资源
  • 【分布式】——分布式事务
  • 第6章:“让我们思考这个”的提示