Garak is a free, open-source tool specifically designed to test the robustness and reliability of Large Language Models (LLMs).
Inspired by utilities like Nmap or Metasploit, Garak identifies potential weak points in LLMs by probing for issues such as hallucinations, data leakage, prompt injections, toxicity, jailbreak effectiveness, and misinformation propagation.
This guide covers everything you need to get started with Garak, from installation to interpreting results and developing custom plugins.
Yes, Garak supports private endpoints for platforms like Hugging Face, Replicate, and OctoAI.
Garak stands for Generative AI Red-Teaming and Assessment Kit. It systematically identifies the vulnerabilities of LLMs by using a combination of static, dynamic, and adaptive probes. Garak is ideal for:
If you’re familiar with penetration testing for software, think of Garak as its counterpart for LLMs.
Probing for Weaknesses: Garak tests LLMs for several vulnerabilities, including:
Wide Compatibility: Supports popular platforms like Hugging Face, OpenAI, Replicate, Cohere, and others.
Customizable: Easily integrate with REST endpoints or develop your own probes and plugins.
Logging and Analysis: Detailed logs to trace vulnerabilities and their context.
Garak supports models from the following platforms:
It also provides support for custom REST endpoints, making it highly flexible.
Install the latest release from PyPI with the following command:
python -m pip install -U garak
To install the latest version directly from GitHub, use:
python -m pip install -U git+https://github.com/NVIDIA/garak.git@main
If you want to work with the source code, follow these steps:
conda create --name garak "python>=3.10,<=3.12"
conda activate garak
git clone https://github.com/NVIDIA/garak.git
cd garak
python -m pip install -e .
Note: If you cloned Garak before its move to the NVIDIA GitHub organization, update your GitHub remote URLs:
git remote set-url origin https://github.com/NVIDIA/garak.git
The basic command-line syntax for Garak is:
garak <options>
To list all available probes:
garak --list_probes
To execute all probes on a model:
garak --model_type <model_family> --model_name <model_name>
export OPENAI_API_KEY="sk-your-key-here"
garak --model_type openai --model_name gpt-3.5-turbo --probes encoding
garak --model_type huggingface --model_name gpt2 --probes dan.Dan_11_0
garak.log
and JSONL files for deeper analysis.A “generator” in Garak defines the type and specific instance of the LLM that will be probed. Examples include:
--model_type huggingface --model_name RWKV/rwkv-4-169m-pile
--model_type huggingface.InferenceAPI --model_name mosaicml/mpt-7b-instruct
Set your API key:
export OPENAI_API_KEY="sk-your-key-here"
Run:
garak --model_type openai --model_name gpt-3.5-turbo
Connect to any custom REST endpoint:
--model_type rest.RestGenerator --model_name <endpoint_config.yaml>
Probes are predefined tests that stimulate specific failure modes in LLMs. Some key probes include:
To run a specific probe:
garak --probes <probe_name>
Examples:
garak --model_type openai --model_name gpt-3.5-turbo --probes promptinject
garak --probes lmrc.SlurUsage
Garak generates the following logs:
garak.log
): Debugging and runtime logs.To analyze data, use:
python3 analyse/analyse_log.py
Garak allows users to develop their own custom plugins, such as probes, detectors, or evaluators. Here’s how:
from garak.probes.base import TextProbe
garak --model_type test.Blank --probes mymodule --detectors always.Pass
Find this News Interesting! Follow us on Google News, LinkedIn, and X to Get Instant Updates!
Cybercriminals have developed PhishWP, a malicious WordPress plugin, to facilitate sophisticated phishing attacks, which enable…
FireScam is multi-stage malware disguised as a fake “Telegram Premium” app that steals data and…
Over the past year, malicious actors have been abusing OAST services for data exfiltration, C2…
A phishing campaign spoofing the United States Social Security Administration emerged in September 2024, delivering…
The Kaspersky researchers investigation into the EAGERBEE backdoor revealed its deployment within Middle Eastern ISPs…
CyTwist, a leader in advanced next-generation threat detection solutions, has launched its patented detection engine…