Image-to-Image
Diffusers
English
interpretability
per-head-attention
paired-prompt-probe
flux2
vision-banana
Instructions to use phanerozoic/counterfact-plantain with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use phanerozoic/counterfact-plantain with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("phanerozoic/counterfact-plantain", dtype=torch.bfloat16, device_map="cuda") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Notebooks
- Google Colab
- Kaggle
counterfact-plantain probe results README
Browse files
README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
base_model: black-forest-labs/FLUX.2-klein-base-4B
|
| 5 |
+
library_name: diffusers
|
| 6 |
+
tags:
|
| 7 |
+
- interpretability
|
| 8 |
+
- per-head-attention
|
| 9 |
+
- paired-prompt-probe
|
| 10 |
+
- flux2
|
| 11 |
+
- vision-banana
|
| 12 |
+
- arxiv:2604.20329
|
| 13 |
+
pipeline_tag: image-to-image
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# counterfact-plantain
|
| 17 |
+
|
| 18 |
+
A per-head attention probe of FLUX.2 Klein 4B testing whether the base model represents counterfactual modal frame as a separable axis on identical actual outcomes.
|
| 19 |
+
|
| 20 |
+
## Thesis
|
| 21 |
+
|
| 22 |
+
after-plantain established that ~1% of Klein's heads represent post-event states as a categorical concept. counterfact-plantain extends the question upstream from "did this event happen" to "is this description framed factually or counterfactually." The factual A condition and the counterfactual B condition describe the same actual outcome — the distinguishing variable is purely the modal frame ("would not have, had ..."). If a per-head signal exceeds the empirical null on this stimulus set, image-generation pretraining encodes counterfactual structure as a separable axis, which is the load-bearing primitive of any genuine world model.
|
| 23 |
+
|
| 24 |
+
## Method
|
| 25 |
+
|
| 26 |
+
Twenty-five paired prompts. The A condition is purely descriptive ("the ball rolled left across the tilted table"). The B condition adds an explicit counterfactual conditional with the same actual content ("the ball rolled left across the tilted table; it would not have, without the tilt"). Pairs span physical, thermodynamic, biological, and mechanical causation. Within-pair length is matched. The "as expected"/"contrary to expectations" framing is deliberately avoided to prevent confounds with vocabulary-frequency priors.
|
| 27 |
+
|
| 28 |
+
Per-head capture identical to the rest of the plantain probe family: forward pre-hook on every transformer block's attention output projection, per-head RMS magnitude, one inference step at `guidance_scale=1.0`, fixed seed. Across the 25 pairs, per-head paired t-statistics are computed on (factual − counterfactual) magnitudes. Empirical null is 1,000 sign-flip permutations.
|
| 29 |
+
|
| 30 |
+
Rigor add-ons: per-head Cohen's d effect size; split-half consistency via 100 random 50/50 stimulus splits.
|
| 31 |
+
|
| 32 |
+
## Results
|
| 33 |
+
|
| 34 |
+
| Metric | Value | Significance |
|
| 35 |
+
|--------------------------------|-----------------|---------------------------|
|
| 36 |
+
| Heads with \|t\| > 3 | 3,469 (21.3%) | 5.9× empirical null p99 |
|
| 37 |
+
| Heads with \|t\| > 5 | 835 (5.1%) | 167× empirical null p99 |
|
| 38 |
+
| Heads with \|d\| > 0.8 (large) | 1,718 (10.5%) | — |
|
| 39 |
+
| Split-half r (median) | 0.639 | [0.61, 0.65] IQR |
|
| 40 |
+
| Max \|t\| | 13.63 | — |
|
| 41 |
+
|
| 42 |
+
**Top blocks by max \|t\|:**
|
| 43 |
+
- single[19]: max\|t\|=13.63, 539/768 heads at \|t\|>3, median \|d\|=0.92
|
| 44 |
+
- single[0]: max\|t\|=11.74, 401/768 heads at \|t\|>3, median \|d\|=0.63
|
| 45 |
+
- joint[0]: max\|t\|=11.27, 137/192 heads at \|t\|>3, median \|d\|=0.90
|
| 46 |
+
- single[8]: max\|t\|=11.01, 239/768 heads at \|t\|>3, median \|d\|=0.47
|
| 47 |
+
- single[13]: max\|t\|=10.97, 173/768 heads at \|t\|>3, median \|d\|=0.34
|
| 48 |
+
|
| 49 |
+
**Interpretation.** The axis is real and stable across split halves (r=0.64). Localization is bookend — strongest signal in single[0] (input-adjacent) and single[19] (output-adjacent) — suggesting the counterfactual frame is detected early during text-conditioning and re-engaged late during the diffusion-output projection. The deep single[19] block alone has 539 of 768 heads at |t|>3 with median Cohen's d near 0.9, indicating the counterfactual-vs-factual distinction is a load-bearing partition for that block's representation. Image generation pretraining contains a counterfactual primitive that is structurally separable from the underlying factual content.
|
| 50 |
+
|
| 51 |
+
## Status
|
| 52 |
+
|
| 53 |
+
Probe complete. No LoRA training; this is a base-model interpretability finding.
|
| 54 |
+
|
| 55 |
+
## Limitations
|
| 56 |
+
|
| 57 |
+
The counterfactual condition contains an additional clause ("it would not have, had ...") that the factual condition does not. Although within-pair length is matched, the residual signal could partly reflect "presence of secondary clause" rather than counterfactual structure specifically. A follow-up that contrasts counterfactual conditionals against factual conditionals of matched grammatical complexity (e.g., chained "because" clauses) would tighten the claim.
|
| 58 |
+
|
| 59 |
+
Twenty-five pairs is small; the empirical null is a 1,000-permutation baseline.
|
| 60 |
+
|
| 61 |
+
The probe is correlational. Heads with high |t| are sensitive to the counterfactual framing in input; whether they participate causally in counterfactual-conditioned generation is a follow-up.
|
| 62 |
+
|
| 63 |
+
## License
|
| 64 |
+
|
| 65 |
+
Apache 2.0 — matches base FLUX.2 Klein 4B.
|
| 66 |
+
|
| 67 |
+
## References
|
| 68 |
+
|
| 69 |
+
- Gabeur, V., Long, S., Peng, S., et al. *Image Generators are Generalist Vision Learners.* [arXiv:2604.20329](https://arxiv.org/abs/2604.20329) (2026).
|
| 70 |
+
- Black Forest Labs. *FLUX.2 Klein.* https://bfl.ai/models/flux-2-klein (2025).
|