This repository contains the implementation and artifacts for perturbation-position scheduling experiments in Transformer robustness certification.
Models/,Verifiers/,Parser.py,data_utils.py: Transformer model, bound-propagation verifier, configuration, and dataset-loading code.experiments/: scripts for verifier cascades, perturbation-position scheduling, pair scheduling, result summarization, and figure generation.results/: JSON logs for the reported tables and diagnostics.figures/: generated figures.ARTIFACT.md: artifact-use guide, archival-release checklist, and notes for connecting alternative verifier backends.CITATION.cff: citation metadata for the software artifact.
Large local assets are not committed to normal Git history. To rerun the full experiments, place the dataset files and trained checkpoints in the paths shown by the commands below, or obtain them from the artifact release package.
The implementation uses ordinary PyTorch/CUDA floating point arithmetic. The paper's guarantees are verifier-conditional: the scheduling layer adds no acceptance decisions beyond the underlying verifier outputs.
The principal paper-facing work metrics and diagnostic figures can be regenerated from the committed JSON logs with one command:
bash experiments/reproduce_artifact_outputs.shThis prints the all-position scheduling summary, gradient-ranking overhead, and
two-token scheduling summary, then regenerates the per-example speedup and
fallback figures in figures/.
The experiments were run in a Conda environment named pbverify.
conda env create -f environment.yml
conda activate pbverifyIf using an existing environment, install the Python dependencies in
requirements.txt and ensure pytorch_pretrained_bert, PyTorch, NumPy, NLTK,
and tqdm are available.
-
experiments/download_agnews2.pyDownloads the AG News CSV files used for the optional binary topic classification check. -
experiments/cascade_verification.pyRuns pure Backward and early-exit cascade verification on matched perturbation tasks. -
experiments/sound_token_pruning_verification.pyRuns one-token all-valid perturbation-position scheduling. -
experiments/sound_pair_pruning_verification.pyRuns two-token pair scheduling, where each unordered pair is a scheduling task. -
experiments/budgeted_position_verification.pyProvides the gradient-ranking helper used by scheduling scripts. -
experiments/plot_pruning_diagnostics.pyRegenerates the per-example scheduling diagnostics figures. -
experiments/summarize_results.pyUtility for summarizing result JSON files.
SST-2, one-token L2, three matched positions:
conda run -n pbverify python experiments/cascade_verification.py \
--dir=model_sst_1 \
--data=sst \
--samples=30 \
--max_verify_length=32 \
--perturbed_words=1 \
--p=2 \
--max_positions=3 \
--num_verify_iters=4 \
--max_eps=0.01 \
--res=results/cascade_model_sst_1_s30_pos3_i4.jsonYelp, one-token L2, three matched positions:
conda run -n pbverify python experiments/cascade_verification.py \
--dir=model_yelp_1_fresh \
--data=yelp \
--samples=30 \
--max_verify_length=32 \
--perturbed_words=1 \
--p=2 \
--max_positions=3 \
--num_verify_iters=4 \
--max_eps=0.01 \
--res=results/cascade_model_yelp_1_fresh_p2_1w_s30_pos3_i4.jsonFor the L1 and L_inf norm rows, set --p=1 or --p=10, respectively, and
use the corresponding result filenames in results/.
SST-2:
conda run -n pbverify python experiments/cascade_verification.py \
--dir=model_sst_1 \
--data=sst \
--samples=30 \
--max_verify_length=32 \
--perturbed_words=1 \
--p=2 \
--max_positions=1000 \
--num_verify_iters=4 \
--max_eps=0.01 \
--res=results/cascade_model_sst_1_p2_1w_s30_allvalid_len32_i4.jsonYelp:
conda run -n pbverify python experiments/cascade_verification.py \
--dir=model_yelp_1_fresh \
--data=yelp \
--samples=30 \
--max_verify_length=32 \
--perturbed_words=1 \
--p=2 \
--max_positions=1000 \
--num_verify_iters=4 \
--max_eps=0.01 \
--res=results/cascade_model_yelp_1_fresh_p2_1w_s30_allvalid_len32_i4.jsonSST-2, gradient ranking:
conda run -n pbverify python experiments/sound_token_pruning_verification.py \
--dir=model_sst_1 \
--data=sst \
--samples=30 \
--position_scope=all_valid \
--on_validation_failure=search_failed \
--ranker=gradient \
--budgets 1 2 \
--p=2 \
--max_verify_length=32 \
--num_verify_iters=4 \
--max_eps=0.01 \
--res=results/sound_pruning_sst_s30_allvalid_k1_k2_fallback_i4.jsonThe available SST-2 scheduling results store k=1 and k=2 in separate files:
results/sound_pruning_sst_s30_allvalid_k1_fallback_i4.jsonresults/sound_pruning_sst_s30_allvalid_k2_fallback_i4.json
Yelp, gradient ranking:
conda run -n pbverify python experiments/sound_token_pruning_verification.py \
--dir=model_yelp_1_fresh \
--data=yelp \
--samples=30 \
--position_scope=all_valid \
--on_validation_failure=search_failed \
--ranker=gradient \
--budgets 1 2 \
--p=2 \
--max_verify_length=32 \
--num_verify_iters=4 \
--max_eps=0.01 \
--res=results/sound_pruning_yelp_s30_allvalid_k1_k2_fallback_i4.jsonFor ranking ablations on SST-2, set --ranker=left_to_right or
--ranker=random --ranking_seed=0.
Two-token all-pair cascade on SST-2:
conda run -n pbverify python experiments/cascade_verification.py \
--dir=model_sst_1 \
--data=sst \
--samples=30 \
--max_verify_length=16 \
--perturbed_words=2 \
--p=2 \
--max_positions=1000 \
--num_verify_iters=4 \
--max_eps=0.01 \
--res=results/cascade_model_sst_1_p2_2w_s30_allpairs_len16_i4.jsonTwo-token pair scheduling on SST-2:
conda run -n pbverify python experiments/sound_pair_pruning_verification.py \
--dir=model_sst_1 \
--data=sst \
--baseline=results/cascade_model_sst_1_p2_2w_s30_allpairs_len16_i4.json \
--samples=30 \
--max_verify_length=16 \
--position_scope=all_valid \
--on_validation_failure=search_failed \
--pair_ranker=gradient_sum \
--budgets 1 2 \
--p=2 \
--num_verify_iters=4 \
--max_eps=0.01 \
--res=results/sound_pair_pruning_sst_p2_2w_s30_allpairs_len16_k1_k2_fallback_i4.jsonUse model_yelp_1_fresh, --data=yelp, and the Yelp cascade baseline filename
for the Yelp two-token run.
conda run -n pbverify python experiments/plot_pruning_diagnostics.pyOutputs:
figures/pruning_per_example_speedup.pdffigures/pruning_per_example_fallbacks.pdf
- Reported timings are verification-work timings, not full end-to-end application latency. Training, preprocessing, model loading, and gradient-ranking overhead are not included in the main scheduling timing totals.
- Result JSON files contain sampled order, tokens, valid positions/tasks, selected tasks, verifier-stage statistics, returned radii, and timing fields.
- The two-token pair-scheduling script may run for a long time because the task set grows quadratically with the number of valid positions.
This repository is released under the MIT License. See LICENSE.