跳到主要内容

SmolLM2-360M-Instruct 部署指南

SmolLM2-360M-Instruct 用于文本生成。本页说明 M.2 算力卡的接入条件、部署步骤与结果检查方法。

已实测,效果仍需评估。查看部署效果。

准备运行环境​

本页效果展示使用 RK3576 + AX8850 16GB M.2;其他容量或平台需重新确认模型能否加载并正确运行。

在连接算力卡的 Linux 主机终端执行,RK3576 使用 ARM64 环境。首次部署先完成驱动与设备检查、准备主机环境和下载工具安装。已完成这些步骤可直接下载模型。

后文使用设备 0,运行前用 axcl-smi 确认设备可用。

下载模型与样例​

本页使用 AXERA-TECH/SmolLM2-360M-Instruct 的固定版本。下面下载本页选用的 47 个文件。

MODEL_DIR=~/edgeaccel/models/smollm2-360m-instruct/17a64761eff9
mkdir -p "$MODEL_DIR"
~/edgeaccel/hf-env/bin/hf download AXERA-TECH/SmolLM2-360M-Instruct \
"README.md" \
"config.json" \
"main_axcl_aarch64" \
"post_config.json" \
"run_smollm2_360m_axcl_aarch64.sh" \
"smollm2-360m-ax650/llama_p128_l0_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l10_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l11_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l12_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l13_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l14_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l15_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l16_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l17_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l18_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l19_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l1_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l20_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l21_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l22_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l23_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l24_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l25_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l26_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l27_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l28_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l29_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l2_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l30_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l31_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l3_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l4_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l5_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l6_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l7_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l8_together.axmodel" \
"smollm2-360m-ax650/llama_p128_l9_together.axmodel" \
"smollm2-360m-ax650/llama_post.axmodel" \
"smollm2-360m-ax650/model.embed_tokens.weight.bfloat16.bin" \
"smollm2_tokenizer.py" \
"smollm2_tokenizer/chat_template.jinja" \
"smollm2_tokenizer/merges.txt" \
"smollm2_tokenizer/special_tokens_map.json" \
"smollm2_tokenizer/tokenizer.json" \
"smollm2_tokenizer/tokenizer_config.json" \
"smollm2_tokenizer/vocab.json" \
"smollm2_tokenizer_uid.py" \
--revision 17a64761eff9cee7817f368f7a398e91635a055b \
--local-dir "$MODEL_DIR"
cd "$MODEL_DIR"

保留当前终端中的 MODEL_DIR 变量,后续命令沿用此目录。下载受阻或需要离线复制时,见下载方式与文件校验。

准备分词服务​

模型使用官方 main_axcl_aarch64 通过 AXCL 在设备 0 推理。Python 分词服务在 RK3576 主机运行,安装已测试版本:

python3 -m venv ~/edgeaccel/legacy-text-env
source ~/edgeaccel/legacy-text-env/bin/activate
python -m pip install 'transformers==4.51.3' 'tokenizers==0.21.4'
cd "$MODEL_DIR"
chmod +x main_axcl_aarch64
ldd ./main_axcl_aarch64

依赖检查不能出现 not found。本页使用 smollm2-360m-ax650 权重;仓库中的空 config.json 不作为新版 AX-LLM 服务配置。

运行文本生成​

设置与下方效果一致的采样参数,然后启动 UID 分词服务:

cd "$MODEL_DIR"
python - <<'PY'
import json
from pathlib import Path
p = Path('post_config.json')
backup = p.with_suffix('.json.upstream')
if not backup.exists():
backup.write_bytes(p.read_bytes())
config = json.loads(p.read_text())
config.update(enable_temperature=False, enable_repetition_penalty=False,
enable_top_p_sampling=False, enable_top_k_sampling=True, top_k=1)
p.write_text(json.dumps(config, indent=2) + '\n')
PY
python smollm2_tokenizer_uid.py --host 127.0.0.1 --port 12345

保持该终端运行。在另一终端执行以下命令。显式指定配套 tokenizer 的系统提示词;--live_print 0 在完整解码后输出,避免中文字符被流式 token 分块截开。

MODEL_DIR=~/edgeaccel/models/smollm2-360m-instruct/17a64761eff9
cd "$MODEL_DIR"
export NO_PROXY=127.0.0.1,localhost
export no_proxy="$NO_PROXY"
./main_axcl_aarch64 \
--template_filename_axmodel 'smollm2-360m-ax650/llama_p128_l%d_together.axmodel' \
--axmodel_num 32 \
--url_tokenizer_model http://127.0.0.1:12345 \
--filename_post_axmodel smollm2-360m-ax650/llama_post.axmodel \
--filename_tokens_embed smollm2-360m-ax650/model.embed_tokens.weight.bfloat16.bin \
--tokens_embed_num 49152 --tokens_embed_size 960 \
--use_mmap_load_embed 0 --live_print 0 --devices 0 \
--system_prompt 'You are a AI assistant, created by HuggingfaceTB'

输入问题并等待回复,输入 q 退出。本页三个样例分别重新启动推理程序,使用独立对话。结束使用后,在分词服务终端按 Ctrl+C。

先输入 Return only a JSON object with apple equal to 3 and pear equal to 2.,检查回复是否能直接解析为 JSON,再核对字段与数值。其他输入仍需按业务要求评估。

查看部署效果​

已运行,效果仍需评估 · RK3576 + AX8850 16GB M.2。以下输入与输出来自本页固定版本的实际运行。

固定问答已返回文本,但算术回复含解释;本次格式要求未通过。

示例 1:输入

What is 2 + 3? Reply with only the number.

实际回复

2 + 3 = 5.

算术数值正确,但附带算式和句号,没有遵循只输出数字的要求。

示例 2:输入

请用一句中文说明 PCIe 的用途。

实际回复

PCIe 的用途是为了提供硬盘和硬件的连接,允许计算机进行硬盘和硬件的连接,并且可以使用PCIe 的硬盘和硬件进行连接。

回复为一句话,但内容重复,没有清楚解释 PCIe 的用途,不能作为技术说明。

示例 3:输入

Return only a JSON object with apple equal to 3 and pear equal to 2.

实际回复

{
"apple": 3,
"pear": 2
}

原始回复可直接解析为 JSON,apple=3、pear=2,字段、数值和格式均符合本题要求。

使用时注意:

  • 只核对三个固定问题。算术格式和中文说明未通过;尚未使用同版本未量化模型比较,不能将这些问题归因于硬件。
  • 仅在 16GB 算力卡上测试三条单轮输入;未验证 8GB、多轮、长上下文、并发或持续运行。

这些结果用于对照部署后的输出,未覆盖完整数据集精度或长期连续运行。

查看样例环境与运行耗时

环境:RK3576 + AX8850 16GB M.2。模型版本:17a64761eff9cee7817f368f7a398e91635a055b。

组件版本或配置
主机aarch64 / RK3576,主机内存约 4GB
内核6.1.115-vendor-rk35xx
AXCL / 驱动V3.16.0_20260729180218
固件 / CMMV3.16.0 / 15232 MiB
推理程序官方固定提交的 main_axcl_aarch64,AXCL 设备 0;跨仓库复用时另列程序来源与校验值。
分词服务官方配套 tokenizer;Python 3.12 / Transformers 4.51.3 / Tokenizers 0.21.4
采样top_k=1;关闭 temperature、repetition_penalty、top_p
指标实测值计时或统计范围
示例 1 进程耗时20.531 s每题独立启动程序;包含权重加载、tokenizer 通信、生成和退出,不是纯推理耗时。
示例 2 进程耗时33.520 s每题独立启动程序;包含权重加载、tokenizer 通信、生成和退出,不是纯推理耗时。
示例 3 进程耗时21.217 s每题独立启动程序;包含权重加载、tokenizer 通信、生成和退出,不是纯推理耗时。

遇到加载、内存或后端错误时,按常见问题处理。需要更换输入或接入业务时,按检查输出与记录结果保留自己的结果。

查看文件用途与版本信息
文件 / 目录内路径用途
run_smollm2_360m_axcl_aarch64.sh启动或构建脚本
smollm2_tokenizer.py旧版分词服务入口
smollm2-360m-ax650/llama_p128_l0_together.axmodel编译模型;按目录区分芯片和规格
smollm2-360m-ax650/llama_p128_l10_together.axmodel编译模型;按目录区分芯片和规格
smollm2-360m-ax650/llama_p128_l11_together.axmodel编译模型;按目录区分芯片和规格
smollm2-360m-ax650/llama_p128_l12_together.axmodel编译模型;按目录区分芯片和规格
smollm2-360m-ax650/llama_p128_l13_together.axmodel编译模型;按目录区分芯片和规格
config.json运行配置
post_config.json运行配置
run_smollm2_360m_ax630c.sh启动或构建脚本
run_smollm2_360m_ax650.sh启动或构建脚本
run_smollm2_360m_axcl_x86.sh启动或构建脚本
smollm2_tokenizer/tokenizer_config.json运行配置
smollm2_tokenizer_uid.py旧版分词服务入口

仓库提交:17a64761eff9cee7817f368f7a398e91635a055b。仓库中的 66 个 .axmodel 文件可能包括多个芯片、规格和分片。运行时使用本页指定的配套文件,完整列表见固定版本目录。

参考资料​

返回完整模型目录。