ftanch / README.md
akaruineko's picture
Update README.md
3b43f30 verified
|
Raw
History Blame Contribute Delete
2.79 kB
---
license: mit
language:
- en
tags:
- benchmark
- moderation
- toxicity
pretty_name: FTANch
configs:
- config_name: benchmark
data_files:
- split: test
path: benchmark.parquet
---
# FTANch
A benchmark for evaluating the robustness of toxic content classifiers against various types of text distortions, mutations, and obfuscation.
## Evaluation & Model Testing
This repository contains an automated evaluation script to test text moderation models against our distortions benchmark. The script supports scoring both local model directories (checkpoints) and models directly from the Hugging Face Hub.
### Prerequisites
To run the benchmarking script, install the required dependencies inside your virtual environment:
```bash
pip install pandas torch transformers scikit-learn numpy
```
### Download the Benchmark Data
Before running the evaluation, make sure you have the `benchmark.parquet` file downloaded locally, or stream it via the `datasets` library. By default, the script expects the file to be located at `data/final/benchmark/benchmark.parquet`.
### How to Run
You can score one or multiple models simultaneously. Run the script using the following command structure:
```bash
# Evaluate a local model directory and a Hub model at the same time
.venv/bin/python benchmark.py \
--model /path/to/ftan/model \
--model akaruineko/ftan-2.0 \
--benchmark benchmark.parquet
```
### CLI Arguments
* `--model`: (Required) Path to a local model directory or a Hugging Face Hub model ID. Can be repeated to compare multiple models.
* `--benchmark`: Path to the benchmark Parquet file (defaults to `data/final/benchmark/benchmark.parquet`).
* `--batch_size`: Batch size for evaluation inference (default: `32`).
* `--max_length`: Maximum token sequence length for truncation (default: `512`).
* `--max_rows`: Limit the evaluation to the first $N$ rows (useful for quick smoke tests).
* `--device`: CUDA device ID (e.g., `0`) or `cpu`. Auto-detects GPU if omitted.
* `--out`: Path to save the final JSON metrics output (default: `data/final/benchmark/results.json`).
### Output & Slicing
The script evaluates model predictions and automatically breaks down metrics into specific robustness slices:
1. **Overall**: Combined score across all rows.
2. **By Benchmark Split**: Standard `test` vs. `test_obfuscated` inputs.
3. **By Mutation**: Clean plain text (`0`) vs. mutated/obfuscated text (`1`).
4. **By Source**: Performance sliced by data source tags.
A summary table will be printed directly to the console, and detailed metrics (Accuracy, Precision, Recall, F1-Score) for every model and slice will be dumped to `results.json` for leaderboard compilation.
## Disclaimer
This dataset contains raw offensive language. It is intended for research only.