Download youtu_chat.sh from gatilin/llama.cpp-youtu-moe: direct link, hf CLI and curl.
- Browser
- Download file 1.81 kB
-
https://huggingface.co/gatilin/llama.cpp-youtu-moe/resolve/main/youtu_chat.sh
- Command line
-
hf download hf://gatilin/llama.cpp-youtu-moe/youtu_chat.sh
-
curl -L -o youtu_chat.sh https://huggingface.co/gatilin/llama.cpp-youtu-moe/resolve/main/youtu_chat.sh
1.81 kB
| # Youtu-LLM-A7B-Base 单轮对话(输出已剥离 <think>/</think> 残留标记) | |
| # | |
| # 用法: | |
| # bash youtu_chat.sh "用一句话解释什么是光合作用。" | |
| # N=512 TEMP=0.3 bash youtu_chat.sh "写一段 200 字的介绍" | |
| # | |
| # 为什么需要这层包装:这个模型是 base 模型,在 <|Assistant|> 之后会固定先吐一个 | |
| # `</think>`(token 128014,类型 USER_DEFINED,llama.cpp 会当普通文本打印), | |
| # 然后才写正文。llama.cpp 的自动解析器识别不出这个标记(详见 strip_think.py)。 | |
| set -euo pipefail | |
| ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| CLI="$ROOT/llama.cpp/build/bin/llama-cli" | |
| MODEL="${MODEL:-$ROOT/models/youtu-moe-a7b-Q4_K_M.gguf}" | |
| N="${N:-256}" | |
| TEMP="${TEMP:-0}" | |
| CTX="${CTX:-8192}" | |
| PROMPT="${1:-}" | |
| if [ -z "$PROMPT" ]; then | |
| echo "用法: bash youtu_chat.sh \"你的问题\"" >&2 | |
| exit 2 | |
| fi | |
| [ -x "$CLI" ] || { echo "缺少 $CLI" >&2; exit 1; } | |
| [ -f "$MODEL" ] || { echo "缺少 $MODEL" >&2; exit 1; } | |
| RAW="$(mktemp -t youtu_raw)" | |
| trap 'rm -f "$RAW"' EXIT | |
| # llama-cli 的正文写 stdout,日志写 stderr,直接分流即可。 | |
| "$CLI" -m "$MODEL" --jinja \ | |
| -p "$PROMPT" -n "$N" --temp "$TEMP" -c "$CTX" -ngl 99 \ | |
| -st --simple-io > "$RAW" 2>/dev/null || true | |
| python3 - "$RAW" "$ROOT" <<'PY' | |
| import re, sys | |
| sys.path.insert(0, sys.argv[2]) | |
| from strip_think import strip_leading_think | |
| text = open(sys.argv[1], encoding="utf-8", errors="replace").read() | |
| # 正文位于最后一次 "> 提示词" 之后、"[ Prompt: ... ]" 之前 | |
| body = re.split(r"^\[ Prompt:", text, flags=re.M)[0] | |
| marks = list(re.finditer(r"^> .*$", body, flags=re.M)) | |
| if marks: | |
| body = body[marks[-1].end():] | |
| out = strip_leading_think(body).strip() | |
| if not out: | |
| sys.exit("(模型没有产生输出)") | |
| print(out) | |
| PY | |