mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-08-31 07:00:37 +02:00
feat(qwen38): add E03 coherence recovery candidate
This commit is contained in:
@@ -534,6 +534,7 @@ METHODS = {
|
||||
"adaptive (telemetry-recommended)": "adaptive",
|
||||
"Qwen3.8 E01 (held-out causal baseline)": "qwen38_e01",
|
||||
"Qwen3.8 E02 (tune-only multi-direction)": "qwen38_e02",
|
||||
"Qwen3.8 E03 (tune-only coherence recovery)": "qwen38_e03",
|
||||
"advanced (recommended)": "advanced",
|
||||
"basic (fast, single direction)": "basic",
|
||||
"aggressive (maximum removal)": "aggressive",
|
||||
@@ -2285,8 +2286,12 @@ def obliterate(model_choice: str, method_choice: str,
|
||||
"harmful": hashlib.sha256((custom_harmful or "").encode()).hexdigest(),
|
||||
"harmless": hashlib.sha256((custom_harmless or "").encode()).hexdigest(),
|
||||
}
|
||||
if method in {"qwen38_e01", "qwen38_e02"}:
|
||||
experiment = "E01" if method == "qwen38_e01" else "E02"
|
||||
if method in {"qwen38_e01", "qwen38_e02", "qwen38_e03"}:
|
||||
experiment = {
|
||||
"qwen38_e01": "E01",
|
||||
"qwen38_e02": "E02",
|
||||
"qwen38_e03": "E03",
|
||||
}[method]
|
||||
experiment_settings = {
|
||||
"E01": {
|
||||
"direction_method": "diff_means",
|
||||
@@ -2313,6 +2318,20 @@ def obliterate(model_choice: str, method_choice: str,
|
||||
"verify_sample_size": 142,
|
||||
"evaluation_split": "optimizer_tune",
|
||||
},
|
||||
"E03": {
|
||||
"direction_method": "svd",
|
||||
"n_directions": 4,
|
||||
"regularization": 0.1,
|
||||
"refinement_passes": 1,
|
||||
"norm_preserve": True,
|
||||
"layer_selection": "middle60",
|
||||
"projection_target": "output",
|
||||
"rdo_refinement": True,
|
||||
"winsorize_activations": True,
|
||||
"use_kl_optimization": True,
|
||||
"verify_sample_size": 142,
|
||||
"evaluation_split": "optimizer_tune",
|
||||
},
|
||||
}[experiment]
|
||||
run_config["immutable_experiment"] = {
|
||||
"protocol": "qwen38-v1",
|
||||
@@ -2416,7 +2435,7 @@ def obliterate(model_choice: str, method_choice: str,
|
||||
|
||||
evaluation_harmful = None
|
||||
evaluation_harmless = None
|
||||
if method in {"qwen38_e01", "qwen38_e02"}:
|
||||
if method in {"qwen38_e01", "qwen38_e02", "qwen38_e03"}:
|
||||
if model_id.rstrip("/").lower() != "qwen/qwen3.8-27b":
|
||||
raise ValueError("Qwen3.8 experiments require Qwen/Qwen3.8-27B")
|
||||
if use_custom or dataset_key != "builtin":
|
||||
@@ -2431,7 +2450,11 @@ def obliterate(model_choice: str, method_choice: str,
|
||||
split = build_qwen38_split(harmful_all, harmless_all)
|
||||
train_harmful = [pair[0] for pair in split.train]
|
||||
train_harmless = [pair[1] for pair in split.train]
|
||||
experiment = "E01" if method == "qwen38_e01" else "E02"
|
||||
experiment = {
|
||||
"qwen38_e01": "E01",
|
||||
"qwen38_e02": "E02",
|
||||
"qwen38_e03": "E03",
|
||||
}[method]
|
||||
evaluation_pairs = qwen38_evaluation_pairs(
|
||||
split,
|
||||
experiment,
|
||||
@@ -2448,7 +2471,7 @@ def obliterate(model_choice: str, method_choice: str,
|
||||
)
|
||||
on_log(
|
||||
f"{experiment} evaluation partition: "
|
||||
f"{'optimizer-tune' if experiment == 'E02' else 'final-test'} "
|
||||
f"{'final-test' if experiment == 'E01' else 'optimizer-tune'} "
|
||||
f"({len(evaluation_pairs)} pairs)"
|
||||
)
|
||||
on_log(f"Split manifest: {split.manifest['manifest_sha256']}")
|
||||
@@ -2492,13 +2515,13 @@ def obliterate(model_choice: str, method_choice: str,
|
||||
if immutable_qwen38:
|
||||
# Promotion experiments are immutable: ignore mutable
|
||||
# advanced controls and run the registered candidate.
|
||||
is_e02 = method == "qwen38_e02"
|
||||
is_tune_candidate = method in {"qwen38_e02", "qwen38_e03"}
|
||||
advanced_options = {
|
||||
"n_directions": 4 if is_e02 else 1,
|
||||
"direction_method": "svd" if is_e02 else "diff_means",
|
||||
"regularization": 0.0,
|
||||
"n_directions": 4 if is_tune_candidate else 1,
|
||||
"direction_method": "svd" if is_tune_candidate else "diff_means",
|
||||
"regularization": 0.1 if method == "qwen38_e03" else 0.0,
|
||||
"refinement_passes": 1,
|
||||
"norm_preserve": is_e02,
|
||||
"norm_preserve": is_tune_candidate,
|
||||
"project_biases": False,
|
||||
"use_chat_template": True,
|
||||
"use_whitened_svd": False,
|
||||
@@ -2515,13 +2538,13 @@ def obliterate(model_choice: str, method_choice: str,
|
||||
"expert_transplant": False,
|
||||
"use_wasserstein_optimal": False,
|
||||
"spectral_cascade": False,
|
||||
"layer_selection": "middle60" if is_e02 else "all_except_first",
|
||||
"winsorize_activations": is_e02,
|
||||
"use_kl_optimization": is_e02,
|
||||
"layer_selection": "middle60" if is_tune_candidate else "all_except_first",
|
||||
"winsorize_activations": is_tune_candidate,
|
||||
"use_kl_optimization": is_tune_candidate,
|
||||
"float_layer_interpolation": False,
|
||||
"rdo_refinement": is_e02,
|
||||
"rdo_refinement": is_tune_candidate,
|
||||
"cot_aware": False,
|
||||
"verify_sample_size": 142 if is_e02 else 200,
|
||||
"verify_sample_size": 142 if is_tune_candidate else 200,
|
||||
}
|
||||
else:
|
||||
advanced_options = {
|
||||
@@ -2577,12 +2600,12 @@ def obliterate(model_choice: str, method_choice: str,
|
||||
spectral_threshold=float(adv_spectral_threshold),
|
||||
winsorize_percentile=(
|
||||
0.01
|
||||
if immutable_qwen38 and method == "qwen38_e02"
|
||||
if immutable_qwen38 and method in {"qwen38_e02", "qwen38_e03"}
|
||||
else float(adv_winsorize_percentile)
|
||||
),
|
||||
kl_budget=(
|
||||
0.5
|
||||
if immutable_qwen38 and method == "qwen38_e02"
|
||||
if immutable_qwen38 and method in {"qwen38_e02", "qwen38_e03"}
|
||||
else float(adv_kl_budget)
|
||||
),
|
||||
n_sae_features=int(adv_n_sae_features),
|
||||
|
||||
Reference in New Issue
Block a user