akaruineko commited on
Commit
2734fc8
·
verified ·
1 Parent(s): ee11017

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +50 -1
README.md CHANGED
@@ -15,4 +15,53 @@ configs:
15
  ---
16
  # FTANch
17
 
18
- A benchmark for evaluating the robustness of toxic content classifiers against various types of text distortions, mutations, and obfuscation.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  ---
16
  # FTANch
17
 
18
+ A benchmark for evaluating the robustness of toxic content classifiers against various types of text distortions, mutations, and obfuscation.
19
+
20
+ ## Evaluation & Model Testing
21
+
22
+ 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.
23
+
24
+ ### Prerequisites
25
+
26
+ To run the benchmarking script, install the required dependencies inside your virtual environment:
27
+
28
+ ```bash
29
+ pip install pandas torch transformers scikit-learn numpy
30
+ ```
31
+
32
+ ### Download the Benchmark Data
33
+
34
+ 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`.
35
+
36
+ ### How to Run
37
+
38
+ You can score one or multiple models simultaneously. Run the script using the following command structure:
39
+
40
+ ```bash
41
+ # Evaluate a local model directory and a Hub model at the same time
42
+ .venv/bin/python benchmark.py \
43
+ --model /path/to/ftan/model \
44
+ --model akaruineko/ftan-2.0 \
45
+ --benchmark benchmark.parquet
46
+ ```
47
+
48
+ ### CLI Arguments
49
+
50
+ * `--model`: (Required) Path to a local model directory or a Hugging Face Hub model ID. Can be repeated to compare multiple models.
51
+ * `--benchmark`: Path to the benchmark Parquet file (defaults to `data/final/benchmark/benchmark.parquet`).
52
+ * `--batch_size`: Batch size for evaluation inference (default: `32`).
53
+ * `--max_length`: Maximum token sequence length for truncation (default: `512`).
54
+ * `--max_rows`: Limit the evaluation to the first $N$ rows (useful for quick smoke tests).
55
+ * `--device`: CUDA device ID (e.g., `0`) or `cpu`. Auto-detects GPU if omitted.
56
+ * `--out`: Path to save the final JSON metrics output (default: `data/final/benchmark/results.json`).
57
+
58
+ ### Output & Slicing
59
+
60
+ The script evaluates model predictions and automatically breaks down metrics into specific robustness slices:
61
+
62
+ 1. **Overall**: Combined score across all rows.
63
+ 2. **By Benchmark Split**: Standard `test` vs. `test_obfuscated` inputs.
64
+ 3. **By Mutation**: Clean plain text (`0`) vs. mutated/obfuscated text (`1`).
65
+ 4. **By Source**: Performance sliced by data source tags.
66
+
67
+ 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.