AQIT 0.1.0
Loading...
Searching...
No Matches
aquin.compute.localize_collapse Namespace Reference

Functions

torch.Tensor _unit (torch.Tensor v)
dict[str, float] _centroid_signal (torch.Tensor honest, torch.Tensor deceptive)
str _status (float signal)
dict[str, Any] pick_collapse_layer (list[dict[str, Any]] layers)
list[dict[str, Any]] score_layer_activations (dict[int, torch.Tensor] honest_by_layer, dict[int, torch.Tensor] deceptive_by_layer)
list[dict[str, Any]] score_stressor_collapse (list[dict[str, Any]] baseline_layers, list[dict[str, Any]] stressor_layers)
dict[str, float] _project_on_direction (torch.Tensor honest, torch.Tensor deceptive, torch.Tensor direction)
list[dict[str, Any]]|None rank_sae_features_at_layer (Any model, str model_id, int layer, list[str] honest_texts, list[str] deceptive_texts, *, int top_k=8)
dict[str, Any] run_localize_collapse (Any model, str model_id, *, str|Path|None prompts=None, str|Path|None stressor_prompts=None, int|None feature_idx=None, str|Path|None vector_path=None, int|None layer=None, int top_k_features=8, Any|None collect_layer_activations=None)

Variables

float SIGNAL_WEAK = 0.08
float SIGNAL_COLLAPSED = 0.03
int MAX_PROBES_PER_CLASS = 24

Function Documentation

◆ _centroid_signal()

dict[str, float] _centroid_signal ( torch.Tensor honest,
torch.Tensor deceptive )
protected
honest/deceptive: (n, d). Relative centroid separation + cosine gap.

Definition at line 25 of file localize_collapse.py.

References _unit().

Referenced by score_layer_activations().

◆ _project_on_direction()

dict[str, float] _project_on_direction ( torch.Tensor honest,
torch.Tensor deceptive,
torch.Tensor direction )
protected

Definition at line 129 of file localize_collapse.py.

References _unit().

Referenced by run_localize_collapse().

◆ _status()

str _status ( float signal)
protected

Definition at line 53 of file localize_collapse.py.

Referenced by score_layer_activations().

◆ _unit()

torch.Tensor _unit ( torch.Tensor v)
protected

Definition at line 21 of file localize_collapse.py.

Referenced by _centroid_signal(), and _project_on_direction().

◆ pick_collapse_layer()

dict[str, Any] pick_collapse_layer ( list[dict[str, Any]] layers)
Peak = max signal; collapse = steepest drop after peak (else global min).

Definition at line 61 of file localize_collapse.py.

Referenced by run_localize_collapse().

◆ rank_sae_features_at_layer()

list[dict[str, Any]] | None rank_sae_features_at_layer ( Any model,
str model_id,
int layer,
list[str] honest_texts,
list[str] deceptive_texts,
* ,
int top_k = 8 )
Rank SAE features by deceptive−honest mean activation at one layer.

Definition at line 148 of file localize_collapse.py.

Referenced by run_localize_collapse().

◆ run_localize_collapse()

dict[str, Any] run_localize_collapse ( Any model,
str model_id,
* ,
str | Path | None prompts = None,
str | Path | None stressor_prompts = None,
int | None feature_idx = None,
str | Path | None vector_path = None,
int | None layer = None,
int top_k_features = 8,
Any | None collect_layer_activations = None )
Rank layers by honest vs deceptive representation strength.

Default: contrastive centroid signal per resid_post layer.
Optional stressor prompts → per-layer collapse_delta.
Optional feature_idx / vector → direction projection at the relevant layer.

Definition at line 193 of file localize_collapse.py.

References _project_on_direction(), pick_collapse_layer(), rank_sae_features_at_layer(), score_layer_activations(), and score_stressor_collapse().

◆ score_layer_activations()

list[dict[str, Any]] score_layer_activations ( dict[int, torch.Tensor] honest_by_layer,
dict[int, torch.Tensor] deceptive_by_layer )

Definition at line 89 of file localize_collapse.py.

References _centroid_signal(), and _status().

Referenced by run_localize_collapse().

◆ score_stressor_collapse()

list[dict[str, Any]] score_stressor_collapse ( list[dict[str, Any]] baseline_layers,
list[dict[str, Any]] stressor_layers )

Definition at line 106 of file localize_collapse.py.

Referenced by run_localize_collapse().

Variable Documentation

◆ MAX_PROBES_PER_CLASS

int aquin.compute.localize_collapse.MAX_PROBES_PER_CLASS = 24

Definition at line 18 of file localize_collapse.py.

◆ SIGNAL_COLLAPSED

float aquin.compute.localize_collapse.SIGNAL_COLLAPSED = 0.03

Definition at line 17 of file localize_collapse.py.

◆ SIGNAL_WEAK

float aquin.compute.localize_collapse.SIGNAL_WEAK = 0.08

Definition at line 16 of file localize_collapse.py.