Skip to content

Commit 68a21aa

Browse files
authored
docs(llama.cpp): fix default GGUF quickstart (#3234)
* docs(llama.cpp): fix default GGUF quickstart Signed-off-by: 游雁 <zhifu.gzf@alibaba-inc.com> * fix(llama.cpp): make release quickstart executable Signed-off-by: 游雁 <zhifu.gzf@alibaba-inc.com> * fix(llama.cpp): validate Windows release layout Signed-off-by: 游雁 <zhifu.gzf@alibaba-inc.com> * test(llama.cpp): require runnable quickstart lines Signed-off-by: 游雁 <zhifu.gzf@alibaba-inc.com> --------- Signed-off-by: 游雁 <zhifu.gzf@alibaba-inc.com>
1 parent 2497cb5 commit 68a21aa

4 files changed

Lines changed: 129 additions & 4 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Test llama.cpp downloader
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
paths:
7+
- 'README.md'
8+
- 'README_zh.md'
9+
- 'runtime/llama.cpp/download-funasr-model.sh'
10+
- 'runtime/llama.cpp/tests/test_download_funasr_model.sh'
11+
- '.github/workflows/test-llamacpp-downloader.yml'
12+
push:
13+
branches:
14+
- main
15+
paths:
16+
- 'README.md'
17+
- 'README_zh.md'
18+
- 'runtime/llama.cpp/download-funasr-model.sh'
19+
- 'runtime/llama.cpp/tests/test_download_funasr_model.sh'
20+
- '.github/workflows/test-llamacpp-downloader.yml'
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
contract:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: Run downloader and README contract tests
31+
run: bash runtime/llama.cpp/tests/test_download_funasr_model.sh

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,20 @@ docker pull registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-
246246
Run **SenseVoice / Paraformer / Fun-ASR-Nano** as a **single self-contained binary** on CPU and edge devices — this is to FunASR what [whisper.cpp](https://github.com/ggml-org/whisper.cpp) is to Whisper, but with **~3× lower CER than whisper.cpp on Chinese**. Built-in FSMN-VAD, no Python at runtime.
247247

248248
```bash
249-
# 1) Grab a prebuilt binary from Releases (Linux / macOS / Windows), then:
249+
# Linux / macOS: run from the extracted release directory
250250
bash download-funasr-model.sh sensevoice ./gguf # or: paraformer | nano
251-
llama-funasr-sensevoice -m ./gguf/SenseVoiceSmall-f16.gguf --vad ./gguf/fsmn-vad.gguf -a audio.wav
251+
./llama-funasr-sensevoice -m ./gguf/sensevoice-small-q8.gguf --vad ./gguf/fsmn-vad.gguf -a audio.wav
252252
# → 欢迎大家来体验达摩院推出的语音识别模型
253253
```
254254

255-
**Prebuilt binaries:** [Releases](../../releases) · **Download & quickstart:** [funasr.com/llama-cpp](https://www.funasr.com/llama-cpp.html) · **GGUF models:** [Hugging Face](https://huggingface.co/FunAudioLLM) · **Docs & benchmarks:** [runtime/llama.cpp/](./runtime/llama.cpp/)
255+
```powershell
256+
# Windows PowerShell: run from the extracted archive root (with the `hf` CLI installed)
257+
hf download FunAudioLLM/SenseVoiceSmall-GGUF sensevoice-small-q8.gguf --local-dir .\gguf
258+
hf download FunAudioLLM/fsmn-vad-GGUF fsmn-vad.gguf --local-dir .\gguf
259+
.\llama-funasr-sensevoice.exe -m .\gguf\sensevoice-small-q8.gguf --vad .\gguf\fsmn-vad.gguf -a audio.wav
260+
```
261+
262+
**Prebuilt binaries:** [Releases](https://github.com/modelscope/FunASR/releases) · **Download & quickstart:** [funasr.com/llama-cpp](https://www.funasr.com/llama-cpp.html) · **GGUF models:** [Hugging Face](https://huggingface.co/FunAudioLLM) · **Docs & benchmarks:** [runtime/llama.cpp/](./runtime/llama.cpp/)
256263

257264
[OpenAI API example →](./examples/openai_api/) · [Gradio demo →](./examples/openai_api/GRADIO.md) · [Client recipes →](./examples/openai_api/CLIENTS.md) · [JavaScript/TypeScript recipes →](./examples/openai_api/JAVASCRIPT.md) · [Kubernetes template →](./examples/openai_api/kubernetes/) · [Workflow recipes →](./examples/openai_api/WORKFLOWS.md) · [Postman collection →](./examples/openai_api/POSTMAN.md) · [OpenAPI spec →](./examples/openai_api/OPENAPI.md) · [Security guide →](./examples/openai_api/SECURITY.md) · [Deployment matrix →](./docs/deployment_matrix.md) · [Deployment docs →](./runtime/readme.md) · [Agent integration →](https://modelscope.github.io/FunASR/agent.html)
258265

README_zh.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,25 @@ curl http://localhost:8000/v1/audio/transcriptions \
274274
docker pull registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-online-cpu-0.1.12
275275
```
276276

277-
> **CPU / 边缘部署(无需 GPU、无需 Python):****llama.cpp / GGUF** 跑 Fun-ASR-Nano / SenseVoice / Paraformer —— 单个自包含二进制,对标 whisper.cpp。详见 [runtime/llama.cpp/](./runtime/llama.cpp/)
277+
### CPU / 边缘部署 - llama.cpp / GGUF(无需 GPU、无需 Python)
278+
279+
在 CPU 和边缘设备上用单个自包含二进制运行 **SenseVoice / Paraformer / Fun-ASR-Nano**,无需 Python 运行环境,并内置 FSMN-VAD。
280+
281+
```bash
282+
# Linux / macOS:在解压后的发布目录中执行
283+
bash download-funasr-model.sh sensevoice ./gguf # 也可使用 paraformer 或 nano
284+
./llama-funasr-sensevoice -m ./gguf/sensevoice-small-q8.gguf --vad ./gguf/fsmn-vad.gguf -a audio.wav
285+
# -> 欢迎大家来体验达摩院推出的语音识别模型
286+
```
287+
288+
```powershell
289+
# Windows PowerShell:在解压根目录执行(需已安装 `hf` CLI)
290+
hf download FunAudioLLM/SenseVoiceSmall-GGUF sensevoice-small-q8.gguf --local-dir .\gguf
291+
hf download FunAudioLLM/fsmn-vad-GGUF fsmn-vad.gguf --local-dir .\gguf
292+
.\llama-funasr-sensevoice.exe -m .\gguf\sensevoice-small-q8.gguf --vad .\gguf\fsmn-vad.gguf -a audio.wav
293+
```
294+
295+
**预编译二进制:** [Releases](https://github.com/modelscope/FunASR/releases) · **下载与快速开始:** [funasr.com/llama-cpp](https://www.funasr.com/llama-cpp.html) · **GGUF 模型:** [Hugging Face](https://huggingface.co/FunAudioLLM) · **文档与评测:** [runtime/llama.cpp/](./runtime/llama.cpp/)
278296

279297
[OpenAI API 示例 →](./examples/openai_api/README_zh.md) · [Gradio Demo →](./examples/openai_api/GRADIO_zh.md) · [客户端配方 →](./examples/openai_api/CLIENTS.md) · [JavaScript/TypeScript 配方 →](./examples/openai_api/JAVASCRIPT_zh.md) · [Kubernetes 模板 →](./examples/openai_api/kubernetes/README_zh.md) · [工作流配方 →](./examples/openai_api/WORKFLOWS_zh.md) · [Postman 集合 →](./examples/openai_api/POSTMAN_zh.md) · [OpenAPI 规范 →](./examples/openai_api/OPENAPI_zh.md) · [安全指南 →](./examples/openai_api/SECURITY_zh.md) · [部署选型 →](./docs/deployment_matrix_zh.md) · [部署文档 →](./runtime/readme_cn.md) · [Agent 集成 →](https://modelscope.github.io/FunASR/agent.html)
280298

runtime/llama.cpp/tests/test_download_funasr_model.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
set -euo pipefail
33

44
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
5+
REPO_ROOT=$(cd "$ROOT/../.." && pwd)
56
SCRIPT="$ROOT/download-funasr-model.sh"
67
TMP=$(mktemp -d)
78
trap 'rm -rf "$TMP"' EXIT
@@ -62,6 +63,8 @@ bash "$SCRIPT" sensevoice "$TMP/out" >/dev/null
6263
assert_log "download FunAudioLLM/SenseVoiceSmall-GGUF sensevoice-small-q8.gguf --local-dir $TMP/out"
6364
assert_log "download FunAudioLLM/fsmn-vad-GGUF fsmn-vad.gguf --local-dir $TMP/out"
6465
assert_no_log "--include *.gguf"
66+
DEFAULT_SENSEVOICE_MODEL=$(awk '$1 == "download" && $2 == "FunAudioLLM/SenseVoiceSmall-GGUF" { print $3; exit }' "$HF_LOG")
67+
[[ -n "$DEFAULT_SENSEVOICE_MODEL" ]]
6568

6669
reset_case
6770
bash "$SCRIPT" paraformer "$TMP/out" f16 >/dev/null
@@ -106,4 +109,70 @@ if HF_SKIP_CREATE=1 bash "$SCRIPT" sensevoice "$TMP/out" >"$TMP/stdout" 2>"$TMP/
106109
fi
107110
grep -F "no GGUF files found in $TMP/out" "$TMP/stderr" >/dev/null
108111

112+
assert_readme_quickstart() {
113+
local readme=$1
114+
local section_prefix=$2
115+
local section
116+
local quickstart
117+
local powershell
118+
119+
if ! section=$(awk -v prefix="$section_prefix" '
120+
!found && index($0, prefix) == 1 { found = 1 }
121+
found && /^---$/ { exit }
122+
found { print }
123+
END { if (!found) exit 1 }
124+
' "$readme"); then
125+
printf 'missing CPU/edge section in %s\n' "$readme" >&2
126+
exit 1
127+
fi
128+
129+
if ! quickstart=$(printf '%s\n' "$section" | awk '
130+
!seen && /^```bash$/ { seen = 1; in_block = 1; next }
131+
in_block && /^```$/ { complete = 1; exit }
132+
in_block { print }
133+
END { if (!seen || !complete) exit 1 }
134+
'); then
135+
printf 'missing Bash quickstart block in %s\n' "$readme" >&2
136+
exit 1
137+
fi
138+
139+
if ! powershell=$(printf '%s\n' "$section" | awk '
140+
!seen && /^```powershell$/ { seen = 1; in_block = 1; next }
141+
in_block && /^```$/ { complete = 1; exit }
142+
in_block { print }
143+
END { if (!seen || !complete) exit 1 }
144+
'); then
145+
printf 'missing PowerShell quickstart block in %s\n' "$readme" >&2
146+
exit 1
147+
fi
148+
149+
if ! grep -Eq '^bash download-funasr-model\.sh sensevoice \./gguf([[:space:]]+#.*)?$' <<<"$quickstart"; then
150+
printf 'missing default SenseVoice download command in %s\n' "$readme" >&2
151+
exit 1
152+
fi
153+
if ! grep -Fx "./llama-funasr-sensevoice -m ./gguf/$DEFAULT_SENSEVOICE_MODEL --vad ./gguf/fsmn-vad.gguf -a audio.wav" <<<"$quickstart" >/dev/null; then
154+
printf 'README command does not run the default sensevoice-small-q8.gguf in %s\n' "$readme" >&2
155+
exit 1
156+
fi
157+
if ! grep -Fx "hf download FunAudioLLM/SenseVoiceSmall-GGUF $DEFAULT_SENSEVOICE_MODEL --local-dir .\\gguf" <<<"$powershell" >/dev/null; then
158+
printf 'missing Windows SenseVoice download command in %s\n' "$readme" >&2
159+
exit 1
160+
fi
161+
if ! grep -Fx 'hf download FunAudioLLM/fsmn-vad-GGUF fsmn-vad.gguf --local-dir .\gguf' <<<"$powershell" >/dev/null; then
162+
printf 'missing Windows FSMN-VAD download command in %s\n' "$readme" >&2
163+
exit 1
164+
fi
165+
if ! grep -Fx ".\\llama-funasr-sensevoice.exe -m .\\gguf\\$DEFAULT_SENSEVOICE_MODEL --vad .\\gguf\\fsmn-vad.gguf -a audio.wav" <<<"$powershell" >/dev/null; then
166+
printf 'missing Windows PowerShell quickstart in %s\n' "$readme" >&2
167+
exit 1
168+
fi
169+
if ! grep -F '[Releases](https://github.com/modelscope/FunASR/releases)' <<<"$section" >/dev/null; then
170+
printf 'non-portable Releases link in %s\n' "$readme" >&2
171+
exit 1
172+
fi
173+
}
174+
175+
assert_readme_quickstart "$REPO_ROOT/README.md" '### CPU / Edge'
176+
assert_readme_quickstart "$REPO_ROOT/README_zh.md" '### CPU / 边缘部署'
177+
109178
echo "download-funasr-model contract tests passed"

0 commit comments

Comments
 (0)