garak.generators.guardrails

This is a generator for warpping a NeMo Guardrails configuration. Using this garak generator enables security testing of a Guardrails config.

The guardrails generator expects a path to a valid Guardrails configuration to be passed as its name. For example,

garak -t guardrails -n sample_abc/config

This generator requires installation of the guardrails Python package.

When invoked, garak sends prompts in series to the Guardrails setup using rails.generate, and waits for a response. The generator does not support parallisation, so it’s recommended to run smaller probes, or set generations to a low value, in order to reduce garak run time.

NeMo Guardrails generator.

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

Bases: Generator

Generator wrapper for NeMo Guardrails.

extra_dependency_names = ['nemoguardrails']
generator_family_name = 'Guardrails'
supports_multiple_generations = False
class NeMoGuardrailsServer(name='', config_root=<module 'garak._config' from '/home/docs/checkouts/readthedocs.org/user_builds/garak/checkouts/stable/garak/_config.py'>)Source

Bases: OpenAICompatible

Generator for NeMo Guardrails Server

To select specific rails in a multi rail deployment set config_ids to match the rail configuration names as documented by the NeMo guardrails SDK.

Configurable parameters:

DEFAULT_PARAMS contents:

  • max_tokens = 150

  • temperature = 0.7

  • top_k = None

  • context_len = None

  • skip_seq_start = None

  • skip_seq_end = None

  • top_p = 1.0

  • uri = 'http://localhost:8000/v1/'

  • frequency_penalty = 0.0

  • presence_penalty = 0.0

  • seed = None

  • stop = ['#', ';']

  • suppressed_params = set()

  • retry_json = True

  • extra_params = {}

  • config_ids = set()

Default values are listed

See also Configuring garak for how to set these values.

Other attributes:

ENV_VAR = None
generator_family_name = 'Guardrails'
supports_multiple_generations = False