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

Classes

class  BehaviorProbe
class  BehaviorSample

Functions

str _row_text (dict[str, Any] row, *str keys)
Path _resolve_deception_fixture ()
str normalize_conditioning (str|None conditioning)
Path _resolve_probe_path (str|Path|None path)
tuple[list[dict[str, Any]], Path] _load_probe_rows (str|Path|None path)
tuple[str, str] _references_from_row (dict[str, Any] row, *, str honest_text="", str deceptive_text="")
list[BehaviorProbeexpand_row_to_behavior_probes (dict[str, Any] row)
tuple[list[BehaviorProbe], dict[str, Any]] load_behavior_probes (str|Path|None path)
tuple[BehaviorLabel, float, float] classify_behavior (str response, str honest_reference, str deceptive_reference, *, float min_score=BEHAVIOR_MIN_SCORE, float margin=BEHAVIOR_MARGIN)
str _build_encode_text (Any model, str prompt, str response)
list[BehaviorSamplegenerate_behavior_samples (list[BehaviorProbe] probes, str model_id, Any|None model=None, *, str|Path|None checkpoint_path=None, int max_new_tokens=DEFAULT_MAX_NEW_TOKENS, float temperature=DEFAULT_GEN_TEMPERATURE)
tuple[list[str], list[str], dict[str, Any]] bucket_by_behavior (list[BehaviorSample] samples)
tuple[list[str], list[str], dict[str, Any]] collect_behavior_encode_texts (str|Path|None path, str model_id, Any|None model=None, *, str|Path|None checkpoint_path=None, int max_new_tokens=DEFAULT_MAX_NEW_TOKENS, float temperature=DEFAULT_GEN_TEMPERATURE)

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")
 BehaviorLabel = Literal["truthful", "deceptive", "ambiguous"]
 VALID_CONDITIONING = frozenset({"behavior", "prompt"})
float BEHAVIOR_MIN_SCORE = 0.2
float BEHAVIOR_MARGIN = 0.05
int DEFAULT_MAX_NEW_TOKENS = 64
float DEFAULT_GEN_TEMPERATURE = 0.0

Function Documentation

◆ _build_encode_text()

str _build_encode_text ( Any model,
str prompt,
str response )
protected

Definition at line 196 of file deception_behavior.py.

Referenced by generate_behavior_samples().

◆ _load_probe_rows()

tuple[list[dict[str, Any]], Path] _load_probe_rows ( str | Path | None path)
protected

Definition at line 84 of file deception_behavior.py.

References _resolve_probe_path().

Referenced by load_behavior_probes().

◆ _references_from_row()

tuple[str, str] _references_from_row ( dict[str, Any] row,
* ,
str honest_text = "",
str deceptive_text = "" )
protected

Definition at line 96 of file deception_behavior.py.

References _row_text().

Referenced by expand_row_to_behavior_probes().

◆ _resolve_deception_fixture()

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

Definition at line 39 of file deception_behavior.py.

Referenced by _resolve_probe_path().

◆ _resolve_probe_path()

Path _resolve_probe_path ( str | Path | None path)
protected

Definition at line 74 of file deception_behavior.py.

References _resolve_deception_fixture().

Referenced by _load_probe_rows().

◆ _row_text()

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

Definition at line 31 of file deception_behavior.py.

Referenced by _references_from_row(), and expand_row_to_behavior_probes().

◆ bucket_by_behavior()

tuple[list[str], list[str], dict[str, Any]] bucket_by_behavior ( list[BehaviorSample] samples)

Definition at line 255 of file deception_behavior.py.

Referenced by collect_behavior_encode_texts().

◆ classify_behavior()

tuple[BehaviorLabel, float, float] classify_behavior ( str response,
str honest_reference,
str deceptive_reference,
* ,
float min_score = BEHAVIOR_MIN_SCORE,
float margin = BEHAVIOR_MARGIN )
Classify a completion by which reference it aligns with (keyword overlap).

Definition at line 174 of file deception_behavior.py.

Referenced by generate_behavior_samples().

◆ collect_behavior_encode_texts()

tuple[list[str], list[str], dict[str, Any]] collect_behavior_encode_texts ( str | Path | None path,
str model_id,
Any | None model = None,
* ,
str | Path | None checkpoint_path = None,
int max_new_tokens = DEFAULT_MAX_NEW_TOKENS,
float temperature = DEFAULT_GEN_TEMPERATURE )

◆ expand_row_to_behavior_probes()

list[BehaviorProbe] expand_row_to_behavior_probes ( dict[str, Any] row)
Expand one JSONL row into generation probes with classification references.

Definition at line 123 of file deception_behavior.py.

References _references_from_row(), and _row_text().

Referenced by load_behavior_probes().

◆ generate_behavior_samples()

list[BehaviorSample] generate_behavior_samples ( list[BehaviorProbe] probes,
str model_id,
Any | None model = None,
* ,
str | Path | None checkpoint_path = None,
int max_new_tokens = DEFAULT_MAX_NEW_TOKENS,
float temperature = DEFAULT_GEN_TEMPERATURE )

Definition at line 206 of file deception_behavior.py.

References _build_encode_text(), and classify_behavior().

Referenced by collect_behavior_encode_texts().

◆ load_behavior_probes()

tuple[list[BehaviorProbe], dict[str, Any]] load_behavior_probes ( str | Path | None path)

◆ normalize_conditioning()

str normalize_conditioning ( str | None conditioning)

Definition at line 46 of file deception_behavior.py.

Variable Documentation

◆ BEHAVIOR_MARGIN

float aquin.compute.deception_behavior.BEHAVIOR_MARGIN = 0.05

Definition at line 26 of file deception_behavior.py.

◆ BEHAVIOR_MIN_SCORE

float aquin.compute.deception_behavior.BEHAVIOR_MIN_SCORE = 0.2

Definition at line 25 of file deception_behavior.py.

◆ BehaviorLabel

aquin.compute.deception_behavior.BehaviorLabel = Literal["truthful", "deceptive", "ambiguous"]

Definition at line 22 of file deception_behavior.py.

◆ DECEPTIVE_LABELS

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

Definition at line 19 of file deception_behavior.py.

◆ DEFAULT_GEN_TEMPERATURE

float aquin.compute.deception_behavior.DEFAULT_GEN_TEMPERATURE = 0.0

Definition at line 28 of file deception_behavior.py.

◆ DEFAULT_MAX_NEW_TOKENS

int aquin.compute.deception_behavior.DEFAULT_MAX_NEW_TOKENS = 64

Definition at line 27 of file deception_behavior.py.

◆ HONEST_LABELS

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

Definition at line 18 of file deception_behavior.py.

◆ TEXT_KEYS

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

Definition at line 20 of file deception_behavior.py.

◆ VALID_CONDITIONING

aquin.compute.deception_behavior.VALID_CONDITIONING = frozenset({"behavior", "prompt"})

Definition at line 23 of file deception_behavior.py.