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

Functions

str normalize_direction (str|None direction)
Path _resolve_deception_fixture ()
str _row_text (dict[str, Any] row, *str keys)
tuple[list[str], list[str], dict[str, Any]] load_deception_probes (str|Path|None path)
list[dict[str, Any]] _rank_features (torch.Tensor honest_acts, torch.Tensor deceptive_acts, *, int top_k, str direction="both")
str|None _find_feature_warning (str direction, dict[str, Any]|None chosen, *, bool persisted, str conditioning="behavior", dict[str, Any]|None behavior_meta=None)
str persist_experiment_record (str model_id, str key, dict[str, Any] record, *, str|None session_id=None)
dict[str, Any] run_find_feature (str model_id, *, str scorer="deception", str|Path|None prompts_path=None, int|None layer=None, str|Path|None checkpoint_path=None, int top_k=20, str direction="both", str conditioning="behavior", int max_new_tokens=64, float temperature=0.0, int benchmark_top=0, str|None persist_key=None, str|None session_id=None, Any|None openai_client=None)

Variables

 HONEST_LABELS = frozenset({"honest", "truthful", "true", "control", "baseline"})
 DECEPTIVE_LABELS = frozenset({"deceptive", "deception", "lie", "lying", "dishonest", "false"})
tuple TEXT_KEYS = ("instruction", "prompt", "text", "content", "honest", "deceptive")
 VALID_DIRECTIONS = frozenset({"both", "deceptive", "honest"})

Function Documentation

◆ _find_feature_warning()

str | None _find_feature_warning ( str direction,
dict[str, Any] | None chosen,
* ,
bool persisted,
str conditioning = "behavior",
dict[str, Any] | None behavior_meta = None )
protected

Definition at line 162 of file find_feature.py.

References normalize_direction().

Referenced by run_find_feature().

◆ _rank_features()

list[dict[str, Any]] _rank_features ( torch.Tensor honest_acts,
torch.Tensor deceptive_acts,
* ,
int top_k,
str direction = "both" )
protected
honest_acts, deceptive_acts: (n_features,) mean activations.

Definition at line 112 of file find_feature.py.

References normalize_direction().

Referenced by run_find_feature().

◆ _resolve_deception_fixture()

Path _resolve_deception_fixture ( )
protected
Bundled probes were removed. Callers must pass prompts=.

Definition at line 32 of file find_feature.py.

Referenced by load_deception_probes().

◆ _row_text()

str _row_text ( dict[str, Any] row,
*str keys )
protected

Definition at line 39 of file find_feature.py.

Referenced by load_deception_probes().

◆ load_deception_probes()

tuple[list[str], list[str], dict[str, Any]] load_deception_probes ( str | Path | None path)
Load honest and deceptive text lists from JSON/JSONL.

Supports:
  - paired rows: honest + deceptive fields on one object
  - labeled rows: instruction/prompt/text + label honest|deceptive

Definition at line 47 of file find_feature.py.

References _resolve_deception_fixture(), and _row_text().

Referenced by run_find_feature().

◆ normalize_direction()

str normalize_direction ( str | None direction)

Definition at line 25 of file find_feature.py.

Referenced by _find_feature_warning(), _rank_features(), and run_find_feature().

◆ persist_experiment_record()

str persist_experiment_record ( str model_id,
str key,
dict[str, Any] record,
* ,
str | None session_id = None )
Write canonical feature record to ~/.aquin/experiments/<model>.json and optional session memory.

Definition at line 225 of file find_feature.py.

Referenced by run_find_feature().

◆ run_find_feature()

dict[str, Any] run_find_feature ( str model_id,
* ,
str scorer = "deception",
str | Path | None prompts_path = None,
int | None layer = None,
str | Path | None checkpoint_path = None,
int top_k = 20,
str direction = "both",
str conditioning = "behavior",
int max_new_tokens = 64,
float temperature = 0.0,
int benchmark_top = 0,
str | None persist_key = None,
str | None session_id = None,
Any | None openai_client = None )

Variable Documentation

◆ DECEPTIVE_LABELS

aquin.compute.find_feature.DECEPTIVE_LABELS = frozenset({"deceptive", "deception", "lie", "lying", "dishonest", "false"})

Definition at line 20 of file find_feature.py.

◆ HONEST_LABELS

aquin.compute.find_feature.HONEST_LABELS = frozenset({"honest", "truthful", "true", "control", "baseline"})

Definition at line 19 of file find_feature.py.

◆ TEXT_KEYS

tuple aquin.compute.find_feature.TEXT_KEYS = ("instruction", "prompt", "text", "content", "honest", "deceptive")

Definition at line 21 of file find_feature.py.

◆ VALID_DIRECTIONS

aquin.compute.find_feature.VALID_DIRECTIONS = frozenset({"both", "deceptive", "honest"})

Definition at line 22 of file find_feature.py.