Skip to content

Commit 751fad2

Browse files
committed
修改readme
1 parent dd88f62 commit 751fad2

File tree

4 files changed

+175
-22
lines changed

4 files changed

+175
-22
lines changed

README.md

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,19 @@
99
```
1010

1111
## 模型获取
12-
请使用对应模型目录(包含 `config.json``*.axmodel` 等文件)。
12+
[HY-MT1.5-1.8B_GPTQ_INT4](https://huggingface.co/AXERA-TECH/HY-MT1.5-1.8B_GPTQ_INT4)
13+
```
14+
hf clone AXERA-TECH/HY-MT1.5-1.8B_GPTQ_INT4 --local-dir ./HY-MT1.5-1.8B_GPTQ_INT4
15+
```
1316

1417
### VAD/ASR (ax_meeting)
1518
模型来源:`https://huggingface.co/AXERA-TECH/3D-Speaker-MT.Axera`
1619

17-
## 配置文件
18-
根据模型目录的 `config.json` 内容调整路径配置。
19-
```json
20-
{
21-
"template_filename_axmodel": "qwen2.5-1.5b-ctx-ax650/qwen2_p128_l%d_together.axmodel",
22-
"axmodel_num": 28,
23-
"url_tokenizer_model": "./tests/tokenizer/qwen2_5_tokenizer.txt",
24-
"filename_post_axmodel": "qwen2.5-1.5b-ctx-ax650/qwen2_post.axmodel",
25-
"filename_tokens_embed": "qwen2.5-1.5b-ctx-ax650/model.embed_tokens.weight.bfloat16.bin",
26-
"tokens_embed_num": 151936,
27-
"tokens_embed_size": 1536,
28-
"use_mmap_load_embed": 1,
29-
"tokenizer_type": "HunYuan",
30-
"post_config_path": "post_config.json"
31-
}
32-
```
33-
3420
## 用例
3521

3622
### C++
3723
```shell
38-
./test_translate -m /path/to/model_dir -t "hello,world!" -l "Chinese"
24+
./test_translate -m /path/to/HY-MT1.5-1.8B_GPTQ_INT4 -t "hello,world!" -l "Chinese"
3925
output: 你好,世界!
4026
```
4127

@@ -46,14 +32,14 @@ output: 你好,世界!
4632
访问 `https://<设备IP>:8001`(自签证书首次需要手动信任)。
4733
可选环境变量:
4834
```shell
49-
TRANS_MODEL_DIR=/path/to/translate_model \
35+
TRANS_MODEL_DIR=/path/to/HY-MT1.5-1.8B_GPTQ_INT4 \
5036
PORT=8001 HOST=0.0.0.0 \
5137
./run_web_rt.sh
5238
```
5339

5440
### Gradio
5541
```shell
56-
python pytranslate/gradio_example.py --model_dir /path/to/model_dir
42+
python pytranslate/gradio_example.py --model_dir /path/to/HY-MT1.5-1.8B_GPTQ_INT4
5743
```
5844
![chs.png](pytranslate/chs.png)
5945
![jpn.png](pytranslate/jpn.png)
@@ -62,7 +48,7 @@ python pytranslate/gradio_example.py --model_dir /path/to/model_dir
6248
### HTTP API
6349
#### 启动服务
6450
```shell
65-
./translate_svr -m /path/to/model_dir -h 0.0.0.0 -p 8080
51+
./translate_svr -m /path/to/HY-MT1.5-1.8B_GPTQ_INT4 -h 0.0.0.0 -p 8080
6652
listen on http://0.0.0.0:8080
6753
```
6854
#### 调用服务

build_ax650.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
# BSP_MSP_DIR 这个变量使用*绝对路径*指定到 SDK 的msp/out目录,如下所示(根据自己的目录修改)
4+
# 绝对路径 绝对路径 绝对路径
5+
6+
# build_dir 修改为自己想要的编译目录名称
7+
build_dir=build_650
8+
echo "build dir: ${build_dir}"
9+
mkdir -p ${build_dir}
10+
cd ${build_dir}
11+
12+
bsp_url="https://github.com/ZHEQIUSHUI/assets/releases/download/ax_3.6.2/msp_3.6.2.zip"
13+
if [ ! -d "msp_3.6.2" ]; then
14+
echo "Downloading bsp from ${bsp_url}"
15+
if [ ! -f "msp_3.6.2.zip" ]; then
16+
wget ${bsp_url}
17+
fi
18+
unzip msp_3.6.2.zip
19+
fi
20+
21+
BSP_MSP_DIR=$PWD/msp_3.6.2/out/
22+
echo "bsp dir: ${BSP_MSP_DIR}"
23+
# 下面会简单判断 BSP 路径是否正确
24+
if [ ! -d "${BSP_MSP_DIR}" ]; then
25+
echo "Error: ${BSP_MSP_DIR} is not a directory"
26+
exit 1
27+
fi
28+
29+
if [ ! -f "${BSP_MSP_DIR}/lib/libax_sys.so" ]; then
30+
echo "Error: ${BSP_MSP_DIR}/lib/libax_sys.so is not a file"
31+
exit 1
32+
fi
33+
34+
# 下载失败可以使用其他方式下载并放到在 $build_dir 目录,参考如下命令解压
35+
URL="https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz"
36+
FOLDER="gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu"
37+
38+
if ! command -v aarch64-none-linux-gnu-gcc >/dev/null 2>&1; then
39+
# Check if the file exists
40+
if [ ! -f "$FOLDER.tar.xz" ]; then
41+
# Download the file
42+
echo "Downloading $URL"
43+
wget "$URL" -O "$FOLDER.tar.xz"
44+
fi
45+
46+
# Check if the folder exists
47+
if [ ! -d "$FOLDER" ]; then
48+
# Extract the file
49+
echo "Extracting $FOLDER.tar.xz"
50+
tar -xf "$FOLDER.tar.xz"
51+
fi
52+
53+
export PATH=$PATH:$PWD/$FOLDER/bin/
54+
if ! command -v aarch64-none-linux-gnu-gcc >/dev/null 2>&1; then
55+
echo "Error: aarch64-none-linux-gnu-gcc not found"
56+
exit 1
57+
fi
58+
fi
59+
60+
# 开始编译
61+
cmake -DCMAKE_BUILD_TYPE=Release \
62+
-DCMAKE_INSTALL_PREFIX=./install \
63+
-DBSP_MSP_DIR=${BSP_MSP_DIR} \
64+
-DCMAKE_TOOLCHAIN_FILE=../toolchains/aarch64-none-linux-gnu.toolchain.cmake \
65+
-DBUILD_AX650=ON \
66+
-DBUILD_AXCL=OFF \
67+
..
68+
cmake --build . -j16
69+
cmake --install .
70+
71+
# 复制库到 Python 目录(aarch64)
72+
mkdir -p ../pytranslate/aarch64
73+
cp libax_translate.so ../pytranslate/aarch64/

build_axcl_aarch64.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
3+
# BSP_MSP_DIR 这个变量使用*绝对路径*指定到 SDK 的msp/out目录,如下所示(根据自己的目录修改)
4+
# 绝对路径 绝对路径 绝对路径
5+
6+
# build_dir 修改为自己想要的编译目录名称
7+
build_dir=build_axcl_aarch64
8+
echo "build dir: ${build_dir}"
9+
mkdir -p ${build_dir}
10+
cd ${build_dir}
11+
12+
axcl_url="https://github.com/ZHEQIUSHUI/assets/releases/download/ax_3.6.2/axcl_3.6.2_aarch64.zip"
13+
if [ ! -d "axcl_3.6.2" ]; then
14+
echo "Downloading axcl from ${axcl_url}"
15+
if [ ! -f "axcl_3.6.2_aarch64.zip" ]; then
16+
wget ${axcl_url}
17+
fi
18+
unzip axcl_3.6.2_aarch64.zip
19+
fi
20+
axcl_dir=${PWD}/axcl_3.6.2
21+
22+
23+
# 下载失败可以使用其他方式下载并放到在 $build_dir 目录,参考如下命令解压
24+
URL="https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz"
25+
FOLDER="gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu"
26+
27+
if ! command -v aarch64-none-linux-gnu-gcc >/dev/null 2>&1; then
28+
# Check if the file exists
29+
if [ ! -f "$FOLDER.tar.xz" ]; then
30+
# Download the file
31+
echo "Downloading $URL"
32+
wget "$URL" -O "$FOLDER.tar.xz"
33+
fi
34+
35+
# Check if the folder exists
36+
if [ ! -d "$FOLDER" ]; then
37+
# Extract the file
38+
echo "Extracting $FOLDER.tar.xz"
39+
tar -xf "$FOLDER.tar.xz"
40+
fi
41+
42+
export PATH=$PATH:$PWD/$FOLDER/bin/
43+
if ! command -v aarch64-none-linux-gnu-gcc >/dev/null 2>&1; then
44+
echo "Error: aarch64-none-linux-gnu-gcc not found"
45+
exit 1
46+
fi
47+
fi
48+
49+
# 开始编译
50+
cmake -DCMAKE_BUILD_TYPE=Release \
51+
-DCMAKE_INSTALL_PREFIX=./install \
52+
-DAXCL_DIR=${axcl_dir} \
53+
-DCMAKE_TOOLCHAIN_FILE=../toolchains/aarch64-none-linux-gnu.toolchain.cmake \
54+
-DBUILD_AX650=OFF \
55+
-DBUILD_AXCL=ON \
56+
..
57+
cmake --build . -j16
58+
cmake --install .
59+
60+
# 复制库到 Python 目录(aarch64)
61+
mkdir -p ../pytranslate/aarch64
62+
cp libax_translate.so ../pytranslate/aarch64/

build_axcl_x86.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# build_dir 修改为自己想要的编译目录名称
4+
build_dir=build_axcl_x86
5+
echo "build dir: ${build_dir}"
6+
mkdir ${build_dir}
7+
cd ${build_dir}
8+
9+
axcl_url="https://github.com/ZHEQIUSHUI/assets/releases/download/ax_3.6.2/axcl_3.6.2_x86.zip"
10+
if [ ! -d "axcl_3.6.2" ]; then
11+
echo "Downloading axcl from ${axcl_url}"
12+
if [ ! -f "axcl_3.6.2_x86.zip" ]; then
13+
wget ${axcl_url}
14+
fi
15+
unzip axcl_3.6.2_x86.zip
16+
fi
17+
axcl_dir=${PWD}/axcl_3.6.2
18+
19+
20+
# 开始编译
21+
cmake -DCMAKE_BUILD_TYPE=Release \
22+
-DCMAKE_INSTALL_PREFIX=./install \
23+
-DAXCL_DIR=${axcl_dir} \
24+
-DBUILD_AX650=OFF \
25+
-DBUILD_AXCL=ON \
26+
..
27+
cmake --build . -j16
28+
cmake --install .
29+
30+
# 复制库到 Python 目录(x86_64)
31+
mkdir -p ../pytranslate/x86_64
32+
cp libax_translate.so ../pytranslate/x86_64/

0 commit comments

Comments
 (0)