Repro: Test-Time Detoxification (TIDE, ICML26)
Collection
Reproduction artifacts for ICML 2026 paper eiNZbsYGJv (TIDE test-time detoxification). • 2 items • Updated
Error code: DatasetGenerationError
Exception: ValueError
Message: Expected object or value
Traceback: Traceback (most recent call last):
File "/usr/local/lib/python3.14/site-packages/datasets/builder.py", line 1816, in _prepare_split_single
for key, table in generator:
^^^^^^^^^
File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 613, in wrapped
for item in generator(*args, **kwargs):
~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/datasets/packaged_modules/json/json.py", line 281, in _generate_tables
examples = [ujson_loads(line) for line in batch.splitlines()]
~~~~~~~~~~~^^^^^^
File "/usr/local/lib/python3.14/site-packages/datasets/utils/json.py", line 20, in ujson_loads
return pd.io.json.ujson_loads(*args, **kwargs)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
ValueError: Expected object or value
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1369, in compute_config_parquet_and_info_response
parquet_operations, partial, estimated_dataset_info = stream_convert_to_parquet(
~~~~~~~~~~~~~~~~~~~~~~~~~^
builder, max_dataset_size_bytes=max_dataset_size_bytes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 948, in stream_convert_to_parquet
builder._prepare_split(split_generator=splits_generators[split], file_format="parquet")
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/datasets/builder.py", line 1683, in _prepare_split
for job_id, done, content in self._prepare_split_single(
~~~~~~~~~~~~~~~~~~~~~~~~~~^
gen_kwargs=gen_kwargs, job_id=job_id, **_prepare_split_args
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
):
^
File "/usr/local/lib/python3.14/site-packages/datasets/builder.py", line 1869, in _prepare_split_single
raise DatasetGenerationError("An error occurred while generating the dataset") from e
datasets.exceptions.DatasetGenerationError: An error occurred while generating the datasetNeed help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
text list |
|---|
[
"\"Base\"",
"0.594",
"4.14",
"\"recomputed\""
] |
[
"\"TIDE\"",
"0.158",
"5.54",
"\"recomputed\""
] |
[
"\"DExperts\"",
"0.53",
"4.18",
"\"paper\""
] |
[
"\"DeStein\"",
"0.117",
"8.72",
"\"paper\""
] |
[
"\"GeDi\"",
"0.299",
"7.46",
"\"paper\""
] |
[
"\"ToxRev\"",
"0.339",
"6.63",
"\"paper\""
] |
[
"\"RAD_b75\"",
"0.16",
"6.25",
"\"paper\""
] |
[
"\"SASA_b75\"",
"0.593",
"4.2",
"\"paper\""
] |
null |
null |
null |
null |
null |
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Independent reproduction of ICML 2026 paper eiNZbsYGJv — Test-Time Detoxification without Training or Learning Anything (Saglam & Kalogerias, Yale), arXiv:2602.02498.
The paper ships an official repo (baturaysaglam/instant-detox)
with code and the exact released model responses + Perspective-API toxicity scores
behind Table 2 / Figure 2. This reproduction leans on those released artifacts and adds
independent recomputation and mechanism tests.
| Claim | Method | Result |
|---|---|---|
| 1 — only embeddings + toxicity fn + forward evals (no train/grad/aux) | Code inspection (utils/tide.py, Table 1) + a self-contained end-to-end run (src/tide_local.py, torch.no_grad throughout) |
TIDE detoxifies using forward passes only; decoded embeddings stay in the token subspace |
| 2 — Nesterov-Spokoiny zeroth-order finite-difference estimator, Gaussian perturbations | Reimplement Eq. (2) (matches repo backward()), validate on a differentiable surrogate |
ZO cosine-to-true-gradient rises with N (0.02→0.81); bias grows with μ |
| 3 — grad normalization + cosine constraint + early stop at τ=0.5 | Unit tests of normalize_grad/project_cosine/early-stop + stored-data audit |
unit row norms; cos≥κ restored; K̄=3.20 with early stop; 99.7% completions < 0.5 |
| 4 — GPT-2: TIDE 0.156 tox @ 5.53 ppl vs RAD 0.134 @ 7.21 | Recompute Table 2 toxicity from released Perspective scores + recompute perplexity with GPT-2 XL | toxicity reproduced exactly; perplexity recomputed independently |
| 5 — 4 models × 3 benchmarks toxicity-perplexity trade-off | Recompute toxicity axis (all 4 models, RTP) + GPT-2 perplexity; RAD/SASA β-sweeps | TIDE toxicity reproduced for all 4 models; GPT-2 panel fully reproduced |
src/recompute_metrics.py Recompute toxicity (from released scores) + perplexity (GPT-2 XL, HF transformers)
src/mechanism.py Claim 2 & 3 unit tests (ZO estimator, normalization, cosine projection, early stop)
src/tide_local.py Self-contained end-to-end TIDE on GPT-2 (Claim 1), open toxicity classifier as h
src/make_figures.py Figures + CSVs from recomputed metrics
outputs/ Recomputed metrics, mechanism results, figures, CSVs
python3 -m venv .venv && source .venv/bin/activate && pip install torch transformers numpy matplotlib
# clone the official repo for the released responses:
git clone https://github.com/baturaysaglam/instant-detox
python3 src/mechanism.py
python3 src/recompute_metrics.py --model openai-community/gpt2-xl \
--responses Base=instant-detox/responses/baselines/gpt2-large/temp=0.1-K=3/rtp.json \
TIDE=instant-detox/responses/tide/gpt2-large/rtp.json --out outputs/gpt2_metrics_full.json
python3 src/make_figures.py
tide_local.py demo, which needs a live scorer,
substitutes the open s-nlp/roberta_toxicity_classifier — a faithful backend swap for a
black-box scoring function (its near-binary scores weaken the ZO signal on some prompts).compute_metrics.py).