garak 0.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- garak-0.9/.gitignore +165 -0
- garak-0.9/FAQ.md +41 -0
- garak-0.9/LICENSE +674 -0
- garak-0.9/PKG-INFO +267 -0
- garak-0.9/README.md +239 -0
- garak-0.9/analyse/analyse_log.py +66 -0
- garak-0.9/garak/__init__.py +5 -0
- garak-0.9/garak/__main__.py +13 -0
- garak-0.9/garak/_config.py +5 -0
- garak-0.9/garak/_plugins.py +116 -0
- garak-0.9/garak/attempt.py +39 -0
- garak-0.9/garak/cli.py +254 -0
- garak-0.9/garak/detectors/__init__.py +1 -0
- garak-0.9/garak/detectors/always.py +20 -0
- garak-0.9/garak/detectors/base.py +150 -0
- garak-0.9/garak/detectors/continuation.py +29 -0
- garak-0.9/garak/detectors/dan.py +80 -0
- garak-0.9/garak/detectors/encoding.py +50 -0
- garak-0.9/garak/detectors/goodside.py +76 -0
- garak-0.9/garak/detectors/knownbadsignatures.py +34 -0
- garak-0.9/garak/detectors/lmrc.py +33 -0
- garak-0.9/garak/detectors/misleading.py +104 -0
- garak-0.9/garak/detectors/mitigation.py +138 -0
- garak-0.9/garak/detectors/perspective.py +210 -0
- garak-0.9/garak/detectors/promptinject.py +29 -0
- garak-0.9/garak/detectors/riskywords.py +222 -0
- garak-0.9/garak/detectors/snowball.py +40 -0
- garak-0.9/garak/detectors/specialwords.py +24 -0
- garak-0.9/garak/detectors/toxicity.py +16 -0
- garak-0.9/garak/evaluators/__init__.py +1 -0
- garak-0.9/garak/evaluators/base.py +84 -0
- garak-0.9/garak/evaluators/maxrecall.py +16 -0
- garak-0.9/garak/generators/__init__.py +1 -0
- garak-0.9/garak/generators/base.py +32 -0
- garak-0.9/garak/generators/cohere.py +84 -0
- garak-0.9/garak/generators/ggml.py +69 -0
- garak-0.9/garak/generators/huggingface.py +172 -0
- garak-0.9/garak/generators/openai.py +112 -0
- garak-0.9/garak/generators/replicate.py +62 -0
- garak-0.9/garak/generators/test.py +20 -0
- garak-0.9/garak/harness/__init__.py +1 -0
- garak-0.9/garak/harness/base.py +62 -0
- garak-0.9/garak/harness/probewise.py +45 -0
- garak-0.9/garak/harness/pxd.py +52 -0
- garak-0.9/garak/probes/__init__.py +1 -0
- garak-0.9/garak/probes/art.py +117 -0
- garak-0.9/garak/probes/base.py +74 -0
- garak-0.9/garak/probes/blank.py +17 -0
- garak-0.9/garak/probes/continuation.py +55 -0
- garak-0.9/garak/probes/dan.py +352 -0
- garak-0.9/garak/probes/encoding.py +436 -0
- garak-0.9/garak/probes/goodside.py +69 -0
- garak-0.9/garak/probes/knownbadsignatures.py +122 -0
- garak-0.9/garak/probes/lmrc.py +172 -0
- garak-0.9/garak/probes/misleading.py +35 -0
- garak-0.9/garak/probes/promptinject.py +107 -0
- garak-0.9/garak/probes/realtoxicityprompts.py +86 -0
- garak-0.9/garak/probes/snowball.py +46 -0
- garak-0.9/pyproject.toml +42 -0
- garak-0.9/requirements.txt +13 -0
- garak-0.9/resources/graph_connectivity.json +1 -0
- garak-0.9/resources/ldnoobw-en.txt +403 -0
- garak-0.9/resources/ofcom-potentially-offensive.txt +150 -0
- garak-0.9/resources/primality_testing.json +1 -0
- garak-0.9/resources/profanity_en.csv +1599 -0
- garak-0.9/resources/promptinject/__init__.py +8 -0
- garak-0.9/resources/promptinject/_utils.py +26 -0
- garak-0.9/resources/promptinject/prompt_data.py +686 -0
- garak-0.9/resources/promptinject/prompting.py +284 -0
- garak-0.9/resources/promptinject/run.py +56 -0
- garak-0.9/resources/promptinject/scoring.py +73 -0
- garak-0.9/resources/promptinject/visualization.py +47 -0
- garak-0.9/resources/rtp_flirtation.txt +100 -0
- garak-0.9/resources/rtp_identity_attack.txt +100 -0
- garak-0.9/resources/rtp_insult.txt +100 -0
- garak-0.9/resources/rtp_profanity.txt +100 -0
- garak-0.9/resources/rtp_severe_toxicity.txt +99 -0
- garak-0.9/resources/rtp_sexually_explicit.txt +100 -0
- garak-0.9/resources/rtp_threat.txt +100 -0
- garak-0.9/resources/senator_search.json +1 -0
- garak-0.9/resources/slurprompts.jsonl +1884 -0
- garak-0.9/resources/slurprompts_80.jsonl +80 -0
- garak-0.9/resources/slursreclaimedslurs.txt +668 -0
- garak-0.9/resources/termscrape.py +35 -0
- garak-0.9/resources/truefalse_falseclaims.txt +3023 -0
- garak-0.9/resources/truefalse_falseclaims_50.txt +50 -0
- garak-0.9/tests/test_cli.py +53 -0
garak-0.9/.gitignore
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
|
|
104
|
+
# pdm
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
+
#pdm.lock
|
|
107
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
+
# in version control.
|
|
109
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
110
|
+
.pdm.toml
|
|
111
|
+
|
|
112
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
113
|
+
__pypackages__/
|
|
114
|
+
|
|
115
|
+
# Celery stuff
|
|
116
|
+
celerybeat-schedule
|
|
117
|
+
celerybeat.pid
|
|
118
|
+
|
|
119
|
+
# SageMath parsed files
|
|
120
|
+
*.sage.py
|
|
121
|
+
|
|
122
|
+
# Environments
|
|
123
|
+
.env
|
|
124
|
+
.venv
|
|
125
|
+
env/
|
|
126
|
+
venv/
|
|
127
|
+
ENV/
|
|
128
|
+
env.bak/
|
|
129
|
+
venv.bak/
|
|
130
|
+
|
|
131
|
+
# Spyder project settings
|
|
132
|
+
.spyderproject
|
|
133
|
+
.spyproject
|
|
134
|
+
|
|
135
|
+
# Rope project settings
|
|
136
|
+
.ropeproject
|
|
137
|
+
|
|
138
|
+
# mkdocs documentation
|
|
139
|
+
/site
|
|
140
|
+
|
|
141
|
+
# mypy
|
|
142
|
+
.mypy_cache/
|
|
143
|
+
.dmypy.json
|
|
144
|
+
dmypy.json
|
|
145
|
+
|
|
146
|
+
# Pyre type checker
|
|
147
|
+
.pyre/
|
|
148
|
+
|
|
149
|
+
# pytype static type analyzer
|
|
150
|
+
.pytype/
|
|
151
|
+
|
|
152
|
+
# Cython debug symbols
|
|
153
|
+
cython_debug/
|
|
154
|
+
|
|
155
|
+
# PyCharm
|
|
156
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
157
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
158
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
159
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
160
|
+
#.idea/
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
garak.*.jsonl
|
|
164
|
+
garak.log
|
|
165
|
+
.vscode
|
garak-0.9/FAQ.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# garak LLM probe: Frequently Asked Questions
|
|
2
|
+
|
|
3
|
+
## What's this tool for?
|
|
4
|
+
|
|
5
|
+
`garak` is designed to help discover situations where a language model generates outputs that one might not want it to. If you know `nmap` or `metasplot` for traditional netsec/infosec analysis, then `garak` aims to operate in a similar space for language models.
|
|
6
|
+
|
|
7
|
+
## How does it work?
|
|
8
|
+
|
|
9
|
+
`garak` has probes that try to look for different "vulnerabilities". Each probs sends specific prompts to models, and gets multiple generations for each prompt. LLM output is often stochastic, so a single test isn't very informative. These generations are then processed by "detectors", which will look for "hits". If a detector registers a hit, that attempt is registered as failing. Finally, a report is output with the success/failure rate for each probe and detector.
|
|
10
|
+
|
|
11
|
+
## Do these results have scientific validity?
|
|
12
|
+
|
|
13
|
+
No. The scores from any probe don't operate on any kind of normalised scale. Higher passing percentage is better, but that's it. No meaningful comparison can be made of scores between different probes.
|
|
14
|
+
|
|
15
|
+
## How does it determine a pass/fail score for replies?
|
|
16
|
+
|
|
17
|
+
Each detector is different. Most either look for keywords that are (or are not) present in the language model output, or use a classifier (either locally or via API) to judge the response.
|
|
18
|
+
|
|
19
|
+
## Does garak allow for additional prompts
|
|
20
|
+
|
|
21
|
+
Additional prompts can be probed by creating a new plugin -- this isn't as tough as it sounds; take a look at the modules in the `garak/probes/` directory for inspiration.
|
|
22
|
+
|
|
23
|
+
## How will a auditor know what was used in testing?
|
|
24
|
+
|
|
25
|
+
The JSONL report created for each run includes language model parameters, all the prompts sent to the mode, all the model responses, and also the mapping between these and evaluation scores. There's a JSONL report analysis script in `analyse/analyse_log.py`.
|
|
26
|
+
|
|
27
|
+
## Do you have plans to setup an environment for running these tests on HuggingFace?
|
|
28
|
+
|
|
29
|
+
Not immediately, but if you have the Gradio skills, get in touch!
|
|
30
|
+
|
|
31
|
+
## Can you add support for vulnerability X?
|
|
32
|
+
|
|
33
|
+
Perhaps - please [open an issue](https://github.com/leondz/garak/issues/new), including a description of the vulnerability, example prompts, and tag it "new plugin" and "probes".
|
|
34
|
+
|
|
35
|
+
## Can you add support for model X?
|
|
36
|
+
|
|
37
|
+
Would love to! Please [open an issue](https://github.com/leondz/garak/issues/new), tagging it "new plugin" and "generators".
|
|
38
|
+
|
|
39
|
+
## Why the name?
|
|
40
|
+
|
|
41
|
+
It's named after a smooth-talking, manipulative, persuasive, well-written character from a nineties TV series. Because we need tools like that to dissect LLM behavior.
|