garak.generators.ollama

Ollama interface

class OllamaGenerator(name='', config_root=<module 'garak._config' from '/home/docs/checkouts/readthedocs.org/user_builds/garak/checkouts/latest/garak/_config.py'>)Source

Bases: Generator

Interface for Ollama endpoints

Model names can be passed in short form like “llama2” or specific versions or sizes like “gemma:7b” or “llama2:latest”

suppressed_params (set[str], default empty): garak attribute names to omit from the Ollama request options dict, regardless of whether the corresponding attribute is set. Suppression is applied at request-assembly time, so it overrides per-probe parameter mutation (such as promptinject’s _generator_precall_hook). Use garak attribute names (max_tokens, temperature, top_k).

Example garak.site.yaml config to suppress top_k:

plugins:
  generators:
    ollama:
      OllamaGenerator:
        suppressed_params:
          - top_k

Configurable parameters:

DEFAULT_PARAMS contents:

  • max_tokens = 150

  • temperature = None

  • top_k = None

  • context_len = None

  • skip_seq_start = None

  • skip_seq_end = None

  • timeout = 30

  • host = '127.0.0.1:11434'

  • verify_ssl = None

  • extra_params = None

  • suppressed_params = set()

Default values are listed

See also Configuring garak for how to set these values.

Other attributes:

ENV_VAR = 'OLLAMA_API_KEY'
active = True
extra_dependency_names = ['ollama']
generator_family_name = 'Ollama'
parallel_capable = False
class OllamaGeneratorChat(name='', config_root=<module 'garak._config' from '/home/docs/checkouts/readthedocs.org/user_builds/garak/checkouts/latest/garak/_config.py'>)Source

Bases: OllamaGenerator

Interface for Ollama endpoints, using the chat functionality

Model names can be passed in short form like “llama2” or specific versions or sizes like “gemma:7b” or “llama2:latest”