Skip to content

Commit

Permalink
Update docs by some tiny fixes (#40)
Browse files Browse the repository at this point in the history
* Update docs
    1. llamafacotry, Diffusers, opencv, timm, open_clip
    2. add pip tsinghua source
    3. rename conda env
    4. fix yaml args config
    5. add exit way for llamafactory inference
  • Loading branch information
MengqingCao authored Jul 18, 2024
1 parent d719cfb commit 8353f58
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 23 deletions.
4 changes: 2 additions & 2 deletions sources/Diffusers/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Python 环境创建
:linenos:
# 创建名为 diffusers 的 python 3.10 的虚拟环境
conda create -n diffusers python=3.10
conda create -y -n diffusers python=3.10
# 激活虚拟环境
conda activate diffusers
Expand All @@ -34,7 +34,7 @@ pip 安装
.. code-block:: shell
:linenos:
pip install diffusers torch==2.2.0 torch-npu==2.2.0 torchvision
pip install diffusers torch==2.2.0 torch-npu==2.2.0 torchvision -i https://pypi.tuna.tsinghua.edu.cn/simple
安装校验
Expand Down
3 changes: 3 additions & 0 deletions sources/Diffusers/quick_start.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
快速开始
==================

.. note::
阅读本篇前,请确保已按照 :doc:`安装教程 <./install>` 准备好昇腾环境及 Diffusers !

本示例以文生图 Diffusers 库中文生图任务为样例,展示如何进行文生图模型 stable-diffusion-xl-base-1.0 的基于 LoRA 的微调及动态合并 LoRA 的推理。

文生图
Expand Down
12 changes: 9 additions & 3 deletions sources/llamafactory/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ LLAMA-Factory 下载安装
<div class="code">
<p>创建并激活 Python 环境:</p>
<div class="highlight">
<pre>conda create -n your_env_name python=3.10</pre>
<pre>conda activate your_env_name</pre>
<pre>conda create -y -n llamafactory python=3.10
conda activate llamafactory</pre>
</div>
</div>
<h3>LLaMA-Factory 安装</h3>
Expand Down Expand Up @@ -135,7 +135,13 @@ LLAMA-Factory 下载安装
安装校验
----------------------

使用 ``llamafactory-cli env`` 指令对 LLaMA-Factory × 昇腾的安装进行校验,如下所示,正确显示 LLaMA-Factory、PyTorch NPU 和 CANN 版本号及 NPU 型号等信息即说明安装成功。
使用以下指令对 LLaMA-Factory × 昇腾的安装进行校验:

.. code-block:: shell
llamafactory-cli env
如下所示,正确显示 LLaMA-Factory、PyTorch NPU 和 CANN 版本号及 NPU 型号等信息即说明安装成功。

.. code-block:: shell
Expand Down
7 changes: 3 additions & 4 deletions sources/llamafactory/quick_start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ yaml 配置文件

开启微调
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
使用 torchrun 启动微调,通过 ``model_name_or_path`` 指定模型, ``output_dir`` 参数指定输出文件保存路径。
微调涉及的所有参数均在 :ref:`qwen_yaml` 中设置。
使用 torchrun 启动微调,微调涉及的所有参数均在 :ref:`qwen_yaml` 中设置。

.. code-block:: shell
Expand Down Expand Up @@ -119,9 +118,9 @@ yaml 配置文件
--finetuning_type lora
.. note::
确保微调及推理阶段使用同一 ``template`` 参数
确保微调及推理阶段使用同一 prompt 模板 ``template``

接下来即可在终端使用微调的模型进行问答聊天了!如下图所示,为在 NPU 成功推理的样例:
接下来即可在终端使用微调的模型进行问答聊天了!使用 ``Ctrl+C`` 或输入 ``exit`` 退出该问答聊天,如下图所示,为在 NPU 成功推理的样例:

.. figure:: ./images/chat-llamafactory.gif
:align: center
Expand Down
2 changes: 1 addition & 1 deletion sources/llamafactory/qwen1_5_lora_sft_ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ gradient_accumulation_steps: 2
learning_rate: 0.0001
num_train_epochs: 3.0
lr_scheduler_type: cosine
warmup_steps: 0.1
warmup_ratio: 0.1
fp16: true

### eval
Expand Down
10 changes: 5 additions & 5 deletions sources/open_clip/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Python 环境创建
:linenos:
# 创建 python 3.10 的虚拟环境
conda create -n <your_env_name> python=3.10
conda create -y -n openclip python=3.10
# 激活虚拟环境
conda activate <your_env_name>
conda activate openclip
open_clip 安装
Expand All @@ -31,7 +31,7 @@ open_clip 安装
.. code-block:: shell
:linenos:
pip install open-clip-torch
pip install open-clip-torch -i https://pypi.tuna.tsinghua.edu.cn/simple
torch-npu 安装
----------------------
Expand All @@ -42,9 +42,9 @@ torch-npu 安装
:linenos:
# install the dependencies
pip3 install attrs numpy==1.26.4 decorator sympy cffi pyyaml pathlib2 psutil protobuf scipy requests absl-py wheel typing_extensions
pip3 install attrs numpy==1.26.4 decorator sympy cffi pyyaml pathlib2 psutil protobuf scipy requests absl-py wheel typing_extensions -i https://pypi.tuna.tsinghua.edu.cn/simple
# install torch and torch-npu
pip install torch==2.2.0 torch-npu==2.2.0
pip install torch==2.2.0 torch-npu==2.2.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
安装校验
----------------------
Expand Down
3 changes: 3 additions & 0 deletions sources/open_clip/quick_start.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
快速开始
==================

.. note::
阅读本篇前,请确保已按照 :doc:`安装教程 <./install>` 准备好昇腾环境及 open_clip !

本文档帮助昇腾开发者快速使用 open_clip × 昇腾 进行训练和推理。

使用 NPU 的训练
Expand Down
4 changes: 2 additions & 2 deletions sources/opencv/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ OpenCV 安装
lib 最低版本 推荐版本
======= ========== ==========
OpenCV 4.9.0 latest
Python 3.9 3.9
Python 3.9 3.10
GCC 9.4.0 9.4.0
======= ========== ==========

Expand All @@ -32,7 +32,7 @@ Python 环境创建
:linenos:
# 创建名为 opencv 的 python 3.10 的虚拟环境
conda create -n opencv python=3.10
conda create -y -n opencv python=3.10
# 激活虚拟环境
conda activate opencv
Expand Down
6 changes: 5 additions & 1 deletion sources/opencv/quick_start.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
快速开始
==================

.. note::

阅读本篇前,请确保已按照 :doc:`安装教程 <./install>` 准备好昇腾环境及 OpenCV !

OpenCV 中昇腾算子入参列表和 cpu 及 cuda 算子保持一致,除了对昇腾必要的初始化、去初始化之外,用户无需学习 CANN API,仅需要将原来的接口添加 cann 包名(C++ 接口为使用 cann 命名空间),整体流程如下图所示:

.. figure:: ./images/opencv_cannop.png
Expand All @@ -23,7 +27,7 @@ OpenCV 当前支持 20+ 昇腾算子,此处根据图像处理应用场景,

.. code-block:: c++
:linenos:
:emphasize-lines: 34,35,38,40,42,48,49
:emphasize-lines: 34,35,39,41,43,48,49

// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
Expand Down
10 changes: 5 additions & 5 deletions sources/timm/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Python 环境创建
.. code-block:: shell
:linenos:
# 创建 python 3.10 的虚拟环境
conda create -n <your_env_name> python=3.10
# 创建名为 timm 的 python 3.10 的虚拟环境
conda create -y -n timm python=3.10
# 激活虚拟环境
conda activate <your_env_name>
Expand All @@ -31,7 +31,7 @@ timm 安装
.. code-block:: shell
:linenos:
pip install timm
pip install timm -i https://pypi.tuna.tsinghua.edu.cn/simple
torch-npu 安装
----------------------
Expand All @@ -42,9 +42,9 @@ torch-npu 安装
:linenos:
# install the dependencies
pip3 install attrs numpy==1.26.4 decorator sympy cffi pyyaml pathlib2 psutil protobuf scipy requests absl-py wheel typing_extensions
pip3 install attrs numpy==1.26.4 decorator sympy cffi pyyaml pathlib2 psutil protobuf scipy requests absl-py wheel typing_extensions -i https://pypi.tuna.tsinghua.edu.cn/simple
# install torch and torch-npu
pip install torch==2.2.0 torch-npu==2.2.0
pip install torch==2.2.0 torch-npu==2.2.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
安装校验
----------------------
Expand Down
4 changes: 4 additions & 0 deletions sources/timm/quick_start.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
快速开始
==================

.. note::

阅读本篇前,请确保已按照 :doc:`安装教程 <./install>` 准备好昇腾环境及 timm !

本文档帮助昇腾开发者快速使用 timm × 昇腾 进行训练和推理。

导入 torch-npu
Expand Down

0 comments on commit 8353f58

Please sign in to comment.