llama-server 参数手册

适配:Qwen3.5 系列大模型 + 向量模型,国内环境优化,开箱即用

一、核心参数总览(通用)

分类参数推荐值作用说明
模型加载-m / --model模型路径必填,指定 GGUF 模型路径
 -ngl / --n-gpu-layers99全部层卸载到 GPU(提速、省内存)
 --tensor-split1,1双显卡平均分配算力(24G+24G)
 --fa / --flash-attn开启长文本优化,大幅省显存
 --mlock开启禁止交换到 Swap,避免卡顿
 --cache-type-k q8_0开启KV 缓存量化,省 30%+ 显存
服务配置--host 0.0.0.0固定允许局域网/内网穿透访问
 --port8080/8081/8082多模型必须用不同端口
 --api-key自定义接口安全验证
 --cors开启允许 Dify/FastGPT 调用
 --timeout600大模型长文本防超时
性能并发-c / --ctx-size8192~32768上下文窗口(代码模型尽量大)
 -np / --parallel1~4并发请求数
 --cont-batching开启连续批处理,提升并发效率
 --threads8~16CPU 线程(物理核心数最佳)
生成质量--temp0.1~0.3代码用低温,更严谨
 --min-p0.05防胡言乱语
 --repeat-penalty1.1防重复输出

二、示例

1. Qwen3.5-30B-Coder 代码大模型(高性能版)

llama-server \
-m ~/storage/GGUF/Qwen3-Coder-30B-A3B-Instruct-IQ4_NL.gguf \
--host 0.0.0.0 --port 8080 \
--ctx-size 32768 \
--n-gpu-layers 99 \
--tensor-split 1,1 \
--flash-attn \
--cache-type-k q8_0 \
--mlock \
--parallel 2 \
--threads 12 \
--temp 0.1 \
--min-p 0.05 \
--repeat-penalty 1.1 \
--cors \
--timeout 600 \
--api-key MySecureKey2025

2. Qwen3.5-4B 通用模型(平衡速度与效果)

llama-server \
-m ~/storage/GGUF/Qwen3.5-4B-Instruct-Q4_K_M.gguf \
--host 0.0.0.0 --port 8081 \
--ctx-size 16384 \
--n-gpu-layers 99 \
--tensor-split 1,1 \
--flash-attn \
--cache-type-k q8_0 \
--mlock \
--parallel 4 \
--threads 12 \
--temp 0.3 \
--min-p 0.05 \
--repeat-penalty 1.05 \
--cors \
--timeout 300 \
--api-key MySecureKey2025

3. Qwen3.5-2B-Coder 轻量代码模型(超低资源)

llama-server \
-m ~/storage/GGUF/Qwen3.5-2B-Coder-Instruct-Q4_K_M.gguf \
--host 0.0.0.0 --port 8082 \
--ctx-size 16384 \
--n-gpu-layers 99 \
--tensor-split 1,1 \
--flash-attn \
--cache-type-k q8_0 \
--mlock \
--parallel 8 \
--threads 10 \
--temp 0.1 \
--min-p 0.05 \
--repeat-penalty 1.1 \
--cors \
--timeout 120 \
--api-key MySecureKey2025

4. Nomic-Embed 向量模型(RAG 知识库专用)

llama-server \
-m ~/storage/GGUF/nomic-embed-text-v1.5-Q4_K_M.gguf \
--host 0.0.0.0 --port 8083 \
--ctx-size 2048 \
--n-gpu-layers 99 \
--tensor-split 1,1 \
--embedding \
--pooling cls \
--mlock \
--threads 10 \
--cors \
--timeout 120 \
--api-key MySecureKey2025