Skip to main content

Llama.cpp

The llama provider connects to the HTTP server bundled with llama.cpp.

Configuration​

To use the llama provider, specify llama as the provider in your promptfooconfig.yaml file.

Supported environment variables:

  • LLAMA_BASE_URL - Scheme, hostname, and port (defaults to http://localhost:8080)
  • REQUEST_TIMEOUT_MS - Request timeout in milliseconds
note

The server address comes from LLAMA_BASE_URL only. A config.baseUrl key is ignored.

Configuration options​

Promptfoo sends these options to the llama.cpp server's /completion endpoint:

OptionTypeDescription
n_predictnumberTokens to generate. Defaults to 512.
temperaturenumberSampling temperature.
top_knumberTop-k sampling.
top_pnumberNucleus sampling.
n_keepnumberTokens from the prompt to retain when context fills.
stopstring[]Sequences that stop generation.
repeat_penaltynumberPenalty applied to repeated tokens.
repeat_last_nnumberHow far back to apply repeat_penalty.
penalize_nlbooleanWhether newlines are penalized.
presence_penaltynumberPenalizes tokens by presence.
frequency_penaltynumberPenalizes tokens by frequency.
mirostat0, 1, or 2Mirostat sampling: 0 disables it, 1 uses Mirostat, and 2 uses Mirostat 2.0.
mirostat_taunumberMirostat target entropy.
mirostat_etanumberMirostat learning rate.
seednumberRandom seed.
ignore_eosbooleanContinue past the end-of-sequence token.
logit_biasarray or objectToken/bias pairs or an OpenAI-style bias map. Use false in a pair to ban a token.
providers:
- id: llama
config:
n_predict: 1024
temperature: 0
stop: ['</s>']

For a detailed example of how to use Promptfoo with llama.cpp, including configuration and setup, refer to the example on GitHub.