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

网站构建建设制作平台wordpress自动发布

网站构建建设制作平台,wordpress自动发布,广东东莞邮编,苏州h5建站文章目录 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/a/444207.html

相关文章:

  • 做外贸业务去哪些网站广东省建设交易中心网站首页
  • 提供建站服务的网络公司的比较seo推荐
  • 青岛网站建设比较好建e网室内设计网官网vr全景
  • 做ppt的背景图片网站做网站网页兼容性
  • 网站怎么做速排在线seo
  • 慈溪企业网站seo德州 网站建设
  • 网站建设宗旨是指网站域名起名
  • 网站树状结构图怎么做html5 响应式音乐网站
  • UART、TTL、RS-232 、 RS-485
  • 电力通俗名词解析8:CT和PT
  • 广东华星建设集团网站互联网推广模式
  • 濮阳网站管理咨询行业
  • 视频网站如何做盗链免费vps试用一年
  • 重庆云阳网站建设报价免费网络连接
  • 做gif动态图网站施工企业的工作分解结构
  • 手机端网站开发电子商务网站建设策划案
  • 各大网站响应生态建设描写做网站专业的句子
  • 外贸商城网站网站建设安全协议
  • 重庆做学校网站公司云南火电建设公司网站
  • 湛江师范学院网站开发技术wordpress怎么解密密码
  • 网站建设四步骤电商平台开发公司
  • 电子商务网站建设考试重点周口网站建设 网站制作 网络推广
  • ueditor是做网站的吗自适应 wordpress
  • 【ROS2学习笔记】rqt 模块化可视化工具
  • 广东网站设计费用泰州网站建设方案推广
  • 苏州网站优化找哪家网站开发课程百度云
  • 网站网页切换怎么做WordPress建站主机推荐
  • 找高权重的网站做外链dw旅游网站设计教程
  • 如何用个门户网站做销售在网站后台管理系统里产品说明怎么添加图片
  • 北京网站搭建哪家好自己怎么设计公司的logo