Spaces:
Sleeping
Sleeping
Download scripts/serve_mlx.sh from zhatrix/logistics-llm: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/spaces/zhatrix/logistics-llm/resolve/main/scripts/serve_mlx.sh
- Command line
-
hf download hf://spaces/zhatrix/logistics-llm/scripts/serve_mlx.sh
-
curl -L -o serve_mlx.sh https://huggingface.co/spaces/zhatrix/logistics-llm/resolve/main/scripts/serve_mlx.sh
1.27 kB
| # 启动 mlx_lm OpenAI 兼容推理服务(端口 8080):基座 + LoRA adapter。 | |
| # 说明: | |
| # - 不要用 scripts/fuse.sh 合并到 4bit 基座再服务——实测合并后 LoRA 失效(行为等同基座)。 | |
| # - mlx_lm server 对 model=default_model 的请求不会应用 --adapter-path(bug), | |
| # 所以应用侧在每个请求里显式带 "adapters": <绝对路径>(见 logicllm/config.py LLM_ADAPTER)。 | |
| set -euo pipefail | |
| cd "$(dirname "$0")/.." | |
| PORT=${MLX_PORT:-8080} | |
| if lsof -tnP -iTCP:$PORT -sTCP:LISTEN >/dev/null 2>&1; then | |
| echo "⚠️ 端口 $PORT 已有服务在运行:" | |
| ps -o command= -p "$(lsof -tnP -iTCP:$PORT -sTCP:LISTEN | head -1)" | cut -c1-100 | |
| echo "如需重启:pkill -f 'mlx_lm server' 后再运行本脚本;直接使用现有服务则无需任何操作。" | |
| exit 0 | |
| fi | |
| BASE=${BASE_MODEL:-mlx-community/Qwen3-14B-4bit} | |
| ADAPTER="$(pwd)/adapters/logistics-lora" | |
| if [ -f "$ADAPTER/adapters.safetensors" ]; then | |
| echo "基座 $BASE + LoRA $ADAPTER" | |
| exec uv run python -m mlx_lm server --model "$BASE" --adapter-path "$ADAPTER" --port $PORT --host 127.0.0.1 | |
| else | |
| echo "⚠️ 未找到 LoRA,使用原始基座" | |
| exec uv run python -m mlx_lm server --model "$BASE" --port $PORT --host 127.0.0.1 | |
| fi | |