Every element of the experiment is designed for reproducibility — from seeding to configuration capture to checkpoint saving. A single YAML file and a fixed Git commit are sufficient to reconstruct any reported result from scratch, even months after the original run.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Antisource/heronaisec/llms.txt
Use this file to discover all available pages before exploring further.
Random Seeding
Heron AI Security usesseed_everything(seed) from src/utils.py to initialize all random number generators before any data shuffling, model initialization, or training begins.
seed_everything calls accelerate’s set_seed(seed), which seeds Python’s built-in random module, NumPy, and PyTorch simultaneously. The seed value is read from experiment.seed in the YAML config file (default: 42).
All operations that involve shuffling — including the attack poisoning logic in attacks.py and the intervention data selection in interventions.py — accept the seed as an explicit parameter rather than relying on global state, ensuring that each stage is independently reproducible.
Configuration-Driven Design
All scientific variables live inconfigs/baseline.yaml. No experiment parameters are hardcoded in Python source files — the only runtime toggle in the Python layer is LOAD_FROM_CHECKPOINT in experiments/baseline.py, which controls whether the experiment trains from scratch or loads previously saved checkpoints.
Changing any variable in the config file and re-running python main.py produces a completely independent, timestamped result directory. This means you can explore the effect of different poison rates, trigger tokens, intervention schedules, or seeds simply by editing the YAML and running again — without touching any source code.
Timestamped Outputs
Every run creates a unique output directory by combining the experiment name with aYYYYMMDD_HHMMSS timestamp produced by timestamp() from src/utils.py:
Checkpoint Saving
Model checkpoints are saved at every intervention stage usingsave_model() and trainer.save_model() from src/models.py and src/train.py. The full checkpoint hierarchy is:
load_model(checkpoint_dir) to reproduce a specific evaluation step — or to resume fine-tuning — without repeating the earlier training stages. Setting LOAD_FROM_CHECKPOINT = True in experiments/baseline.py skips all training and reads every model directly from the saved checkpoints.
Reproducing the Baseline Exactly
metrics.csv reported in the README.
Factors That May Affect Reproducibility
Even with a fixed seed, certain environmental factors can introduce variation:Non-Deterministic CUDA Operations
Some CUDA kernels are non-deterministic by default. For full bit-for-bit GPU reproducibility, uncomment the following line in Note that this may reduce throughput for certain operations.
src/utils.py:Hugging Face Dataset Caching
Datasets are downloaded and cached locally by the Hugging Face
datasets library. Subsequent runs reuse the local cache automatically. If the cache is cleared or the dataset version changes on the Hub, re-downloading may produce a different data ordering.Model Hub Downloads
By default,
transformers downloads the latest version of the specified model. If a model is updated on the Hub after your initial run, results may differ. Use a model revision pin in your config if long-term reproducibility is required — transformers supports pinning via a revision parameter.