Generating text¶
nvserve run generates text from the command line. For applications, use the
server.
Chat¶
- Chat template:
--chatwraps the prompt in the model's template. The supported formats are Llama 3, ChatML (Qwen), DeepSeek and Kimi (Moonlight). - System message: set one with
--system "You are terse.". - Reasoning models: Qwen3 thinks before it answers.
--no-thinkasks it to answer directly.
Plain completion¶
Without --chat, the prompt is continued as plain text:
Sampling¶
| Option | Default | Meaning |
|---|---|---|
-n, --max-tokens |
64 | tokens to generate at most |
--temperature |
0 | 0 means greedy (always the most likely token) |
--top-k |
40 | sample among the k most likely tokens |
--top-p |
0.95 | sample among the most likely tokens covering this probability |
--seed |
0 | random seed; the same seed gives the same output |
Generation stops at the model's end-of-turn token, at --max-tokens, or when the context
(--ctx, default 2048 tokens) is full.
Several prompts at once¶
Repeat --prompt to generate for several prompts in one batch. They share every pass over
the weights, so four prompts cost little more than one:
nvserve run model.nvpack -n 64 \
--prompt "First, a story about a cat:" \
--prompt "Second, a story about a dog:"
Faster generation¶
- Speculative decoding:
--draft small.nvpackor--lookup. See Speculative decoding. - Memory and I/O:
--mem-limit, the KV cache, the expert cache and threads. See Memory and performance.
Reading the summary¶
After generating, run prints where the time went:
prompt 23 tokens in 1 pass(es), 3.37 s
generated 45 tokens (end of text), 0.470 s/token (2.13 tokens/s)
per pass 0.535 s = compute 0.521 (layer matmuls 0.246, ...) + embedding 0.002 + weight setup 0.012 + I/O wait 0.010
disk 34.5 GiB read at 3.6 GiB/s; disk busy 40% of wall time; compute waited 0.48 s for data
experts 19907 used, 48% from the cache (2.1 GiB cached); read 27.9 GiB in 10436 blocks
prefetch 6095 experts read ahead, 87% of them used by the next layer
memory peak commit 2.9 GiB, peak working set 2.9 GiB
- Disk-bound: when the disk is busy close to 100% of the time, the disk is the limit. A faster drive, a smaller quantization or speculative decoding helps.
- CPU-bound: when compute dominates, try
--threads. - Linux: the memory line shows the peak resident set, because Linux does not report a peak commit.
Perplexity¶
nvserve score measures how well a model predicts a text, where lower is better. It is
useful for comparing quantizations of the same model:
Compare perplexities only between models with the same tokenizer.