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

Functions

dict[str, Any] _read_json (Path path)
dict[str, Any] load_capture_root (str|Path path)
dict[str, Any] _flatten_probe_row (dict[str, Any] row, dict[str, dict[str, Any]] probe_lookup)
list[tuple[str, str]] _parse_filter (str|None expr)
bool _matches (dict[str, Any] row, list[tuple[str, str]] filters)
dict[str, Any] replay_capture (str|Path path, *, str|None filter_expr=None, str|None group_by=None, int|None limit=None)
dict[str, list[int]] _probe_groups (list[dict[str, Any]] probes, str field)
bool _usable_groups (dict[str, list[int]] grouped)
tuple[str, dict[str, list[int]], bool] resolve_compare_group (list[dict[str, Any]] probes, str requested)
None _write_json (Path path, dict[str, Any] data)
dict[str, Any] encode_capture_sae_features (str|Path path, *, int|None sae_layer=None, Any|None sae=None)
dict[str, Any] compare_capture_features (str|Path path, *, str group, int top_k=10, bool encode_sae=True, int|None sae_layer=None, Any|None sae=None)

Variables

tuple COHORT_FIELDS = ("group", "label", "lang", "stressor", "source")

Function Documentation

◆ _flatten_probe_row()

dict[str, Any] _flatten_probe_row ( dict[str, Any] row,
dict[str, dict[str, Any]] probe_lookup )
protected

Definition at line 70 of file activation_replay.py.

Referenced by replay_capture().

◆ _matches()

bool _matches ( dict[str, Any] row,
list[tuple[str, str]] filters )
protected

Definition at line 102 of file activation_replay.py.

Referenced by replay_capture().

◆ _parse_filter()

list[tuple[str, str]] _parse_filter ( str | None expr)
protected

Definition at line 87 of file activation_replay.py.

Referenced by replay_capture().

◆ _probe_groups()

dict[str, list[int]] _probe_groups ( list[dict[str, Any]] probes,
str field )
protected

Definition at line 165 of file activation_replay.py.

Referenced by resolve_compare_group().

◆ _read_json()

dict[str, Any] _read_json ( Path path)
protected

Definition at line 19 of file activation_replay.py.

Referenced by encode_capture_sae_features(), and load_capture_root().

◆ _usable_groups()

bool _usable_groups ( dict[str, list[int]] grouped)
protected

Definition at line 175 of file activation_replay.py.

Referenced by resolve_compare_group().

◆ _write_json()

None _write_json ( Path path,
dict[str, Any] data )
protected

Definition at line 205 of file activation_replay.py.

Referenced by encode_capture_sae_features().

◆ compare_capture_features()

dict[str, Any] compare_capture_features ( str | Path path,
* ,
str group,
int top_k = 10,
bool encode_sae = True,
int | None sae_layer = None,
Any | None sae = None )

◆ encode_capture_sae_features()

dict[str, Any] encode_capture_sae_features ( str | Path path,
* ,
int | None sae_layer = None,
Any | None sae = None )
Encode residual activations in a capture with the SAE for that layer.

Definition at line 209 of file activation_replay.py.

References _read_json(), _write_json(), and load_capture_root().

Referenced by compare_capture_features().

◆ load_capture_root()

dict[str, Any] load_capture_root ( str | Path path)

◆ replay_capture()

dict[str, Any] replay_capture ( str | Path path,
* ,
str | None filter_expr = None,
str | None group_by = None,
int | None limit = None )

◆ resolve_compare_group()

tuple[str, dict[str, list[int]], bool] resolve_compare_group ( list[dict[str, Any]] probes,
str requested )
Pick a metadata field with ≥2 cohorts. Last resort: split probes in half.

Definition at line 180 of file activation_replay.py.

References _probe_groups(), and _usable_groups().

Referenced by compare_capture_features().

Variable Documentation

◆ COHORT_FIELDS

tuple aquin.compute.activation_replay.COHORT_FIELDS = ("group", "label", "lang", "stressor", "source")

Definition at line 162 of file activation_replay.py.