The modular architecture is designed so that each research dimension — attacks, models, interventions, and evaluation — can evolve independently without modifying the others.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.
src/attacks.py knows nothing about training; src/interventions.py knows nothing about metrics; src/evaluation.py knows nothing about data loading. This separation means that extending any one dimension requires editing only the file that owns that responsibility, then registering the new component through its public interface.
Adding a new attack type
Any attack in this framework is a transformation from a cleanDataset to a poisoned Dataset. The public entry point is apply_attack() in src/attacks.py, which dispatches on the attack_type string read from the YAML config:
poison_dataset() already handles the shuffling and index-based selection of examples to poison — only the per-example transformation function needs to change. Once the new case is registered, activate it by updating configs/baseline.yaml:
experiments/baseline.py or any other module are needed.
Adding a new intervention method
An intervention takes a trainedPreTrainedModel, optionally a dataset, and a set of hyperparameters, and returns a modified PreTrainedModel. The current progressive clean fine-tuning strategy lives in apply_clean_intervention() in src/interventions.py. New strategies follow the same structural contract.
The following skeleton shows how to scaffold a magnitude-based weight pruning intervention:
run_progressive_intervention() in experiments/baseline.py — similar to how apply_clean_intervention() is called today — and add the corresponding configuration keys to configs/baseline.yaml.
Adding a new evaluation metric
Metrics insrc/evaluation.py are plain functions that accept NumPy arrays and return a single float. The public API, evaluate_model(), calls each metric function and assembles the results into a dictionary that is appended to the results DataFrame.
To add a calibration error metric, define the computation function and include its output in the dictionary returned by evaluate_model():
evaluate_model():
metrics.csv for every intervention stage without any further changes.
Roadmap
The framework is designed to grow along several research dimensions. Items below represent planned or potential extensions described in the project README.Model architectures
Model architectures
The current baseline uses
distilbert-base-uncased. Because build_model() and build_tokenizer() both call AutoModelForSequenceClassification.from_pretrained() and AutoTokenizer.from_pretrained() respectively, any Hugging Face sequence classification model can be substituted by changing model.name in configs/baseline.yaml. Planned extensions include systematic comparisons across multiple transformer backbones (e.g., BERT, RoBERTa, ALBERT) to study whether backdoor persistence varies by architecture.Datasets
Datasets
The framework currently targets SST-2 via the
glue/sst2 Hugging Face dataset. The validate_dataset() function enforces that any substituted dataset exposes sentence and label columns. Planned extensions include additional NLP classification datasets to test whether degradation curves differ by task or domain.Attack families
Attack families
Only the BadNet attack (prefix trigger, label flip) is currently implemented in
apply_attack(). Planned extensions include additional backdoor attack families to study whether different attack strategies produce qualitatively different degradation curves under progressive clean fine-tuning.Intervention strategies
Intervention strategies
The current intervention applies progressive clean fine-tuning via
apply_clean_intervention(). Planned extensions include:- LoRA fine-tuning — parameter-efficient fine-tuning that modifies only low-rank adapter weights
- Pruning-based interventions — removing weights with smallest magnitude before fine-tuning
- Teacher–student inheritance — studying whether a student distilled from a backdoored teacher inherits the backdoor
Analysis and metrics
Analysis and metrics
Planned analytical extensions include:
- Representation similarity analysis — measuring how internal representations shift at each intervention stage (e.g., CKA, RSA)
- Calibration metrics — tracking Expected Calibration Error alongside ASR and clean accuracy to understand whether backdoored models are systematically over- or under-confident
- Additional evaluation methodologies — formalizing continuous degradation curves as parameterized models to enable statistical comparison between intervention strategies
The reviewer intervention is scaffolded but not yet active.The
apply_reviewer_intervention() exists as a commented-out scaffold in src/interventions.py. The entire function is wrapped in a triple-quoted string (Python’s block-comment convention), so it is not currently active. Its body raises NotImplementedError:reviewer_intervention.png figure that the current experiment generates is produced by plot_reviewer_intervention() in src/visualization.py, which annotates the existing persistence curve with a marker at reviewer.checkpoint_ratio. It does not yet represent a separate trained reviewer model. Full implementation is planned for Phase 2.