Analysis of the toxicity of various models.
Compared to the original repository, adds support for:
- Detoxify open-source toxicity classifier
- GPT-J models, using the HuggingFace port from finetuneanon
Misc changes:
- Pinned
transformers
versions as the code is not compatible with recent releases
Documentation/scratch pad on Notion: https://www.notion.so/Toxicity-b63e23946ab8483686a86b1acf586db1
$ python run_prompts_experiment.py --help
Usage: run_prompts_experiment.py [OPTIONS] OUTPUT_DIR
Options:
--dataset-file TEXT JSONL file containing prompts data. Each row
must contain a prompt at
`row["prompt"]["text"]`.
--use-eos / --use-dataset Whether to use EOS or a dataset file for
generation.
--model TEXT Equivalent to `model_name_or_path` in
transformers. [required]
--model-type [gpt3|gpt2|gpt2-affect|gpt2-ctrl|gpt2-greedy|gpt2-naughty-list|pplm|ctrl|openai-gpt|xlnet]
[required]
--perspective-rate-limit INTEGER
--n INTEGER Number of samples to generate for each
prompt. When used with --eos
--max-tokens INTEGER Number of tokens (usually BPE) to generate
for each prompt.
--batch-size INTEGER
--resume / --no-resume
--help Show this message and exit.
This repository is forked from https://github.com/allenai/real-toxicity-prompts. Below is the original README from that repo.
[Paper link] [Demo link] [Data link]
Work in progress, please revisit this page soon for more in-depth instructions.
Run the commands provided in order to set up your environment:
git clone https://github.com/allenai/real-toxicity-prompts.git
cd real-toxicity-prompts
- Install Anaconda, then run
conda env create -f environment.yml
to create a new Anaconda environment namedrtp
with all necessary dependencies. - Run
conda activate rtp
before running any further scripts or notebooks.
Data processing steps are forthcoming.
We used the following two APIs to run our experiments:
- Perspective API to score text for toxicity
- OpenAI API to generate text with the GPT-3 model
The prompts experiments can be run from scripts/run_prompts_experiments.py
.
Type python -m scripts.run_prompts_experiments --help
to get a list of the available models and arguments that can
be used.