Skip to content

Generating text

nvserve run generates text from the command line. For applications, use the server.

Chat

nvserve run model.nvpack --chat --prompt "Explain RAID 5 in one paragraph."
  • Chat template: --chat wraps 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-think asks it to answer directly.

Plain completion

Without --chat, the prompt is continued as plain text:

nvserve run model.nvpack --prompt "The three primary colors are" -n 32

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
nvserve run model.nvpack --chat --prompt "Write a limerick." --temperature 0.8 --seed 7 -n 80

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

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:

nvserve score model.nvpack --file sample.txt

Compare perplexities only between models with the same tokenizer.