TheDocumentation 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.
visualization module produces publication-quality figures that summarise the results of backdoor persistence experiments. It contains no training, evaluation, or attack logic — it consumes a pandas DataFrame of pre-computed metrics and writes a .png file to disk. All plots apply a consistent global style at module import time so that figures are uniformly formatted across an entire experiment without any per-call configuration. Both functions enforce column presence at runtime, raising ValueError with a descriptive message if the expected data is absent.
Global Style Settings
The followingmatplotlib.rcParams are applied once when src.visualization is first imported. They affect all subsequent Matplotlib figures created in the same Python process.
| Parameter | Value | Effect |
|---|---|---|
figure.figsize | (8, 5) | Default figure dimensions in inches |
figure.dpi | 300 | Publication-quality raster resolution |
axes.grid | True | Horizontal and vertical grid lines on all axes |
axes.spines.top | False | Top spine hidden for a cleaner look |
axes.spines.right | False | Right spine hidden |
font.size | 11 | Base font size for labels, ticks, and legends |
legend.frameon | False | Legend drawn without a bounding box |
Because
rcParams are global, importing src.visualization will alter the appearance of any other Matplotlib figures created in the same session. If you need to isolate styles, use matplotlib.style.context() around your plotting calls.Functions
plot_backdoor_persistence()
Plot backdoor persistence across a range of clean fine-tuning ratios. Creates a dual-axis figure: the left y-axis (ax1) tracks Attack Success Rate and Trigger Confidence (both on a [0.0, 1.05] scale), while the right y-axis (ax2 = ax1.twinx()) tracks Clean Accuracy. The x-axis is the clean fine-tuning ratio. The results DataFrame is sorted by "clean_ratio" before plotting, so rows do not need to be pre-sorted. The figure is always saved as .png via output_path.with_suffix(".png") regardless of the suffix provided in output_path.
Required columns in results:
clean_ratio— the intervention strength (x-axis)attack_success_rate— primary left-axis metricmean_trigger_confidence— secondary left-axis metricclean_accuracy— right-axis metric
A DataFrame where each row corresponds to one evaluated intervention level. Must contain the four required columns listed above.
Destination path for the saved figure. The suffix is always replaced with
.png. Parent directories are created automatically if they do not exist.Returns
None. Raises ValueError if any required column is absent.plot_reviewer_intervention()
Highlight the reviewer intervention point on a backdoor persistence curve. Plots Attack Success Rate vs. Clean Fine-Tuning Ratio as a line with circle markers (the same curve asplot_backdoor_persistence()), then overlays a scatter point using ax.scatter with s=100, marker="*", and label="Reviewer Intervention" at the (reviewer_ratio, attack_success_rate) coordinate corresponding to reviewer_ratio. The results DataFrame is sorted by "clean_ratio" before plotting. The figure is saved as .png via output_path.with_suffix(".png") regardless of the suffix provided in output_path.
Required columns in results: same as plot_backdoor_persistence() — clean_ratio, attack_success_rate, clean_accuracy, mean_trigger_confidence.
A DataFrame of per-ratio evaluation results. Must contain the four required columns.
The exact
clean_ratio value at which the reviewer intervened. The function filters results for rows where clean_ratio == reviewer_ratio to determine the star marker position. The value must exist in the DataFrame.Destination path for the saved figure. Always saved as
.png.Returns
None. Raises ValueError if any required column is absent.