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

做搜索的网站网站网页建设与维护

做搜索的网站,网站网页建设与维护,开发助手app,中关村电脑报价官网文章目录 1. 使用docker安装1.1 配置docker1. 2 拉取 LLaMA-Factory1.3 修改配置 2. 下载模型3. 准备训练数据3.1 下载数据集3.2 自定义数据集配置 4. 训练4.1 训练配置4.2 启动训练4.3 训练效果测试 5. 合并权重 更好的阅读体验:传送门 服务器:800TA2 芯…

文章目录

    • 1. 使用docker安装
      • 1.1 配置docker
      • 1. 2 拉取 LLaMA-Factory
      • 1.3 修改配置
    • 2. 下载模型
    • 3. 准备训练数据
      • 3.1 下载数据集
      • 3.2 自定义数据集配置
    • 4. 训练
      • 4.1 训练配置
      • 4.2 启动训练
      • 4.3 训练效果测试
    • 5. 合并权重

更好的阅读体验:传送门

服务器:800TA2
芯片:910B3
模型:Qwen2.5-14B-Instruct
数据集:魔搭自定义数据集,alpaca格式

1. 使用docker安装

1.1 配置docker

配置docker镜像源:

sudo vi /etc/docker/daemon.json

填入:

{"registry-mirrors": ["https://2t697950.mirror.aliyuncs.com","https://docker.1ms.run","https://docker.xuanyuan.me"]
}

安装 docker-compose

sudo curl -L https://github.com/docker/compose/releases/download/v2.33.0/docker-compose-linux-aarch64 -o /usr/local/bin/docker-compose
chmod 777 /usr/local/bin/docker-compose
docker-compose -v

1. 2 拉取 LLaMA-Factory

# 以下环境都基于路径  /home/aicc1
mkdir  /home/aicc1
cd  /home/aicc1
git clone https://github.com/hiyouga/LLaMA-Factory.git
cd LLaMA-Factory/docker/docker-npu

1.3 修改配置

请保证docker镜像源已配置完毕。
修改Dockerfile docker-compose.yml,中挂载的设备数量、python镜像源。
默认只挂载了一个卡,下面的配置通过添加devices挂载了8张卡。

挂载了目录 /home/aicc1,用于与宿主机数据交互。具体请修改为你自己的文件路径

docker-compose.yml

services:llamafactory:build:dockerfile: ./docker/docker-npu/Dockerfilecontext: ../..args:INSTALL_DEEPSPEED: "false"PIP_INDEX: https://pypi.tuna.tsinghua.edu.cn/simplecontainer_name: llamafactoryvolumes:- ../../hf_cache:/root/.cache/huggingface- ../../ms_cache:/root/.cache/modelscope- ../../om_cache:/root/.cache/openmind- ../../data:/app/data- ../../output:/app/output- /usr/local/dcmi:/usr/local/dcmi- /usr/local/bin/npu-smi:/usr/local/bin/npu-smi- /usr/local/Ascend/driver:/usr/local/Ascend/driver- /etc/ascend_install.info:/etc/ascend_install.info- /home/aicc1:/home/aicc1- /home/aicc2:/home/aicc2ports:- "7860:7860"- "8000:8000"ipc: hosttty: trueshm_size: "16gb"stdin_open: truecommand: bashdevices:- /dev/davinci0- /dev/davinci1- /dev/davinci2- /dev/davinci3- /dev/davinci4- /dev/davinci5- /dev/davinci6- /dev/davinci7- /dev/davinci_manager- /dev/devmm_svm- /dev/hisi_hdcrestart: unless-stopped

Dockerfile :

# Use the Ubuntu 22.04 image with CANN 8.0.rc1
# More versions can be found at https://hub.docker.com/r/ascendai/cann/tags
# FROM ascendai/cann:8.0.rc1-910-ubuntu22.04-py3.8
FROM ascendai/cann:8.0.0-910b-ubuntu22.04-py3.10
# FROM ascendai/cann:8.0.rc1-910-openeuler22.03-py3.8
# FROM ascendai/cann:8.0.rc1-910b-openeuler22.03-py3.8# Define environments
ENV DEBIAN_FRONTEND=noninteractive# Define installation arguments
ARG INSTALL_DEEPSPEED=false
ARG PIP_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple
ARG TORCH_INDEX=https://mirrors.aliyun.com/pytorch-wheels/cpu
ARG HTTP_PROXY=# Set the working directory
WORKDIR /app# Set http proxy
RUN if [ -n "$HTTP_PROXY" ]; then \echo "Configuring proxy..."; \export http_proxy=$HTTP_PROXY; \export https_proxy=$HTTP_PROXY; \fi# Install the requirements
COPY requirements.txt /app
# RUN python -m pip install --upgrade pip && \
#     pip config set global.index-url "$PIP_INDEX" && \
#     pip config set global.extra-index-url "$TORCH_INDEX" && \
#     if [ -n "$HTTP_PROXY" ]; then \
#         python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --proxy=$HTTP_PROXY -r requirements.txt; \
#     else \
#         python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt; \
#     fiRUN python -m pip install --upgrade pip && \pip config set global.index-url "$PIP_INDEX" && \pip config set global.extra-index-url "$TORCH_INDEX" && \pip install --retries=3 --timeout=60 \-r requirements.txt \-i "$PIP_INDEX" \--extra-index-url "$TORCH_INDEX"
# Copy the rest of the application into the image
COPY . /app# Install the LLaMA Factory
RUN EXTRA_PACKAGES="torch-npu,metrics"; \if [ "$INSTALL_DEEPSPEED" == "true" ]; then \EXTRA_PACKAGES="${EXTRA_PACKAGES},deepspeed"; \fi; \if [ -n "$HTTP_PROXY" ]; then \pip install --proxy=$HTTP_PROXY -e ".[$EXTRA_PACKAGES]"; \else \pip install -e ".[$EXTRA_PACKAGES]"; \fi# Unset http proxy
RUN if [ -n "$HTTP_PROXY" ]; then \unset http_proxy; \unset https_proxy; \fi# Set up volumes
VOLUME [ "/root/.cache/huggingface", "/root/.cache/modelscope", "/app/data", "/app/output" ]# Expose port 7860 for the LLaMA Board
ENV GRADIO_SERVER_PORT 7860
EXPOSE 7860# Expose port 8000 for the API service
ENV API_PORT 8000
EXPOSE 8000

2. 下载模型

ps:请修改为你要训练的模型

# 进入容器
docker exec -it llamafactory bash
# 下载模型
pip install modelscope
modelscope download --model Qwen/Qwen2.5-14B-Instruct --local_dir /home/aicc1/Qwen2.5-14B-Instruct/

3. 准备训练数据

3.1 下载数据集

使用魔搭上一个医疗的数据,大小:580M,格式:Alpaca。
数据处理或格式要求请查看官方文档:
传送门

ps:如果认为数据集太大(训练时间会加长),可以下载后删除大部分,保留几百条数据去测试

# 在宿主机上 (容器中没有下载wget)
cd /home/aicc1/LLaMA-Factory/data
wget https://modelscope.cn/datasets/swift/Alpaca-CoT/resolve/master/Chinese-medical/chinesemedical.json

3.2 自定义数据集配置

如果使用自定义数据集,需要配置LLaMA-Factory

vim /home/aicc1/LLaMA-Factory/data/dataset_info.json

在其中添加:

"my_dataset": {"file_name": "chinesemedical.json","columns": {"prompt": "instruction","query": "input","response": "output"}
},

4. 训练

4.1 训练配置

mkdir /home/aicc1/LLaMA-Factory/qwen_config
cd /home/aicc1/LLaMA-Factory/qwen_config
tourch qwen2_5_lora_sft_ds.yaml

qwen2_5_lora_sft_ds.yaml 配置:

该配置采用文档中qwen1.5的训练配置。传送门

### model
model_name_or_path: /home/aicc1/Qwen2.5-14B-Instruct### method
stage: sft
do_train: true
finetuning_type: lora
lora_target: q_proj,v_proj### ddp
ddp_timeout: 180000000
deepspeed: examples/deepspeed/ds_z0_config.json### dataset
dataset: identity,my_dataset
template: qwen
cutoff_len: 1024
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16### output
output_dir: saves/Qwen2.5-14B/lora/sft
logging_steps: 10
save_steps: 500
plot_loss: true
overwrite_output_dir: true### train
per_device_train_batch_size: 1
gradient_accumulation_steps: 2
learning_rate: 0.0001
num_train_epochs: 10.0
lr_scheduler_type: cosine
warmup_ratio: 0.1
fp16: true### eval
val_size: 0.1
per_device_eval_batch_size: 1
eval_strategy: steps
eval_steps: 500

请注意一些关键参数:
model_name_or_path:下载的模型路径
dataset:数据集
num_train_epochs:训练轮次

本篇用到的数据集为 LLaMA-Factory 自带的 identity 和 自定义的my_dataset,对 identity 数据集进行如下全局替换即可实现定制指令:
{{name}} 替换为 Ascend-helper
{{author}} 替换为 Ascend

执行下方命令替换:

sed -i 's/{{name}}/Ascend-helper/g; s/{{author}}/Ascend/g' /home/aicc1/LLaMA-Factorydata/identity.json

在这里插入图片描述

4.2 启动训练

cd /home/aicc1/LLaMA-Factory
ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 torchrun --nproc_per_node 8 \--nnodes 1 \--node_rank 0 \--master_addr 127.0.0.1 \--master_port 7007 \src/train.py qwen_config/qwen2_5_lora_sft_ds.yaml

训练开始:
在这里插入图片描述
训练中间:
在这里插入图片描述
训练结束:

输出关于训练、评估的指标信息

在这里插入图片描述
结果保存在saves文件夹下
在这里插入图片描述
Loss下降的感觉还不错:
在这里插入图片描述

4.3 训练效果测试

指定原始模型路径、训练后lora路径。

llamafactory-cli chat --model_name_or_path /home/aicc1/Qwen2.5-14B-Instruct \--adapter_name_or_path /home/aicc1/LLaMA-Factory/saves/Qwen2.5-14B/lora/sft \--template qwen \--finetuning_type lora

询问identity数据集内容,返回成功。如图所示:
在这里插入图片描述

5. 合并权重

ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 llamafactory-cli export \--model_name_or_path /home/aicc1/Qwen2.5-14B-Instruct \--adapter_name_or_path ./saves/Qwen2.5-14B/lora/sft  \--template qwen \--finetuning_type lora \--export_dir ./saves/Qwen2.5-14B/lora/megred-model-path \--export_size 2 \--export_device auto \--export_legacy_format False
http://www.dtcms.com/wzjs/782108.html

相关文章:

  • 郑州巩义网站建设博客程序seo
  • seo撰写网站标题以及描述的案例星子网房产租房
  • 做视频网站的上市公司建设工程是指哪些工程
  • 太原中小学网站建设网站开发学历要求
  • 一个人做网站原型哪个网站公司做的
  • 医院网站建设 价格wordpress主题下载zip
  • 湖南哪里有做网站的刷百度关键词排名
  • 有没有专业做电视测评的网站模板网优酷
  • 企业网站策划进度插件 wordpress
  • 商城网站建设是 什么软件国内包装设计网站
  • 中国建设银行海南省分行网站网站建设教程百度网盘
  • 福田做商城网站建设多少钱上海公关公司排行榜
  • 网站数据库做好了 怎么做网页大学生可以做的网站项目
  • 财务管理做的好的门户网站谁能做网站开发
  • 余杭区住房与建设局网站深圳建设交易信息网站
  • 大型网站开发用的技术网上商城小程序开发
  • 建设双语的网站网站专项审批查询
  • 网站线框图为什么做腾讯网站
  • 下载学校网站模板建e网室内设计网现代简约
  • jquery 个人网站网络营销的机遇和挑战
  • 大有网网站方庄网站建设
  • 常见的cms网站wordpress数据库连接时错误
  • 小程序免费网站网站开发程序说明
  • 网站怎么添加手机版漂浮广告网站
  • 网站设计的优化个人网站设计制作步骤
  • 深圳网站做优化哪家公司好道路建设网站专题
  • 网站开发工程师缺口4399小游戏电脑版在线玩
  • 在线做行测的网站建筑工程公司起个名字
  • 旅游网站的导航栏目设计网页设计公司深圳
  • 忘记网站管理员密码阿里云账号密码发给网站开发