wisent 0.7.379__py3-none-any.whl → 0.7.701__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wisent/__init__.py +1 -1
- wisent/core/activations/__init__.py +22 -6
- wisent/core/activations/activations.py +21 -39
- wisent/core/activations/activations_collector.py +141 -373
- wisent/core/activations/classifier_inference_strategy.py +194 -0
- wisent/core/activations/core/atoms.py +8 -92
- wisent/core/activations/extraction_strategy.py +308 -0
- wisent/core/agent/diagnose/response_diagnostics.py +3 -3
- wisent/core/agent/diagnose.py +3 -3
- wisent/core/autonomous_agent.py +2 -2
- wisent/core/cli/agent/apply_steering.py +23 -27
- wisent/core/cli/agent/evaluate_response.py +18 -20
- wisent/core/cli/agent/train_classifier.py +18 -20
- wisent/core/cli/cluster_benchmarks.py +472 -0
- wisent/core/cli/create_steering_vector.py +13 -5
- wisent/core/cli/generate_vector_from_task.py +4 -0
- wisent/core/cli/get_activations.py +12 -36
- wisent/core/cli/method_optimizer.py +859 -0
- wisent/core/cli/optimize.py +44 -5
- wisent/core/cli/optimize_classification.py +5 -6
- wisent/core/cli/optimize_sample_size.py +8 -22
- wisent/core/cli/optimize_steering.py +429 -153
- wisent/core/cli/optimize_weights.py +65 -6
- wisent/core/cli/steering_method_trainer.py +5 -4
- wisent/core/cli/steering_search_space.py +20 -15
- wisent/core/cli/tasks.py +14 -43
- wisent/core/cli/train_unified_goodness.py +17 -18
- wisent/core/contrastive_pairs/diagnostics/control_vectors.py +1578 -173
- wisent/core/contrastive_pairs/diagnostics/linearity.py +63 -80
- wisent/core/contrastive_pairs/diagnostics/vector_quality.py +6 -5
- wisent/core/contrastive_pairs/huggingface_pairs/hf_extractor_manifest.py +5 -19
- wisent/core/contrastive_pairs/huggingface_pairs/hf_task_extractors/__init__.py +11 -5
- wisent/core/contrastive_pairs/huggingface_pairs/hf_task_extractors/apps.py +146 -32
- wisent/core/contrastive_pairs/huggingface_pairs/hf_task_extractors/codexglue.py +2 -2
- wisent/core/contrastive_pairs/huggingface_pairs/hf_task_extractors/humaneval.py +98 -57
- wisent/core/contrastive_pairs/lm_eval_pairs/group_task_manifests/code_x_glue.py +8 -8
- wisent/core/contrastive_pairs/lm_eval_pairs/group_task_manifests/freebase.py +1 -1
- wisent/core/contrastive_pairs/lm_eval_pairs/lm_extractor_manifest.py +8 -5
- wisent/core/contrastive_pairs/lm_eval_pairs/lm_task_extractors/agieval_aqua_rat.py +129 -0
- wisent/core/contrastive_pairs/lm_eval_pairs/lm_task_extractors/code_x_glue.py +11 -6
- wisent/core/contrastive_pairs/lm_eval_pairs/lm_task_extractors/gsm8k.py +1 -1
- wisent/core/contrastive_pairs/lm_eval_pairs/lm_task_extractors/mbpp.py +47 -6
- wisent/core/evaluators/benchmark_specific/apps_evaluator.py +133 -0
- wisent/core/evaluators/benchmark_specific/coding/metrics/evaluator.py +6 -1
- wisent/core/evaluators/benchmark_specific/conala_evaluator.py +31 -168
- wisent/core/evaluators/custom/examples/humanization_coherent.py +89 -35
- wisent/core/evaluators/oracles/truthfulqa_gen_evaluator.py +2 -20
- wisent/core/evaluators/personalization/coherence.py +46 -0
- wisent/core/hyperparameter_optimizer.py +13 -13
- wisent/core/lm_eval_harness_ground_truth.py +7 -11
- wisent/core/main.py +3 -0
- wisent/core/models/wisent_model.py +8 -7
- wisent/core/opti/methods/opti_weights.py +29 -2
- wisent/core/optuna/classifier/activation_generator.py +14 -12
- wisent/core/optuna/steering/steering_optimization.py +14 -9
- wisent/core/parser_arguments/cluster_benchmarks_parser.py +31 -0
- wisent/core/parser_arguments/generate_vector_from_task_parser.py +20 -0
- wisent/core/parser_arguments/main_parser.py +8 -0
- wisent/core/parser_arguments/optimize_steering_parser.py +117 -10
- wisent/core/parser_arguments/optimize_weights_parser.py +6 -0
- wisent/core/parser_arguments/tasks_parser.py +7 -19
- wisent/core/steering_methods/core/atoms.py +1 -2
- wisent/core/steering_methods/methods/caa.py +1 -1
- wisent/core/steering_methods/methods/hyperplane.py +74 -0
- wisent/core/steering_methods/methods/prism.py +1 -2
- wisent/core/steering_methods/methods/pulse.py +39 -8
- wisent/core/steering_methods/methods/titan.py +59 -14
- wisent/core/steering_methods/registry.py +52 -12
- wisent/core/steering_optimizer.py +15 -15
- wisent/core/trainers/steering_trainer.py +9 -18
- wisent/parameters/lm_eval/track_progress_not_lm_eval_tasks.json +19 -70
- wisent/scripts/run_quality_metrics_sweep.sh +22 -27
- wisent/tests/test_aggregation_geometry.py +236 -0
- wisent/tests/test_detector_accuracy.py +163 -0
- wisent/tests/test_geometry_exhaustive.py +1202 -0
- wisent/tests/visualize_geometry.py +255 -61
- {wisent-0.7.379.dist-info → wisent-0.7.701.dist-info}/METADATA +1 -1
- {wisent-0.7.379.dist-info → wisent-0.7.701.dist-info}/RECORD +82 -714
- wisent/core/activations/prompt_construction_strategy.py +0 -47
- wisent/core/contrastive_pairs/huggingface_pairs/hf_task_extractors/codexglue_code_to_text.py +0 -15
- wisent/core/contrastive_pairs/huggingface_pairs/hf_task_extractors/codexglue_code_to_text_go.py +0 -64
- wisent/core/contrastive_pairs/huggingface_pairs/hf_task_extractors/codexglue_code_to_text_java.py +0 -65
- wisent/core/contrastive_pairs/huggingface_pairs/hf_task_extractors/codexglue_code_to_text_javascript.py +0 -65
- wisent/core/contrastive_pairs/huggingface_pairs/hf_task_extractors/codexglue_code_to_text_php.py +0 -65
- wisent/core/contrastive_pairs/huggingface_pairs/hf_task_extractors/codexglue_code_to_text_python.py +0 -65
- wisent/core/contrastive_pairs/huggingface_pairs/hf_task_extractors/codexglue_code_to_text_ruby.py +0 -65
- wisent/core/contrastive_pairs/huggingface_pairs/hf_task_extractors/freebase.py +0 -99
- wisent/core/contrastive_pairs/huggingface_pairs/hf_task_extractors/instruct_humaneval.py +0 -180
- wisent/core/contrastive_pairs/huggingface_pairs/hf_task_extractors/instructhumaneval.py +0 -129
- wisent/core/contrastive_pairs/huggingface_pairs/hf_task_extractors/mbpp.py +0 -142
- wisent/core/contrastive_pairs/lm_eval_pairs/lm_task_extractors/agieval.py +0 -155
- wisent/core/contrastive_pairs/lm_eval_pairs/lm_task_extractors/code2text.py +0 -161
- wisent/core/contrastive_pairs/lm_eval_pairs/lm_task_extractors/codexglue.py +0 -107
- wisent/core/contrastive_pairs/lm_eval_pairs/lm_task_extractors/livemathbench.py +0 -155
- wisent/core/contrastive_pairs/lm_eval_pairs/lm_task_extractors/polymath.py +0 -155
- wisent/examples/scripts/results/benchmark_descriptions.json +0 -1244
- wisent/examples/scripts/results/benchmark_evaluation_methods.json +0 -66
- wisent/examples/scripts/results/benchmark_evaluator_mapping.json +0 -2781
- wisent/examples/scripts/results/benchmark_evaluator_mapping_updated.json +0 -30536
- wisent/examples/scripts/results/benchmark_evaluators_clean.json +0 -469
- wisent/examples/scripts/results/benchmark_methods_summary.json +0 -260
- wisent/examples/scripts/results/benchmark_pair_creation_methods.json +0 -66
- wisent/examples/scripts/results/benchmark_pair_totals.json +0 -269
- wisent/examples/scripts/results/benchmark_tags.json +0 -917
- wisent/examples/scripts/results/benchmark_test_summary_nov4.json +0 -71
- wisent/examples/scripts/results/coding_benchmarks_test_code_status.json +0 -150
- wisent/examples/scripts/results/failing_benchmarks.json +0 -946
- wisent/examples/scripts/results/failing_benchmarks_list.json +0 -41
- wisent/examples/scripts/results/failing_benchmarks_test_results.json +0 -945
- wisent/examples/scripts/results/missing_benchmark_tags.json +0 -341
- wisent/examples/scripts/results/test_20_newsgroups_evaluation.json +0 -30
- wisent/examples/scripts/results/test_20_newsgroups_pairs.json +0 -8
- wisent/examples/scripts/results/test_AraDICE_evaluation.json +0 -51
- wisent/examples/scripts/results/test_AraDICE_pairs.json +0 -14
- wisent/examples/scripts/results/test_AraDiCE_boolq_egy/test_AraDiCE_boolq_egy_evaluation.json +0 -30
- wisent/examples/scripts/results/test_AraDiCE_boolq_egy/test_AraDiCE_boolq_egy_pairs.json +0 -8
- wisent/examples/scripts/results/test_ArabCulture_evaluation.json +0 -51
- wisent/examples/scripts/results/test_ArabCulture_pairs.json +0 -14
- wisent/examples/scripts/results/test_Tag_evaluation.json +0 -30
- wisent/examples/scripts/results/test_Tag_pairs.json +0 -8
- wisent/examples/scripts/results/test_aclue_evaluation.json +0 -51
- wisent/examples/scripts/results/test_aclue_pairs.json +0 -14
- wisent/examples/scripts/results/test_acp_bench_evaluation.json +0 -51
- wisent/examples/scripts/results/test_acp_bench_hard_evaluation.json +0 -51
- wisent/examples/scripts/results/test_acp_bench_hard_pairs.json +0 -14
- wisent/examples/scripts/results/test_acp_bench_pairs.json +0 -14
- wisent/examples/scripts/results/test_advanced_ai_risk_evaluation.json +0 -51
- wisent/examples/scripts/results/test_advanced_ai_risk_pairs.json +0 -14
- wisent/examples/scripts/results/test_aexams_evaluation.json +0 -51
- wisent/examples/scripts/results/test_aexams_pairs.json +0 -14
- wisent/examples/scripts/results/test_afrimgsm_direct_amh_evaluation.json +0 -30
- wisent/examples/scripts/results/test_afrimgsm_direct_amh_pairs.json +0 -8
- wisent/examples/scripts/results/test_afrimmlu_direct_amh_evaluation.json +0 -30
- wisent/examples/scripts/results/test_afrimmlu_direct_amh_pairs.json +0 -8
- wisent/examples/scripts/results/test_afrixnli_en_direct_amh_evaluation.json +0 -30
- wisent/examples/scripts/results/test_afrixnli_en_direct_amh_pairs.json +0 -8
- wisent/examples/scripts/results/test_ag_news_evaluation.json +0 -30
- wisent/examples/scripts/results/test_ag_news_pairs.json +0 -8
- wisent/examples/scripts/results/test_agieval_evaluation.json +0 -51
- wisent/examples/scripts/results/test_agieval_pairs.json +0 -14
- wisent/examples/scripts/results/test_aime2024_evaluation.json +0 -30
- wisent/examples/scripts/results/test_aime2024_pairs.json +0 -8
- wisent/examples/scripts/results/test_aime2025_evaluation.json +0 -30
- wisent/examples/scripts/results/test_aime2025_pairs.json +0 -8
- wisent/examples/scripts/results/test_aime_evaluation.json +0 -30
- wisent/examples/scripts/results/test_aime_pairs.json +0 -8
- wisent/examples/scripts/results/test_anagrams1_evaluation.json +0 -30
- wisent/examples/scripts/results/test_anagrams1_pairs.json +0 -8
- wisent/examples/scripts/results/test_anagrams2_evaluation.json +0 -30
- wisent/examples/scripts/results/test_anagrams2_pairs.json +0 -8
- wisent/examples/scripts/results/test_anli_evaluation.json +0 -30
- wisent/examples/scripts/results/test_anli_pairs.json +0 -8
- wisent/examples/scripts/results/test_apps_evaluation.json +0 -30
- wisent/examples/scripts/results/test_apps_pairs.json +0 -8
- wisent/examples/scripts/results/test_arabic_exams_evaluation.json +0 -30
- wisent/examples/scripts/results/test_arabic_exams_pairs.json +0 -8
- wisent/examples/scripts/results/test_arabic_leaderboard_complete_evaluation.json +0 -51
- wisent/examples/scripts/results/test_arabic_leaderboard_complete_pairs.json +0 -14
- wisent/examples/scripts/results/test_arabic_leaderboard_light_evaluation.json +0 -51
- wisent/examples/scripts/results/test_arabic_leaderboard_light_pairs.json +0 -14
- wisent/examples/scripts/results/test_arabicmmlu_evaluation.json +0 -51
- wisent/examples/scripts/results/test_arabicmmlu_pairs.json +0 -14
- wisent/examples/scripts/results/test_aradice/test_aradice_evaluation.json +0 -51
- wisent/examples/scripts/results/test_aradice/test_aradice_pairs.json +0 -14
- wisent/examples/scripts/results/test_aradice3/test_aradice_evaluation.json +0 -51
- wisent/examples/scripts/results/test_aradice3/test_aradice_pairs.json +0 -14
- wisent/examples/scripts/results/test_arc_ar_evaluation.json +0 -30
- wisent/examples/scripts/results/test_arc_ar_pairs.json +0 -8
- wisent/examples/scripts/results/test_arc_challenge_evaluation.json +0 -30
- wisent/examples/scripts/results/test_arc_challenge_pairs.json +0 -8
- wisent/examples/scripts/results/test_arc_easy_evaluation.json +0 -30
- wisent/examples/scripts/results/test_arc_easy_pairs.json +0 -8
- wisent/examples/scripts/results/test_argument_topic_evaluation.json +0 -30
- wisent/examples/scripts/results/test_argument_topic_pairs.json +0 -8
- wisent/examples/scripts/results/test_arithmetic_evaluation.json +0 -51
- wisent/examples/scripts/results/test_arithmetic_pairs.json +0 -14
- wisent/examples/scripts/results/test_asdiv_evaluation.json +0 -30
- wisent/examples/scripts/results/test_asdiv_pairs.json +0 -8
- wisent/examples/scripts/results/test_assin_entailment_evaluation.json +0 -30
- wisent/examples/scripts/results/test_assin_entailment_pairs.json +0 -8
- wisent/examples/scripts/results/test_atis_evaluation.json +0 -30
- wisent/examples/scripts/results/test_atis_pairs.json +0 -8
- wisent/examples/scripts/results/test_babi_evaluation.json +0 -30
- wisent/examples/scripts/results/test_babi_pairs.json +0 -8
- wisent/examples/scripts/results/test_babilong_evaluation.json +0 -30
- wisent/examples/scripts/results/test_babilong_pairs.json +0 -8
- wisent/examples/scripts/results/test_bangla_mmlu_evaluation.json +0 -30
- wisent/examples/scripts/results/test_bangla_mmlu_pairs.json +0 -8
- wisent/examples/scripts/results/test_banking77_evaluation.json +0 -30
- wisent/examples/scripts/results/test_banking77_pairs.json +0 -8
- wisent/examples/scripts/results/test_basque/test_basque-glue_pairs.json +0 -14
- wisent/examples/scripts/results/test_basque-glue_evaluation.json +0 -51
- wisent/examples/scripts/results/test_basque-glue_pairs.json +0 -14
- wisent/examples/scripts/results/test_basque2/test_basque-glue_evaluation.json +0 -51
- wisent/examples/scripts/results/test_basque2/test_basque-glue_pairs.json +0 -14
- wisent/examples/scripts/results/test_basque_bench_evaluation.json +0 -51
- wisent/examples/scripts/results/test_basque_bench_pairs.json +0 -14
- wisent/examples/scripts/results/test_basque_glue/test_basque-glue_evaluation.json +0 -51
- wisent/examples/scripts/results/test_basque_glue/test_basque-glue_pairs.json +0 -14
- wisent/examples/scripts/results/test_basqueglue_evaluation.json +0 -51
- wisent/examples/scripts/results/test_basqueglue_pairs.json +0 -14
- wisent/examples/scripts/results/test_bbh_evaluation.json +0 -51
- wisent/examples/scripts/results/test_bbh_pairs.json +0 -14
- wisent/examples/scripts/results/test_bbq_evaluation.json +0 -30
- wisent/examples/scripts/results/test_bbq_pairs.json +0 -8
- wisent/examples/scripts/results/test_bec2016eu_evaluation.json +0 -51
- wisent/examples/scripts/results/test_bec2016eu_pairs.json +0 -14
- wisent/examples/scripts/results/test_belebele_evaluation.json +0 -51
- wisent/examples/scripts/results/test_belebele_pairs.json +0 -14
- wisent/examples/scripts/results/test_benchmarks_evaluation.json +0 -51
- wisent/examples/scripts/results/test_benchmarks_pairs.json +0 -14
- wisent/examples/scripts/results/test_bertaqa_evaluation.json +0 -51
- wisent/examples/scripts/results/test_bertaqa_pairs.json +0 -14
- wisent/examples/scripts/results/test_bhtc_v2_evaluation.json +0 -30
- wisent/examples/scripts/results/test_bhtc_v2_pairs.json +0 -8
- wisent/examples/scripts/results/test_bigbench_evaluation.json +0 -51
- wisent/examples/scripts/results/test_bigbench_pairs.json +0 -14
- wisent/examples/scripts/results/test_blimp_evaluation.json +0 -51
- wisent/examples/scripts/results/test_blimp_pairs.json +0 -14
- wisent/examples/scripts/results/test_boolq/test_boolq_evaluation.json +0 -30
- wisent/examples/scripts/results/test_boolq/test_boolq_pairs.json +0 -8
- wisent/examples/scripts/results/test_boolq-seq2seq_evaluation.json +0 -30
- wisent/examples/scripts/results/test_boolq-seq2seq_pairs.json +0 -8
- wisent/examples/scripts/results/test_boolq_evaluation.json +0 -30
- wisent/examples/scripts/results/test_boolq_pairs.json +0 -8
- wisent/examples/scripts/results/test_c4_evaluation.json +0 -30
- wisent/examples/scripts/results/test_c4_pairs.json +0 -8
- wisent/examples/scripts/results/test_cabreu_evaluation.json +0 -30
- wisent/examples/scripts/results/test_cabreu_pairs.json +0 -8
- wisent/examples/scripts/results/test_careqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_careqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_catalan_bench_evaluation.json +0 -51
- wisent/examples/scripts/results/test_catalan_bench_pairs.json +0 -14
- wisent/examples/scripts/results/test_catalanqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_catalanqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_catcola_evaluation.json +0 -30
- wisent/examples/scripts/results/test_catcola_pairs.json +0 -8
- wisent/examples/scripts/results/test_cb_evaluation.json +0 -30
- wisent/examples/scripts/results/test_cb_pairs.json +0 -8
- wisent/examples/scripts/results/test_ceval/test_ceval_evaluation.json +0 -51
- wisent/examples/scripts/results/test_ceval/test_ceval_pairs.json +0 -14
- wisent/examples/scripts/results/test_ceval_accountant/test_ceval-valid_accountant_evaluation.json +0 -30
- wisent/examples/scripts/results/test_ceval_accountant/test_ceval-valid_accountant_pairs.json +0 -8
- wisent/examples/scripts/results/test_ceval_evaluation.json +0 -51
- wisent/examples/scripts/results/test_ceval_pairs.json +0 -14
- wisent/examples/scripts/results/test_ceval_valid/test_ceval_valid_evaluation.json +0 -51
- wisent/examples/scripts/results/test_ceval_valid/test_ceval_valid_pairs.json +0 -14
- wisent/examples/scripts/results/test_chain_of_thought_evaluation.json +0 -51
- wisent/examples/scripts/results/test_chain_of_thought_pairs.json +0 -14
- wisent/examples/scripts/results/test_chartqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_chartqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_claim_stance_topic_evaluation.json +0 -30
- wisent/examples/scripts/results/test_claim_stance_topic_pairs.json +0 -8
- wisent/examples/scripts/results/test_cmmlu_evaluation.json +0 -51
- wisent/examples/scripts/results/test_cmmlu_pairs.json +0 -14
- wisent/examples/scripts/results/test_cnn_dailymail_evaluation.json +0 -30
- wisent/examples/scripts/results/test_cnn_dailymail_pairs.json +0 -8
- wisent/examples/scripts/results/test_cocoteros_es_evaluation.json +0 -30
- wisent/examples/scripts/results/test_cocoteros_es_pairs.json +0 -8
- wisent/examples/scripts/results/test_codexglue_code_to_text_go_evaluation.json +0 -30
- wisent/examples/scripts/results/test_codexglue_code_to_text_go_pairs.json +0 -8
- wisent/examples/scripts/results/test_codexglue_code_to_text_java_evaluation.json +0 -30
- wisent/examples/scripts/results/test_codexglue_code_to_text_java_pairs.json +0 -8
- wisent/examples/scripts/results/test_codexglue_code_to_text_javascript_evaluation.json +0 -30
- wisent/examples/scripts/results/test_codexglue_code_to_text_javascript_pairs.json +0 -8
- wisent/examples/scripts/results/test_codexglue_code_to_text_php_evaluation.json +0 -30
- wisent/examples/scripts/results/test_codexglue_code_to_text_php_pairs.json +0 -8
- wisent/examples/scripts/results/test_codexglue_code_to_text_python_evaluation.json +0 -30
- wisent/examples/scripts/results/test_codexglue_code_to_text_python_pairs.json +0 -8
- wisent/examples/scripts/results/test_codexglue_code_to_text_ruby_evaluation.json +0 -30
- wisent/examples/scripts/results/test_codexglue_code_to_text_ruby_pairs.json +0 -8
- wisent/examples/scripts/results/test_coedit_gec_evaluation.json +0 -30
- wisent/examples/scripts/results/test_coedit_gec_pairs.json +0 -8
- wisent/examples/scripts/results/test_cola_evaluation.json +0 -30
- wisent/examples/scripts/results/test_cola_pairs.json +0 -8
- wisent/examples/scripts/results/test_commonsense_qa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_commonsense_qa_pairs.json +0 -8
- wisent/examples/scripts/results/test_conala_evaluation.json +0 -30
- wisent/examples/scripts/results/test_conala_pairs.json +0 -8
- wisent/examples/scripts/results/test_concode_evaluation.json +0 -30
- wisent/examples/scripts/results/test_concode_pairs.json +0 -8
- wisent/examples/scripts/results/test_copa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_copa_pairs.json +0 -8
- wisent/examples/scripts/results/test_copal_id_evaluation.json +0 -30
- wisent/examples/scripts/results/test_copal_id_pairs.json +0 -8
- wisent/examples/scripts/results/test_coqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_coqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_coqcat_evaluation.json +0 -30
- wisent/examples/scripts/results/test_coqcat_pairs.json +0 -8
- wisent/examples/scripts/results/test_crows_pairs_evaluation.json +0 -51
- wisent/examples/scripts/results/test_crows_pairs_pairs.json +0 -14
- wisent/examples/scripts/results/test_csatqa_evaluation.json +0 -51
- wisent/examples/scripts/results/test_csatqa_pairs.json +0 -14
- wisent/examples/scripts/results/test_cycle_letters_evaluation.json +0 -30
- wisent/examples/scripts/results/test_cycle_letters_pairs.json +0 -8
- wisent/examples/scripts/results/test_darija_bench/test_darija_bench_evaluation.json +0 -51
- wisent/examples/scripts/results/test_darija_bench/test_darija_bench_pairs.json +0 -14
- wisent/examples/scripts/results/test_darija_bench_evaluation.json +0 -51
- wisent/examples/scripts/results/test_darija_bench_pairs.json +0 -14
- wisent/examples/scripts/results/test_darijahellaswag_evaluation.json +0 -30
- wisent/examples/scripts/results/test_darijahellaswag_pairs.json +0 -8
- wisent/examples/scripts/results/test_darijammlu_evaluation.json +0 -51
- wisent/examples/scripts/results/test_darijammlu_pairs.json +0 -14
- wisent/examples/scripts/results/test_dbpedia_14_evaluation.json +0 -30
- wisent/examples/scripts/results/test_dbpedia_14_pairs.json +0 -8
- wisent/examples/scripts/results/test_drop_evaluation.json +0 -30
- wisent/examples/scripts/results/test_drop_pairs.json +0 -8
- wisent/examples/scripts/results/test_ds1000_evaluation.json +0 -30
- wisent/examples/scripts/results/test_ds1000_pairs.json +0 -8
- wisent/examples/scripts/results/test_egyhellaswag_evaluation.json +0 -30
- wisent/examples/scripts/results/test_egyhellaswag_pairs.json +0 -8
- wisent/examples/scripts/results/test_egymmlu_evaluation.json +0 -51
- wisent/examples/scripts/results/test_egymmlu_pairs.json +0 -14
- wisent/examples/scripts/results/test_epec_koref_bin_evaluation.json +0 -30
- wisent/examples/scripts/results/test_epec_koref_bin_pairs.json +0 -8
- wisent/examples/scripts/results/test_eq_bench_evaluation.json +0 -30
- wisent/examples/scripts/results/test_eq_bench_pairs.json +0 -8
- wisent/examples/scripts/results/test_escola_evaluation.json +0 -30
- wisent/examples/scripts/results/test_escola_pairs.json +0 -8
- wisent/examples/scripts/results/test_ethics_cm_evaluation.json +0 -30
- wisent/examples/scripts/results/test_ethics_cm_pairs.json +0 -8
- wisent/examples/scripts/results/test_ethos_binary_evaluation.json +0 -30
- wisent/examples/scripts/results/test_ethos_binary_pairs.json +0 -8
- wisent/examples/scripts/results/test_eus_exams/test_eus_exams_evaluation.json +0 -51
- wisent/examples/scripts/results/test_eus_exams/test_eus_exams_pairs.json +0 -14
- wisent/examples/scripts/results/test_eus_exams_es_evaluation.json +0 -51
- wisent/examples/scripts/results/test_eus_exams_es_pairs.json +0 -14
- wisent/examples/scripts/results/test_eus_exams_evaluation.json +0 -51
- wisent/examples/scripts/results/test_eus_exams_pairs.json +0 -14
- wisent/examples/scripts/results/test_eus_proficiency_evaluation.json +0 -30
- wisent/examples/scripts/results/test_eus_proficiency_pairs.json +0 -8
- wisent/examples/scripts/results/test_eus_reading_evaluation.json +0 -30
- wisent/examples/scripts/results/test_eus_reading_pairs.json +0 -8
- wisent/examples/scripts/results/test_eus_trivia_evaluation.json +0 -30
- wisent/examples/scripts/results/test_eus_trivia_pairs.json +0 -8
- wisent/examples/scripts/results/test_evalita-mp_evaluation.json +0 -51
- wisent/examples/scripts/results/test_evalita-mp_pairs.json +0 -14
- wisent/examples/scripts/results/test_evalita-sp_sum_task_fp-small_p1_evaluation.json +0 -30
- wisent/examples/scripts/results/test_evalita-sp_sum_task_fp-small_p1_pairs.json +0 -8
- wisent/examples/scripts/results/test_evalita_LLM_evaluation.json +0 -51
- wisent/examples/scripts/results/test_evalita_LLM_pairs.json +0 -14
- wisent/examples/scripts/results/test_evalita_llm/test_evalita_llm_evaluation.json +0 -51
- wisent/examples/scripts/results/test_evalita_llm/test_evalita_llm_pairs.json +0 -14
- wisent/examples/scripts/results/test_evalita_mp/test_evalita-mp_te_prompt-1_evaluation.json +0 -30
- wisent/examples/scripts/results/test_evalita_mp/test_evalita-mp_te_prompt-1_pairs.json +0 -8
- wisent/examples/scripts/results/test_evalita_mp2/test_evalita_mp_evaluation.json +0 -51
- wisent/examples/scripts/results/test_evalita_mp2/test_evalita_mp_pairs.json +0 -14
- wisent/examples/scripts/results/test_evalita_sp2/test_evalita-sp_sum_task_fp-small_p1_evaluation.json +0 -30
- wisent/examples/scripts/results/test_evalita_sp2/test_evalita-sp_sum_task_fp-small_p1_pairs.json +0 -8
- wisent/examples/scripts/results/test_fda_evaluation.json +0 -30
- wisent/examples/scripts/results/test_fda_pairs.json +0 -8
- wisent/examples/scripts/results/test_financial_tweets_evaluation.json +0 -30
- wisent/examples/scripts/results/test_financial_tweets_pairs.json +0 -8
- wisent/examples/scripts/results/test_fld/test_fld_evaluation.json +0 -30
- wisent/examples/scripts/results/test_fld/test_fld_pairs.json +0 -8
- wisent/examples/scripts/results/test_fld_evaluation.json +0 -30
- wisent/examples/scripts/results/test_fld_fixed/test_fld_evaluation.json +0 -30
- wisent/examples/scripts/results/test_fld_fixed/test_fld_pairs.json +0 -8
- wisent/examples/scripts/results/test_fld_pairs.json +0 -8
- wisent/examples/scripts/results/test_flores_evaluation.json +0 -51
- wisent/examples/scripts/results/test_flores_pairs.json +0 -14
- wisent/examples/scripts/results/test_freebase_evaluation.json +0 -30
- wisent/examples/scripts/results/test_freebase_pairs.json +0 -8
- wisent/examples/scripts/results/test_french_bench_evaluation.json +0 -51
- wisent/examples/scripts/results/test_french_bench_pairs.json +0 -14
- wisent/examples/scripts/results/test_galcola_evaluation.json +0 -30
- wisent/examples/scripts/results/test_galcola_pairs.json +0 -8
- wisent/examples/scripts/results/test_galician_bench_evaluation.json +0 -51
- wisent/examples/scripts/results/test_galician_bench_pairs.json +0 -14
- wisent/examples/scripts/results/test_glianorex_evaluation.json +0 -30
- wisent/examples/scripts/results/test_glianorex_pairs.json +0 -8
- wisent/examples/scripts/results/test_global_mmlu_evaluation.json +0 -51
- wisent/examples/scripts/results/test_global_mmlu_pairs.json +0 -14
- wisent/examples/scripts/results/test_glue_evaluation.json +0 -51
- wisent/examples/scripts/results/test_glue_pairs.json +0 -14
- wisent/examples/scripts/results/test_gpqa_evaluation.json +0 -51
- wisent/examples/scripts/results/test_gpqa_pairs.json +0 -14
- wisent/examples/scripts/results/test_gpt3_translation_benchmarks_evaluation.json +0 -51
- wisent/examples/scripts/results/test_gpt3_translation_benchmarks_pairs.json +0 -14
- wisent/examples/scripts/results/test_groundcocoa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_groundcocoa_pairs.json +0 -8
- wisent/examples/scripts/results/test_gsm8k_evaluation.json +0 -30
- wisent/examples/scripts/results/test_gsm8k_pairs.json +0 -8
- wisent/examples/scripts/results/test_haerae_evaluation.json +0 -51
- wisent/examples/scripts/results/test_haerae_pairs.json +0 -14
- wisent/examples/scripts/results/test_headqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_headqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_hellaswag_evaluation.json +0 -30
- wisent/examples/scripts/results/test_hellaswag_pairs.json +0 -8
- wisent/examples/scripts/results/test_hendrycks_ethics_evaluation.json +0 -51
- wisent/examples/scripts/results/test_hendrycks_ethics_pairs.json +0 -14
- wisent/examples/scripts/results/test_hendrycks_math_evaluation.json +0 -51
- wisent/examples/scripts/results/test_hendrycks_math_pairs.json +0 -14
- wisent/examples/scripts/results/test_histoires_morales_evaluation.json +0 -30
- wisent/examples/scripts/results/test_histoires_morales_pairs.json +0 -8
- wisent/examples/scripts/results/test_hmmt_evaluation.json +0 -30
- wisent/examples/scripts/results/test_hmmt_feb_2025_evaluation.json +0 -30
- wisent/examples/scripts/results/test_hmmt_feb_2025_pairs.json +0 -8
- wisent/examples/scripts/results/test_hmmt_pairs.json +0 -8
- wisent/examples/scripts/results/test_hrm8k_evaluation.json +0 -51
- wisent/examples/scripts/results/test_hrm8k_pairs.json +0 -14
- wisent/examples/scripts/results/test_humaneval_evaluation.json +0 -30
- wisent/examples/scripts/results/test_humaneval_pairs.json +0 -8
- wisent/examples/scripts/results/test_humaneval_plus_evaluation.json +0 -30
- wisent/examples/scripts/results/test_humaneval_plus_pairs.json +0 -8
- wisent/examples/scripts/results/test_ifeval_evaluation.json +0 -30
- wisent/examples/scripts/results/test_ifeval_pairs.json +0 -8
- wisent/examples/scripts/results/test_instruct_humaneval/test_instruct_humaneval_evaluation.json +0 -30
- wisent/examples/scripts/results/test_instruct_humaneval/test_instruct_humaneval_pairs.json +0 -8
- wisent/examples/scripts/results/test_instruct_humaneval_evaluation.json +0 -30
- wisent/examples/scripts/results/test_instruct_humaneval_pairs.json +0 -8
- wisent/examples/scripts/results/test_inverse_scaling_evaluation.json +0 -51
- wisent/examples/scripts/results/test_inverse_scaling_hindsight_neglect_10shot_evaluation.json +0 -30
- wisent/examples/scripts/results/test_inverse_scaling_hindsight_neglect_10shot_pairs.json +0 -8
- wisent/examples/scripts/results/test_inverse_scaling_mc/test_inverse_scaling_mc_evaluation.json +0 -51
- wisent/examples/scripts/results/test_inverse_scaling_mc/test_inverse_scaling_mc_pairs.json +0 -14
- wisent/examples/scripts/results/test_inverse_scaling_pairs.json +0 -14
- wisent/examples/scripts/results/test_iwslt2017-ar-en_evaluation.json +0 -30
- wisent/examples/scripts/results/test_iwslt2017-ar-en_pairs.json +0 -8
- wisent/examples/scripts/results/test_iwslt2017-en-ar_evaluation.json +0 -30
- wisent/examples/scripts/results/test_iwslt2017-en-ar_pairs.json +0 -8
- wisent/examples/scripts/results/test_iwslt2017_ar_en/test_iwslt2017-ar-en_evaluation.json +0 -30
- wisent/examples/scripts/results/test_iwslt2017_ar_en/test_iwslt2017-ar-en_pairs.json +0 -8
- wisent/examples/scripts/results/test_iwslt2017_en_ar/test_iwslt2017-en-ar_evaluation.json +0 -30
- wisent/examples/scripts/results/test_iwslt2017_en_ar/test_iwslt2017-en-ar_pairs.json +0 -8
- wisent/examples/scripts/results/test_iwslt2017_group/test_iwslt2017_evaluation.json +0 -30
- wisent/examples/scripts/results/test_iwslt2017_group/test_iwslt2017_pairs.json +0 -8
- wisent/examples/scripts/results/test_japanese_leaderboard_evaluation.json +0 -51
- wisent/examples/scripts/results/test_japanese_leaderboard_pairs.json +0 -14
- wisent/examples/scripts/results/test_jsonschema_bench/test_jsonschema_bench_evaluation.json +0 -30
- wisent/examples/scripts/results/test_jsonschema_bench/test_jsonschema_bench_pairs.json +0 -8
- wisent/examples/scripts/results/test_jsonschema_bench_evaluation.json +0 -30
- wisent/examples/scripts/results/test_jsonschema_bench_final/test_jsonschema_bench_evaluation.json +0 -30
- wisent/examples/scripts/results/test_jsonschema_bench_final/test_jsonschema_bench_pairs.json +0 -8
- wisent/examples/scripts/results/test_jsonschema_bench_pairs.json +0 -8
- wisent/examples/scripts/results/test_kbl_evaluation.json +0 -51
- wisent/examples/scripts/results/test_kbl_fixed/test_kbl_evaluation.json +0 -51
- wisent/examples/scripts/results/test_kbl_fixed/test_kbl_pairs.json +0 -14
- wisent/examples/scripts/results/test_kbl_pairs.json +0 -14
- wisent/examples/scripts/results/test_kmmlu_evaluation.json +0 -51
- wisent/examples/scripts/results/test_kmmlu_pairs.json +0 -14
- wisent/examples/scripts/results/test_kobest_evaluation.json +0 -51
- wisent/examples/scripts/results/test_kobest_pairs.json +0 -14
- wisent/examples/scripts/results/test_kormedmcqa/test_kormedmcqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_kormedmcqa/test_kormedmcqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_kormedmcqa_dentist/test_kormedmcqa_dentist_evaluation.json +0 -30
- wisent/examples/scripts/results/test_kormedmcqa_dentist/test_kormedmcqa_dentist_pairs.json +0 -8
- wisent/examples/scripts/results/test_kormedmcqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_kormedmcqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_lambada_cloze_evaluation.json +0 -30
- wisent/examples/scripts/results/test_lambada_cloze_pairs.json +0 -8
- wisent/examples/scripts/results/test_lambada_evaluation.json +0 -30
- wisent/examples/scripts/results/test_lambada_final/test_lambada_openai_mt_stablelm_en_evaluation.json +0 -30
- wisent/examples/scripts/results/test_lambada_final/test_lambada_openai_mt_stablelm_en_pairs.json +0 -8
- wisent/examples/scripts/results/test_lambada_multilingual/test_lambada_multilingual_evaluation.json +0 -51
- wisent/examples/scripts/results/test_lambada_multilingual/test_lambada_multilingual_pairs.json +0 -14
- wisent/examples/scripts/results/test_lambada_multilingual_evaluation.json +0 -51
- wisent/examples/scripts/results/test_lambada_multilingual_pairs.json +0 -14
- wisent/examples/scripts/results/test_lambada_multilingual_stablelm_evaluation.json +0 -51
- wisent/examples/scripts/results/test_lambada_multilingual_stablelm_pairs.json +0 -14
- wisent/examples/scripts/results/test_lambada_openai_evaluation.json +0 -30
- wisent/examples/scripts/results/test_lambada_openai_pairs.json +0 -8
- wisent/examples/scripts/results/test_lambada_pairs.json +0 -8
- wisent/examples/scripts/results/test_lambada_stablelm_en_fixed/test_lambada_openai_mt_stablelm_en_evaluation.json +0 -30
- wisent/examples/scripts/results/test_lambada_stablelm_en_fixed/test_lambada_openai_mt_stablelm_en_pairs.json +0 -8
- wisent/examples/scripts/results/test_lambada_stablelm_fixed/test_lambada_openai_mt_stablelm_en_evaluation.json +0 -30
- wisent/examples/scripts/results/test_lambada_stablelm_fixed/test_lambada_openai_mt_stablelm_en_pairs.json +0 -8
- wisent/examples/scripts/results/test_lambada_standard_evaluation.json +0 -30
- wisent/examples/scripts/results/test_lambada_standard_pairs.json +0 -8
- wisent/examples/scripts/results/test_leaderboard_evaluation.json +0 -51
- wisent/examples/scripts/results/test_leaderboard_pairs.json +0 -14
- wisent/examples/scripts/results/test_libra/test_libra_evaluation.json +0 -51
- wisent/examples/scripts/results/test_libra/test_libra_pairs.json +0 -14
- wisent/examples/scripts/results/test_libra_evaluation.json +0 -51
- wisent/examples/scripts/results/test_libra_pairs.json +0 -14
- wisent/examples/scripts/results/test_lingoly_evaluation.json +0 -30
- wisent/examples/scripts/results/test_lingoly_pairs.json +0 -8
- wisent/examples/scripts/results/test_livecodebench_evaluation.json +0 -30
- wisent/examples/scripts/results/test_livecodebench_pairs.json +0 -8
- wisent/examples/scripts/results/test_livemathbench_cnmo_en_evaluation.json +0 -30
- wisent/examples/scripts/results/test_livemathbench_cnmo_en_pairs.json +0 -8
- wisent/examples/scripts/results/test_livemathbench_cnmo_zh_evaluation.json +0 -30
- wisent/examples/scripts/results/test_livemathbench_cnmo_zh_pairs.json +0 -8
- wisent/examples/scripts/results/test_llama_evaluation.json +0 -30
- wisent/examples/scripts/results/test_llama_pairs.json +0 -8
- wisent/examples/scripts/results/test_logiqa2_evaluation.json +0 -30
- wisent/examples/scripts/results/test_logiqa2_pairs.json +0 -8
- wisent/examples/scripts/results/test_logiqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_logiqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_m_mmlu_evaluation.json +0 -51
- wisent/examples/scripts/results/test_m_mmlu_pairs.json +0 -14
- wisent/examples/scripts/results/test_mastermind/test_mastermind_evaluation.json +0 -51
- wisent/examples/scripts/results/test_mastermind/test_mastermind_pairs.json +0 -14
- wisent/examples/scripts/results/test_mastermind_24_easy/test_mastermind_24_easy_evaluation.json +0 -30
- wisent/examples/scripts/results/test_mastermind_24_easy/test_mastermind_24_easy_pairs.json +0 -8
- wisent/examples/scripts/results/test_mastermind_evaluation.json +0 -51
- wisent/examples/scripts/results/test_mastermind_pairs.json +0 -14
- wisent/examples/scripts/results/test_math500_evaluation.json +0 -30
- wisent/examples/scripts/results/test_math500_pairs.json +0 -8
- wisent/examples/scripts/results/test_math_evaluation.json +0 -30
- wisent/examples/scripts/results/test_math_pairs.json +0 -8
- wisent/examples/scripts/results/test_mathqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_mathqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_mbpp_evaluation.json +0 -30
- wisent/examples/scripts/results/test_mbpp_pairs.json +0 -8
- wisent/examples/scripts/results/test_mbpp_plus_evaluation.json +0 -30
- wisent/examples/scripts/results/test_mbpp_plus_pairs.json +0 -8
- wisent/examples/scripts/results/test_mc_taco_evaluation.json +0 -30
- wisent/examples/scripts/results/test_mc_taco_pairs.json +0 -8
- wisent/examples/scripts/results/test_med_concepts_qa/test_med_concepts_qa_evaluation.json +0 -51
- wisent/examples/scripts/results/test_med_concepts_qa/test_med_concepts_qa_pairs.json +0 -14
- wisent/examples/scripts/results/test_med_concepts_qa_atc_easy/test_med_concepts_qa_atc_easy_evaluation.json +0 -30
- wisent/examples/scripts/results/test_med_concepts_qa_atc_easy/test_med_concepts_qa_atc_easy_pairs.json +0 -8
- wisent/examples/scripts/results/test_med_concepts_qa_evaluation.json +0 -51
- wisent/examples/scripts/results/test_med_concepts_qa_pairs.json +0 -14
- wisent/examples/scripts/results/test_meddialog_evaluation.json +0 -30
- wisent/examples/scripts/results/test_meddialog_pairs.json +0 -8
- wisent/examples/scripts/results/test_meddialog_raw_perplexity/test_meddialog_raw_perplexity_evaluation.json +0 -30
- wisent/examples/scripts/results/test_meddialog_raw_perplexity/test_meddialog_raw_perplexity_pairs.json +0 -8
- wisent/examples/scripts/results/test_mediqa_qa2019_evaluation.json +0 -30
- wisent/examples/scripts/results/test_mediqa_qa2019_pairs.json +0 -8
- wisent/examples/scripts/results/test_medmcqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_medmcqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_medqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_medqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_medtext_evaluation.json +0 -30
- wisent/examples/scripts/results/test_medtext_pairs.json +0 -8
- wisent/examples/scripts/results/test_mela_evaluation.json +0 -51
- wisent/examples/scripts/results/test_mela_pairs.json +0 -14
- wisent/examples/scripts/results/test_meqsum_evaluation.json +0 -30
- wisent/examples/scripts/results/test_meqsum_pairs.json +0 -8
- wisent/examples/scripts/results/test_mercury_evaluation.json +0 -30
- wisent/examples/scripts/results/test_mercury_pairs.json +0 -8
- wisent/examples/scripts/results/test_metabench_evaluation.json +0 -51
- wisent/examples/scripts/results/test_metabench_pairs.json +0 -14
- wisent/examples/scripts/results/test_mgsm_evaluation.json +0 -51
- wisent/examples/scripts/results/test_mgsm_pairs.json +0 -14
- wisent/examples/scripts/results/test_mimic_repsum_evaluation.json +0 -30
- wisent/examples/scripts/results/test_mimic_repsum_pairs.json +0 -8
- wisent/examples/scripts/results/test_minerva_math_evaluation.json +0 -51
- wisent/examples/scripts/results/test_minerva_math_pairs.json +0 -14
- wisent/examples/scripts/results/test_mlqa_evaluation.json +0 -51
- wisent/examples/scripts/results/test_mlqa_pairs.json +0 -14
- wisent/examples/scripts/results/test_mmlu-pro-plus_evaluation.json +0 -51
- wisent/examples/scripts/results/test_mmlu-pro-plus_pairs.json +0 -14
- wisent/examples/scripts/results/test_mmlu_evaluation.json +0 -51
- wisent/examples/scripts/results/test_mmlu_pairs.json +0 -14
- wisent/examples/scripts/results/test_mmlu_pro_evaluation.json +0 -51
- wisent/examples/scripts/results/test_mmlu_pro_pairs.json +0 -14
- wisent/examples/scripts/results/test_mmlu_prox_evaluation.json +0 -51
- wisent/examples/scripts/results/test_mmlu_prox_pairs.json +0 -14
- wisent/examples/scripts/results/test_mmlusr_evaluation.json +0 -30
- wisent/examples/scripts/results/test_mmlusr_pairs.json +0 -8
- wisent/examples/scripts/results/test_mmmu_evaluation.json +0 -51
- wisent/examples/scripts/results/test_mmmu_pairs.json +0 -14
- wisent/examples/scripts/results/test_mnli_evaluation.json +0 -30
- wisent/examples/scripts/results/test_mnli_pairs.json +0 -8
- wisent/examples/scripts/results/test_model_written_evals_evaluation.json +0 -51
- wisent/examples/scripts/results/test_model_written_evals_pairs.json +0 -14
- wisent/examples/scripts/results/test_moral_stories_evaluation.json +0 -30
- wisent/examples/scripts/results/test_moral_stories_pairs.json +0 -8
- wisent/examples/scripts/results/test_mts_dialog_evaluation.json +0 -30
- wisent/examples/scripts/results/test_mts_dialog_pairs.json +0 -8
- wisent/examples/scripts/results/test_multiblimp_evaluation.json +0 -51
- wisent/examples/scripts/results/test_multiblimp_pairs.json +0 -14
- wisent/examples/scripts/results/test_multimedqa_evaluation.json +0 -51
- wisent/examples/scripts/results/test_multimedqa_pairs.json +0 -14
- wisent/examples/scripts/results/test_multipl_e_evaluation.json +0 -30
- wisent/examples/scripts/results/test_multipl_e_pairs.json +0 -8
- wisent/examples/scripts/results/test_mutual_evaluation.json +0 -30
- wisent/examples/scripts/results/test_mutual_pairs.json +0 -8
- wisent/examples/scripts/results/test_non_greedy_robustness_agieval_aqua_rat_evaluation.json +0 -30
- wisent/examples/scripts/results/test_non_greedy_robustness_agieval_aqua_rat_pairs.json +0 -8
- wisent/examples/scripts/results/test_noreval_evaluation.json +0 -51
- wisent/examples/scripts/results/test_noreval_pairs.json +0 -14
- wisent/examples/scripts/results/test_noticia_evaluation.json +0 -30
- wisent/examples/scripts/results/test_noticia_pairs.json +0 -8
- wisent/examples/scripts/results/test_nq_open_evaluation.json +0 -30
- wisent/examples/scripts/results/test_nq_open_pairs.json +0 -8
- wisent/examples/scripts/results/test_olaph_evaluation.json +0 -30
- wisent/examples/scripts/results/test_olaph_pairs.json +0 -8
- wisent/examples/scripts/results/test_openbookqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_openbookqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_openllm_evaluation.json +0 -51
- wisent/examples/scripts/results/test_openllm_pairs.json +0 -14
- wisent/examples/scripts/results/test_option_order_robustness_agieval_aqua_rat_evaluation.json +0 -30
- wisent/examples/scripts/results/test_option_order_robustness_agieval_aqua_rat_pairs.json +0 -8
- wisent/examples/scripts/results/test_paloma_evaluation.json +0 -51
- wisent/examples/scripts/results/test_paloma_pairs.json +0 -14
- wisent/examples/scripts/results/test_passkey/test_passkey_evaluation.json +0 -30
- wisent/examples/scripts/results/test_passkey/test_passkey_pairs.json +0 -8
- wisent/examples/scripts/results/test_paws-x_evaluation.json +0 -51
- wisent/examples/scripts/results/test_paws-x_pairs.json +0 -14
- wisent/examples/scripts/results/test_paws_en/test_paws_en_evaluation.json +0 -30
- wisent/examples/scripts/results/test_paws_en/test_paws_en_pairs.json +0 -8
- wisent/examples/scripts/results/test_penn_treebank_evaluation.json +0 -30
- wisent/examples/scripts/results/test_penn_treebank_pairs.json +0 -8
- wisent/examples/scripts/results/test_pile_10k/test_pile_10k_evaluation.json +0 -30
- wisent/examples/scripts/results/test_pile_10k/test_pile_10k_pairs.json +0 -8
- wisent/examples/scripts/results/test_piqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_piqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_polemo2_evaluation.json +0 -30
- wisent/examples/scripts/results/test_polemo2_pairs.json +0 -8
- wisent/examples/scripts/results/test_polymath_en_high_evaluation.json +0 -30
- wisent/examples/scripts/results/test_polymath_en_high_pairs.json +0 -8
- wisent/examples/scripts/results/test_polymath_en_medium_evaluation.json +0 -30
- wisent/examples/scripts/results/test_polymath_en_medium_pairs.json +0 -8
- wisent/examples/scripts/results/test_polymath_zh_high_evaluation.json +0 -30
- wisent/examples/scripts/results/test_polymath_zh_high_pairs.json +0 -8
- wisent/examples/scripts/results/test_polymath_zh_medium_evaluation.json +0 -30
- wisent/examples/scripts/results/test_polymath_zh_medium_pairs.json +0 -8
- wisent/examples/scripts/results/test_portuguese_bench_evaluation.json +0 -51
- wisent/examples/scripts/results/test_portuguese_bench_pairs.json +0 -14
- wisent/examples/scripts/results/test_prompt_robustness_agieval_aqua_rat/test_prompt_robustness_agieval_aqua_rat_evaluation.json +0 -30
- wisent/examples/scripts/results/test_prompt_robustness_agieval_aqua_rat/test_prompt_robustness_agieval_aqua_rat_pairs.json +0 -8
- wisent/examples/scripts/results/test_prompt_robustness_agieval_aqua_rat_evaluation.json +0 -30
- wisent/examples/scripts/results/test_prompt_robustness_agieval_aqua_rat_pairs.json +0 -8
- wisent/examples/scripts/results/test_prost_evaluation.json +0 -30
- wisent/examples/scripts/results/test_prost_pairs.json +0 -8
- wisent/examples/scripts/results/test_ptb_evaluation.json +0 -30
- wisent/examples/scripts/results/test_ptb_pairs.json +0 -8
- wisent/examples/scripts/results/test_pubmedqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_pubmedqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_pythia_evaluation.json +0 -51
- wisent/examples/scripts/results/test_pythia_pairs.json +0 -14
- wisent/examples/scripts/results/test_qa4mre_evaluation.json +0 -30
- wisent/examples/scripts/results/test_qa4mre_pairs.json +0 -8
- wisent/examples/scripts/results/test_qasper_evaluation.json +0 -30
- wisent/examples/scripts/results/test_qasper_pairs.json +0 -8
- wisent/examples/scripts/results/test_race_evaluation.json +0 -30
- wisent/examples/scripts/results/test_race_pairs.json +0 -8
- wisent/examples/scripts/results/test_realtoxicityprompts_evaluation.json +0 -30
- wisent/examples/scripts/results/test_realtoxicityprompts_pairs.json +0 -8
- wisent/examples/scripts/results/test_recode_evaluation.json +0 -30
- wisent/examples/scripts/results/test_recode_pairs.json +0 -8
- wisent/examples/scripts/results/test_record_evaluation.json +0 -30
- wisent/examples/scripts/results/test_record_pairs.json +0 -8
- wisent/examples/scripts/results/test_ruler_evaluation.json +0 -51
- wisent/examples/scripts/results/test_ruler_pairs.json +0 -14
- wisent/examples/scripts/results/test_sciq_evaluation.json +0 -30
- wisent/examples/scripts/results/test_sciq_pairs.json +0 -8
- wisent/examples/scripts/results/test_score_evaluation.json +0 -51
- wisent/examples/scripts/results/test_score_pairs.json +0 -14
- wisent/examples/scripts/results/test_self_consistency_evaluation.json +0 -30
- wisent/examples/scripts/results/test_self_consistency_pairs.json +0 -8
- wisent/examples/scripts/results/test_siqa/test_siqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_siqa/test_siqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_siqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_siqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_spanish_bench_evaluation.json +0 -51
- wisent/examples/scripts/results/test_spanish_bench_pairs.json +0 -14
- wisent/examples/scripts/results/test_squad2_evaluation.json +0 -30
- wisent/examples/scripts/results/test_squad2_pairs.json +0 -8
- wisent/examples/scripts/results/test_squadv2_evaluation.json +0 -30
- wisent/examples/scripts/results/test_squadv2_pairs.json +0 -8
- wisent/examples/scripts/results/test_super-glue-lm-eval-v1-seq2seq_evaluation.json +0 -30
- wisent/examples/scripts/results/test_super-glue-lm-eval-v1-seq2seq_pairs.json +0 -8
- wisent/examples/scripts/results/test_super-glue-lm-eval-v1_evaluation.json +0 -51
- wisent/examples/scripts/results/test_super-glue-lm-eval-v1_pairs.json +0 -14
- wisent/examples/scripts/results/test_swag_evaluation.json +0 -30
- wisent/examples/scripts/results/test_swag_pairs.json +0 -8
- wisent/examples/scripts/results/test_tinyBenchmarks_evaluation.json +0 -51
- wisent/examples/scripts/results/test_tinyBenchmarks_pairs.json +0 -14
- wisent/examples/scripts/results/test_tmmluplus_evaluation.json +0 -51
- wisent/examples/scripts/results/test_tmmluplus_pairs.json +0 -14
- wisent/examples/scripts/results/test_translation_evaluation.json +0 -51
- wisent/examples/scripts/results/test_translation_pairs.json +0 -14
- wisent/examples/scripts/results/test_triviaqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_triviaqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_truthfulqa-multi_evaluation.json +0 -51
- wisent/examples/scripts/results/test_truthfulqa-multi_pairs.json +0 -14
- wisent/examples/scripts/results/test_truthfulqa_evaluation.json +0 -30
- wisent/examples/scripts/results/test_truthfulqa_mc1_evaluation.json +0 -30
- wisent/examples/scripts/results/test_truthfulqa_mc1_pairs.json +0 -8
- wisent/examples/scripts/results/test_truthfulqa_mc2_evaluation.json +0 -30
- wisent/examples/scripts/results/test_truthfulqa_mc2_pairs.json +0 -8
- wisent/examples/scripts/results/test_truthfulqa_pairs.json +0 -8
- wisent/examples/scripts/results/test_turkishmmlu_evaluation.json +0 -51
- wisent/examples/scripts/results/test_turkishmmlu_pairs.json +0 -14
- wisent/examples/scripts/results/test_unfair_tos_evaluation.json +0 -30
- wisent/examples/scripts/results/test_unfair_tos_pairs.json +0 -8
- wisent/examples/scripts/results/test_unscramble_evaluation.json +0 -51
- wisent/examples/scripts/results/test_unscramble_pairs.json +0 -14
- wisent/examples/scripts/results/test_webqs_evaluation.json +0 -30
- wisent/examples/scripts/results/test_webqs_pairs.json +0 -8
- wisent/examples/scripts/results/test_wikitext103_evaluation.json +0 -30
- wisent/examples/scripts/results/test_wikitext103_pairs.json +0 -8
- wisent/examples/scripts/results/test_wikitext_evaluation.json +0 -30
- wisent/examples/scripts/results/test_wikitext_pairs.json +0 -8
- wisent/examples/scripts/results/test_winogender_evaluation.json +0 -51
- wisent/examples/scripts/results/test_winogender_pairs.json +0 -14
- wisent/examples/scripts/results/test_winogrande_evaluation.json +0 -30
- wisent/examples/scripts/results/test_winogrande_pairs.json +0 -8
- wisent/examples/scripts/results/test_wmdp_evaluation.json +0 -30
- wisent/examples/scripts/results/test_wmdp_pairs.json +0 -8
- wisent/examples/scripts/results/test_wmt-ro-en-t5-prompt_evaluation.json +0 -30
- wisent/examples/scripts/results/test_wmt-ro-en-t5-prompt_pairs.json +0 -8
- wisent/examples/scripts/results/test_wmt14_en_fr_evaluation.json +0 -30
- wisent/examples/scripts/results/test_wmt14_en_fr_pairs.json +0 -8
- wisent/examples/scripts/results/test_wmt16_en_de_evaluation.json +0 -30
- wisent/examples/scripts/results/test_wmt16_en_de_pairs.json +0 -8
- wisent/examples/scripts/results/test_wmt16_ro_en_evaluation.json +0 -30
- wisent/examples/scripts/results/test_wmt16_ro_en_pairs.json +0 -8
- wisent/examples/scripts/results/test_wsc273_evaluation.json +0 -30
- wisent/examples/scripts/results/test_wsc273_pairs.json +0 -8
- wisent/examples/scripts/results/test_xcopa_evaluation.json +0 -51
- wisent/examples/scripts/results/test_xcopa_pairs.json +0 -14
- wisent/examples/scripts/results/test_xnli_eu_evaluation.json +0 -30
- wisent/examples/scripts/results/test_xnli_eu_pairs.json +0 -8
- wisent/examples/scripts/results/test_xnli_evaluation.json +0 -51
- wisent/examples/scripts/results/test_xnli_pairs.json +0 -14
- wisent/examples/scripts/results/test_xquad_evaluation.json +0 -51
- wisent/examples/scripts/results/test_xquad_pairs.json +0 -14
- wisent/examples/scripts/results/test_xstorycloze_evaluation.json +0 -51
- wisent/examples/scripts/results/test_xstorycloze_pairs.json +0 -14
- wisent/examples/scripts/results/test_xsum_evaluation.json +0 -30
- wisent/examples/scripts/results/test_xsum_pairs.json +0 -8
- wisent/examples/scripts/results/test_xwinograd_evaluation.json +0 -51
- wisent/examples/scripts/results/test_xwinograd_pairs.json +0 -14
- wisent/examples/scripts/results/test_yahoo_answers_topics_evaluation.json +0 -30
- wisent/examples/scripts/results/test_yahoo_answers_topics_pairs.json +0 -8
- {wisent-0.7.379.dist-info → wisent-0.7.701.dist-info}/WHEEL +0 -0
- {wisent-0.7.379.dist-info → wisent-0.7.701.dist-info}/entry_points.txt +0 -0
- {wisent-0.7.379.dist-info → wisent-0.7.701.dist-info}/licenses/LICENSE +0 -0
- {wisent-0.7.379.dist-info → wisent-0.7.701.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,859 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Universal Steering Method Optimizer.
|
|
3
|
+
|
|
4
|
+
This module provides a foolproof way to optimize ANY steering method's parameters.
|
|
5
|
+
It uses the universal `train(pair_set)` interface that all methods must implement,
|
|
6
|
+
ensuring compatibility with current and future steering methods.
|
|
7
|
+
|
|
8
|
+
Key design principles:
|
|
9
|
+
1. Uses `method.train(pair_set)` - the universal interface all methods implement
|
|
10
|
+
2. Automatically extracts method-specific parameters from the registry
|
|
11
|
+
3. Search spaces are defined per-method and automatically iterated
|
|
12
|
+
4. Evaluation is decoupled from training - any evaluator can be used
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import logging
|
|
18
|
+
import time
|
|
19
|
+
from dataclasses import dataclass, field
|
|
20
|
+
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type
|
|
21
|
+
|
|
22
|
+
import torch
|
|
23
|
+
|
|
24
|
+
from wisent.core.activations.activations_collector import ActivationCollector
|
|
25
|
+
from wisent.core.activations.extraction_strategy import ExtractionStrategy
|
|
26
|
+
from wisent.core.activations.core.atoms import LayerActivations
|
|
27
|
+
|
|
28
|
+
from wisent.core.contrastive_pairs.core.pair import ContrastivePair
|
|
29
|
+
from wisent.core.contrastive_pairs.core.set import ContrastivePairSet
|
|
30
|
+
from wisent.core.models.core.atoms import SteeringPlan, SteeringVector
|
|
31
|
+
from wisent.core.steering_methods.core.atoms import BaseSteeringMethod
|
|
32
|
+
from wisent.core.steering_methods.registry import SteeringMethodRegistry
|
|
33
|
+
|
|
34
|
+
logger = logging.getLogger(__name__)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@dataclass
|
|
38
|
+
class OptimizationConfig:
|
|
39
|
+
"""Configuration for a single optimization trial."""
|
|
40
|
+
|
|
41
|
+
method_name: str
|
|
42
|
+
"""Name of the steering method (caa, prism, pulse, titan)."""
|
|
43
|
+
|
|
44
|
+
# Activation extraction parameters
|
|
45
|
+
layers: List[str]
|
|
46
|
+
"""Layer indices to extract activations from."""
|
|
47
|
+
|
|
48
|
+
token_aggregation: ExtractionStrategy
|
|
49
|
+
"""How to aggregate tokens within a sequence."""
|
|
50
|
+
|
|
51
|
+
prompt_strategy: ExtractionStrategy
|
|
52
|
+
"""How to construct prompts for the model."""
|
|
53
|
+
|
|
54
|
+
# Application parameters
|
|
55
|
+
strength: float = 1.0
|
|
56
|
+
"""Steering strength multiplier."""
|
|
57
|
+
|
|
58
|
+
strategy: str = "constant"
|
|
59
|
+
"""Steering application strategy."""
|
|
60
|
+
|
|
61
|
+
# Method-specific parameters
|
|
62
|
+
method_params: Dict[str, Any] = field(default_factory=dict)
|
|
63
|
+
"""Method-specific parameters (num_directions, sensor_layer, etc.)."""
|
|
64
|
+
|
|
65
|
+
def __hash__(self):
|
|
66
|
+
return hash((
|
|
67
|
+
self.method_name,
|
|
68
|
+
tuple(self.layers),
|
|
69
|
+
self.token_aggregation.value,
|
|
70
|
+
self.prompt_strategy.value,
|
|
71
|
+
self.strength,
|
|
72
|
+
self.strategy,
|
|
73
|
+
tuple(sorted(self.method_params.items())),
|
|
74
|
+
))
|
|
75
|
+
|
|
76
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
77
|
+
return {
|
|
78
|
+
"method_name": self.method_name,
|
|
79
|
+
"layers": self.layers,
|
|
80
|
+
"token_aggregation": self.token_aggregation.value,
|
|
81
|
+
"prompt_strategy": self.prompt_strategy.value,
|
|
82
|
+
"strength": self.strength,
|
|
83
|
+
"strategy": self.strategy,
|
|
84
|
+
"method_params": self.method_params,
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@dataclass
|
|
89
|
+
class OptimizationResult:
|
|
90
|
+
"""Result of a single optimization trial."""
|
|
91
|
+
|
|
92
|
+
config: OptimizationConfig
|
|
93
|
+
"""The configuration that was tested."""
|
|
94
|
+
|
|
95
|
+
score: float
|
|
96
|
+
"""Primary evaluation score."""
|
|
97
|
+
|
|
98
|
+
metrics: Dict[str, float] = field(default_factory=dict)
|
|
99
|
+
"""Additional metrics (accuracy, f1, etc.)."""
|
|
100
|
+
|
|
101
|
+
steering_vectors: Optional[LayerActivations] = None
|
|
102
|
+
"""Trained steering vectors (optional, for caching)."""
|
|
103
|
+
|
|
104
|
+
training_time: float = 0.0
|
|
105
|
+
"""Time taken to train the method."""
|
|
106
|
+
|
|
107
|
+
evaluation_time: float = 0.0
|
|
108
|
+
"""Time taken to evaluate."""
|
|
109
|
+
|
|
110
|
+
metadata: Dict[str, Any] = field(default_factory=dict)
|
|
111
|
+
"""Additional metadata from training."""
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@dataclass
|
|
115
|
+
class OptimizationSummary:
|
|
116
|
+
"""Summary of optimization run."""
|
|
117
|
+
|
|
118
|
+
best_result: OptimizationResult
|
|
119
|
+
"""Best result found."""
|
|
120
|
+
|
|
121
|
+
all_results: List[OptimizationResult]
|
|
122
|
+
"""All results from the optimization."""
|
|
123
|
+
|
|
124
|
+
method_name: str
|
|
125
|
+
"""Method that was optimized."""
|
|
126
|
+
|
|
127
|
+
task_name: str
|
|
128
|
+
"""Task/benchmark used for evaluation."""
|
|
129
|
+
|
|
130
|
+
total_time: float = 0.0
|
|
131
|
+
"""Total optimization time."""
|
|
132
|
+
|
|
133
|
+
configs_tested: int = 0
|
|
134
|
+
"""Number of configurations tested."""
|
|
135
|
+
|
|
136
|
+
baseline_score: float = 0.0
|
|
137
|
+
"""Baseline (unsteered) accuracy for comparison."""
|
|
138
|
+
|
|
139
|
+
baseline_metrics: Dict[str, float] = field(default_factory=dict)
|
|
140
|
+
"""Baseline metrics (accuracy, correct, total)."""
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class MethodOptimizer:
|
|
144
|
+
"""
|
|
145
|
+
Universal optimizer for any steering method.
|
|
146
|
+
|
|
147
|
+
This optimizer works with ANY steering method by using the universal
|
|
148
|
+
`train(pair_set)` interface. It handles:
|
|
149
|
+
|
|
150
|
+
1. Collecting activations with different extraction parameters
|
|
151
|
+
2. Training methods with different method-specific parameters
|
|
152
|
+
3. Evaluating results with any provided evaluator
|
|
153
|
+
4. Tracking and comparing results across configurations
|
|
154
|
+
|
|
155
|
+
Example usage:
|
|
156
|
+
|
|
157
|
+
optimizer = MethodOptimizer(model, method_name="titan")
|
|
158
|
+
|
|
159
|
+
# Generate search space
|
|
160
|
+
configs = optimizer.generate_search_space(num_layers=16, quick=True)
|
|
161
|
+
|
|
162
|
+
# Run optimization
|
|
163
|
+
summary = optimizer.optimize(
|
|
164
|
+
train_pairs=train_pairs,
|
|
165
|
+
test_pairs=test_pairs,
|
|
166
|
+
evaluator=evaluator,
|
|
167
|
+
configs=configs,
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
print(f"Best config: {summary.best_result.config}")
|
|
171
|
+
print(f"Best score: {summary.best_result.score}")
|
|
172
|
+
"""
|
|
173
|
+
|
|
174
|
+
def __init__(
|
|
175
|
+
self,
|
|
176
|
+
model,
|
|
177
|
+
method_name: str,
|
|
178
|
+
device: str = "cpu",
|
|
179
|
+
verbose: bool = True,
|
|
180
|
+
):
|
|
181
|
+
"""
|
|
182
|
+
Initialize the optimizer.
|
|
183
|
+
|
|
184
|
+
Args:
|
|
185
|
+
model: WisentModel instance
|
|
186
|
+
method_name: Name of steering method to optimize
|
|
187
|
+
device: Device for storing activations
|
|
188
|
+
verbose: Whether to print progress
|
|
189
|
+
"""
|
|
190
|
+
self.model = model
|
|
191
|
+
self.method_name = method_name.lower()
|
|
192
|
+
self.device = device
|
|
193
|
+
self.verbose = verbose
|
|
194
|
+
|
|
195
|
+
# Validate method exists
|
|
196
|
+
if not SteeringMethodRegistry.validate_method(self.method_name):
|
|
197
|
+
available = ", ".join(SteeringMethodRegistry.list_methods())
|
|
198
|
+
raise ValueError(f"Unknown method: {method_name}. Available: {available}")
|
|
199
|
+
|
|
200
|
+
self.method_definition = SteeringMethodRegistry.get(self.method_name)
|
|
201
|
+
|
|
202
|
+
def _log(self, msg: str):
|
|
203
|
+
if self.verbose:
|
|
204
|
+
print(msg)
|
|
205
|
+
|
|
206
|
+
def generate_search_space(
|
|
207
|
+
self,
|
|
208
|
+
num_layers: int,
|
|
209
|
+
quick: bool = False,
|
|
210
|
+
custom_layers: Optional[List[int]] = None,
|
|
211
|
+
custom_strengths: Optional[List[float]] = None,
|
|
212
|
+
custom_token_aggregations: Optional[List[str]] = None,
|
|
213
|
+
custom_prompt_strategies: Optional[List[str]] = None,
|
|
214
|
+
custom_method_params: Optional[Dict[str, List[Any]]] = None,
|
|
215
|
+
) -> List[OptimizationConfig]:
|
|
216
|
+
"""
|
|
217
|
+
Generate search space for optimization.
|
|
218
|
+
|
|
219
|
+
Args:
|
|
220
|
+
num_layers: Number of layers in the model
|
|
221
|
+
quick: Use reduced search space for faster testing
|
|
222
|
+
custom_*: Override default search values
|
|
223
|
+
|
|
224
|
+
Returns:
|
|
225
|
+
List of OptimizationConfig to test
|
|
226
|
+
"""
|
|
227
|
+
# Default extraction parameter ranges
|
|
228
|
+
if quick:
|
|
229
|
+
layers = custom_layers or self._get_quick_layers(num_layers)
|
|
230
|
+
strengths = custom_strengths or [0.5, 1.0, 1.5]
|
|
231
|
+
token_aggs = custom_token_aggregations or ["last_token"]
|
|
232
|
+
prompt_strats = custom_prompt_strategies or ["chat_template"]
|
|
233
|
+
steering_strategies = ["constant"]
|
|
234
|
+
else:
|
|
235
|
+
layers = custom_layers or self._get_full_layers(num_layers)
|
|
236
|
+
strengths = custom_strengths or [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0]
|
|
237
|
+
token_aggs = custom_token_aggregations or ["last_token", "mean_pooling", "first_token", "max_pooling", "continuation_token"]
|
|
238
|
+
prompt_strats = custom_prompt_strategies or ["chat_template", "direct_completion", "multiple_choice", "role_playing", "instruction_following"]
|
|
239
|
+
steering_strategies = ["constant", "initial_only", "diminishing", "increasing", "gaussian"]
|
|
240
|
+
|
|
241
|
+
# Get method-specific parameter ranges
|
|
242
|
+
method_param_ranges = self._get_method_param_ranges(quick, custom_method_params)
|
|
243
|
+
|
|
244
|
+
# Generate all configurations
|
|
245
|
+
configs = []
|
|
246
|
+
|
|
247
|
+
# Convert to enums
|
|
248
|
+
token_agg_map = {
|
|
249
|
+
"last_token": ExtractionStrategy.CHAT_LAST,
|
|
250
|
+
"mean_pooling": ExtractionStrategy.CHAT_MEAN,
|
|
251
|
+
"first_token": ExtractionStrategy.CHAT_FIRST,
|
|
252
|
+
"max_pooling": ExtractionStrategy.CHAT_MAX_NORM,
|
|
253
|
+
"continuation_token": ExtractionStrategy.CHAT_GEN_POINT,
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
prompt_strat_map = {
|
|
257
|
+
"chat_template": ExtractionStrategy.CHAT_LAST,
|
|
258
|
+
"direct_completion": ExtractionStrategy.CHAT_LAST,
|
|
259
|
+
"multiple_choice": ExtractionStrategy.MC_BALANCED,
|
|
260
|
+
"role_playing": ExtractionStrategy.ROLE_PLAY,
|
|
261
|
+
"instruction_following": ExtractionStrategy.CHAT_LAST,
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
# Generate method param combinations
|
|
265
|
+
method_param_combos = self._generate_param_combinations(method_param_ranges)
|
|
266
|
+
|
|
267
|
+
for layer in layers:
|
|
268
|
+
for strength in strengths:
|
|
269
|
+
for token_agg_name in token_aggs:
|
|
270
|
+
for prompt_strat_name in prompt_strats:
|
|
271
|
+
for steering_strat in steering_strategies:
|
|
272
|
+
for method_params in method_param_combos:
|
|
273
|
+
# Determine which layers to collect activations for
|
|
274
|
+
# For multi-layer methods, collect all needed layers
|
|
275
|
+
activation_layers = self._determine_activation_layers(
|
|
276
|
+
layer, num_layers, method_params
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
config = OptimizationConfig(
|
|
280
|
+
method_name=self.method_name,
|
|
281
|
+
layers=[str(l) for l in activation_layers],
|
|
282
|
+
token_aggregation=token_agg_map.get(
|
|
283
|
+
token_agg_name, ExtractionStrategy.CHAT_LAST
|
|
284
|
+
),
|
|
285
|
+
prompt_strategy=prompt_strat_map.get(
|
|
286
|
+
prompt_strat_name, ExtractionStrategy.CHAT_LAST
|
|
287
|
+
),
|
|
288
|
+
strength=strength,
|
|
289
|
+
strategy=steering_strat,
|
|
290
|
+
method_params=method_params,
|
|
291
|
+
)
|
|
292
|
+
configs.append(config)
|
|
293
|
+
|
|
294
|
+
return configs
|
|
295
|
+
|
|
296
|
+
def _get_quick_layers(self, num_layers: int) -> List[int]:
|
|
297
|
+
"""Get reduced layer set for quick search."""
|
|
298
|
+
if num_layers <= 12:
|
|
299
|
+
return [num_layers // 3, num_layers // 2, 2 * num_layers // 3]
|
|
300
|
+
elif num_layers <= 24:
|
|
301
|
+
return [num_layers // 4, num_layers // 2, 3 * num_layers // 4]
|
|
302
|
+
else:
|
|
303
|
+
return [num_layers // 4, num_layers // 3, num_layers // 2, 2 * num_layers // 3]
|
|
304
|
+
|
|
305
|
+
def _get_full_layers(self, num_layers: int) -> List[int]:
|
|
306
|
+
"""Get full layer set for comprehensive search."""
|
|
307
|
+
# Test ALL layers from 0 to num_layers-1
|
|
308
|
+
return list(range(num_layers))
|
|
309
|
+
|
|
310
|
+
def _get_method_param_ranges(
|
|
311
|
+
self,
|
|
312
|
+
quick: bool,
|
|
313
|
+
custom: Optional[Dict[str, List[Any]]] = None,
|
|
314
|
+
) -> Dict[str, List[Any]]:
|
|
315
|
+
"""Get method-specific parameter ranges."""
|
|
316
|
+
custom = custom or {}
|
|
317
|
+
|
|
318
|
+
if self.method_name == "caa":
|
|
319
|
+
return {
|
|
320
|
+
"normalize": custom.get("normalize", [True]),
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
elif self.method_name == "prism":
|
|
324
|
+
if quick:
|
|
325
|
+
return {
|
|
326
|
+
"num_directions": custom.get("num_directions", [2, 3]),
|
|
327
|
+
"optimization_steps": custom.get("optimization_steps", [50]),
|
|
328
|
+
"retain_weight": custom.get("retain_weight", [0.1]),
|
|
329
|
+
"learning_rate": custom.get("learning_rate", [0.01]),
|
|
330
|
+
"use_caa_init": custom.get("use_caa_init", [True]),
|
|
331
|
+
}
|
|
332
|
+
return {
|
|
333
|
+
"num_directions": custom.get("num_directions", [1, 2, 3, 5]),
|
|
334
|
+
"optimization_steps": custom.get("optimization_steps", [50, 100]),
|
|
335
|
+
"retain_weight": custom.get("retain_weight", [0.0, 0.1, 0.3]),
|
|
336
|
+
"learning_rate": custom.get("learning_rate", [0.01]),
|
|
337
|
+
"independence_weight": custom.get("independence_weight", [0.05]),
|
|
338
|
+
"use_caa_init": custom.get("use_caa_init", [True]),
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
elif self.method_name == "pulse":
|
|
342
|
+
if quick:
|
|
343
|
+
return {
|
|
344
|
+
"sensor_layer": custom.get("sensor_layer", ["auto"]), # Will be resolved
|
|
345
|
+
"steering_layers": custom.get("steering_layers", ["range_3"]),
|
|
346
|
+
"condition_threshold": custom.get("condition_threshold", [0.5]),
|
|
347
|
+
"gate_temperature": custom.get("gate_temperature", [0.5]),
|
|
348
|
+
"use_entropy_scaling": custom.get("use_entropy_scaling", [False]),
|
|
349
|
+
"max_alpha": custom.get("max_alpha", [2.0]),
|
|
350
|
+
}
|
|
351
|
+
return {
|
|
352
|
+
"sensor_layer": custom.get("sensor_layer", ["auto"]),
|
|
353
|
+
"steering_layers": custom.get("steering_layers", ["single", "range_3", "range_5"]),
|
|
354
|
+
"condition_threshold": custom.get("condition_threshold", [0.3, 0.5, 0.7]),
|
|
355
|
+
"gate_temperature": custom.get("gate_temperature", [0.1, 0.5, 1.0]),
|
|
356
|
+
"per_layer_scaling": custom.get("per_layer_scaling", [True, False]),
|
|
357
|
+
"use_entropy_scaling": custom.get("use_entropy_scaling", [True, False]),
|
|
358
|
+
"max_alpha": custom.get("max_alpha", [1.5, 2.0, 3.0]),
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
elif self.method_name == "titan":
|
|
362
|
+
if quick:
|
|
363
|
+
return {
|
|
364
|
+
"num_directions": custom.get("num_directions", [3]),
|
|
365
|
+
"sensor_layer": custom.get("sensor_layer", ["auto"]),
|
|
366
|
+
"steering_layers": custom.get("steering_layers", ["range_3"]),
|
|
367
|
+
"gate_hidden_dim": custom.get("gate_hidden_dim", [64]),
|
|
368
|
+
"intensity_hidden_dim": custom.get("intensity_hidden_dim", [32]),
|
|
369
|
+
"optimization_steps": custom.get("optimization_steps", [100]),
|
|
370
|
+
"behavior_weight": custom.get("behavior_weight", [1.0]),
|
|
371
|
+
"retain_weight": custom.get("retain_weight", [0.2]),
|
|
372
|
+
"max_alpha": custom.get("max_alpha", [2.0]),
|
|
373
|
+
}
|
|
374
|
+
return {
|
|
375
|
+
"num_directions": custom.get("num_directions", [2, 3, 5]),
|
|
376
|
+
"sensor_layer": custom.get("sensor_layer", ["auto"]),
|
|
377
|
+
"steering_layers": custom.get("steering_layers", ["range_3", "range_5", "all_late"]),
|
|
378
|
+
"gate_hidden_dim": custom.get("gate_hidden_dim", [32, 64, 128]),
|
|
379
|
+
"intensity_hidden_dim": custom.get("intensity_hidden_dim", [16, 32, 64]),
|
|
380
|
+
"optimization_steps": custom.get("optimization_steps", [100, 200]),
|
|
381
|
+
"behavior_weight": custom.get("behavior_weight", [0.5, 1.0]),
|
|
382
|
+
"retain_weight": custom.get("retain_weight", [0.1, 0.2, 0.5]),
|
|
383
|
+
"sparse_weight": custom.get("sparse_weight", [0.0, 0.05]),
|
|
384
|
+
"max_alpha": custom.get("max_alpha", [2.0, 3.0]),
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
# Default for unknown methods - empty params
|
|
388
|
+
return {}
|
|
389
|
+
|
|
390
|
+
def _generate_param_combinations(
|
|
391
|
+
self,
|
|
392
|
+
param_ranges: Dict[str, List[Any]],
|
|
393
|
+
) -> List[Dict[str, Any]]:
|
|
394
|
+
"""Generate all combinations of method parameters."""
|
|
395
|
+
if not param_ranges:
|
|
396
|
+
return [{}]
|
|
397
|
+
|
|
398
|
+
import itertools
|
|
399
|
+
|
|
400
|
+
keys = list(param_ranges.keys())
|
|
401
|
+
values = [param_ranges[k] for k in keys]
|
|
402
|
+
|
|
403
|
+
combinations = []
|
|
404
|
+
for combo in itertools.product(*values):
|
|
405
|
+
combinations.append(dict(zip(keys, combo)))
|
|
406
|
+
|
|
407
|
+
return combinations
|
|
408
|
+
|
|
409
|
+
def _determine_activation_layers(
|
|
410
|
+
self,
|
|
411
|
+
base_layer: int,
|
|
412
|
+
num_layers: int,
|
|
413
|
+
method_params: Dict[str, Any],
|
|
414
|
+
) -> List[int]:
|
|
415
|
+
"""Determine which layers to collect activations for."""
|
|
416
|
+
# For methods that need multi-layer activations
|
|
417
|
+
steering_layers_config = method_params.get("steering_layers", "single")
|
|
418
|
+
|
|
419
|
+
if steering_layers_config == "single":
|
|
420
|
+
return [base_layer]
|
|
421
|
+
elif steering_layers_config == "range_3":
|
|
422
|
+
return list(range(max(0, base_layer - 1), min(num_layers, base_layer + 2)))
|
|
423
|
+
elif steering_layers_config == "range_5":
|
|
424
|
+
return list(range(max(0, base_layer - 2), min(num_layers, base_layer + 3)))
|
|
425
|
+
elif steering_layers_config == "all_late":
|
|
426
|
+
start = int(num_layers * 0.75)
|
|
427
|
+
return list(range(start, num_layers - 1))
|
|
428
|
+
elif isinstance(steering_layers_config, list):
|
|
429
|
+
return steering_layers_config
|
|
430
|
+
else:
|
|
431
|
+
return [base_layer]
|
|
432
|
+
|
|
433
|
+
def collect_activations(
|
|
434
|
+
self,
|
|
435
|
+
pairs: ContrastivePairSet,
|
|
436
|
+
config: OptimizationConfig,
|
|
437
|
+
) -> ContrastivePairSet:
|
|
438
|
+
"""
|
|
439
|
+
Collect activations for a pair set using the given config.
|
|
440
|
+
|
|
441
|
+
Args:
|
|
442
|
+
pairs: ContrastivePairSet to collect activations for
|
|
443
|
+
config: Configuration specifying layers, aggregation, etc.
|
|
444
|
+
|
|
445
|
+
Returns:
|
|
446
|
+
ContrastivePairSet with activations populated
|
|
447
|
+
"""
|
|
448
|
+
collector = ActivationCollector(model=self.model, store_device=self.device)
|
|
449
|
+
|
|
450
|
+
updated_pairs = []
|
|
451
|
+
for pair in pairs.pairs:
|
|
452
|
+
updated_pair = collector.collect_for_pair(
|
|
453
|
+
pair,
|
|
454
|
+
layers=config.layers,
|
|
455
|
+
aggregation=config.token_aggregation,
|
|
456
|
+
return_full_sequence=False,
|
|
457
|
+
normalize_layers=False,
|
|
458
|
+
)
|
|
459
|
+
updated_pairs.append(updated_pair)
|
|
460
|
+
|
|
461
|
+
return ContrastivePairSet(
|
|
462
|
+
name=pairs.name if hasattr(pairs, 'name') else "collected",
|
|
463
|
+
pairs=updated_pairs,
|
|
464
|
+
task_type=pairs.task_type if hasattr(pairs, 'task_type') else None,
|
|
465
|
+
)
|
|
466
|
+
|
|
467
|
+
def train_method(
|
|
468
|
+
self,
|
|
469
|
+
pair_set: ContrastivePairSet,
|
|
470
|
+
config: OptimizationConfig,
|
|
471
|
+
) -> Tuple[LayerActivations, Dict[str, Any]]:
|
|
472
|
+
"""
|
|
473
|
+
Train a steering method using the universal interface.
|
|
474
|
+
|
|
475
|
+
Args:
|
|
476
|
+
pair_set: ContrastivePairSet with activations already collected
|
|
477
|
+
config: Configuration with method parameters
|
|
478
|
+
|
|
479
|
+
Returns:
|
|
480
|
+
Tuple of (LayerActivations, metadata dict)
|
|
481
|
+
"""
|
|
482
|
+
# Create method instance with parameters from config
|
|
483
|
+
method_class = self.method_definition.get_method_class()
|
|
484
|
+
|
|
485
|
+
# Merge default params with config params
|
|
486
|
+
params = self.method_definition.get_default_params()
|
|
487
|
+
params.update(config.method_params)
|
|
488
|
+
|
|
489
|
+
# Resolve special parameter values
|
|
490
|
+
params = self._resolve_params(params, config)
|
|
491
|
+
|
|
492
|
+
# Create method instance
|
|
493
|
+
method = method_class(**params)
|
|
494
|
+
|
|
495
|
+
# Train using universal interface
|
|
496
|
+
steering_vectors = method.train(pair_set)
|
|
497
|
+
|
|
498
|
+
# Extract any metadata from training
|
|
499
|
+
metadata = {}
|
|
500
|
+
if hasattr(method, "_training_logs"):
|
|
501
|
+
metadata["training_logs"] = method._training_logs
|
|
502
|
+
|
|
503
|
+
return steering_vectors, metadata
|
|
504
|
+
|
|
505
|
+
def _resolve_params(
|
|
506
|
+
self,
|
|
507
|
+
params: Dict[str, Any],
|
|
508
|
+
config: OptimizationConfig,
|
|
509
|
+
) -> Dict[str, Any]:
|
|
510
|
+
"""Resolve special parameter values like 'auto'."""
|
|
511
|
+
resolved = dict(params)
|
|
512
|
+
num_layers = self.model.num_layers
|
|
513
|
+
|
|
514
|
+
# Resolve sensor_layer
|
|
515
|
+
if resolved.get("sensor_layer") == "auto":
|
|
516
|
+
# Use 75% through the network
|
|
517
|
+
resolved["sensor_layer"] = int(num_layers * 0.75)
|
|
518
|
+
|
|
519
|
+
# Resolve steering_layers from string config to actual layer list
|
|
520
|
+
steering_config = resolved.get("steering_layers")
|
|
521
|
+
if isinstance(steering_config, str):
|
|
522
|
+
base_layer = int(config.layers[0]) if config.layers else 0
|
|
523
|
+
if steering_config == "single":
|
|
524
|
+
resolved["steering_layers"] = [base_layer]
|
|
525
|
+
elif steering_config == "range_3":
|
|
526
|
+
resolved["steering_layers"] = list(range(
|
|
527
|
+
max(0, base_layer - 1),
|
|
528
|
+
min(num_layers, base_layer + 2)
|
|
529
|
+
))
|
|
530
|
+
elif steering_config == "range_5":
|
|
531
|
+
resolved["steering_layers"] = list(range(
|
|
532
|
+
max(0, base_layer - 2),
|
|
533
|
+
min(num_layers, base_layer + 3)
|
|
534
|
+
))
|
|
535
|
+
elif steering_config == "all_late":
|
|
536
|
+
start = int(num_layers * 0.75)
|
|
537
|
+
resolved["steering_layers"] = list(range(start, num_layers - 1))
|
|
538
|
+
|
|
539
|
+
return resolved
|
|
540
|
+
|
|
541
|
+
def create_steering_plan(
|
|
542
|
+
self,
|
|
543
|
+
steering_vectors: LayerActivations,
|
|
544
|
+
config: OptimizationConfig,
|
|
545
|
+
) -> SteeringPlan:
|
|
546
|
+
"""Create a SteeringPlan from trained vectors and config."""
|
|
547
|
+
raw_map = steering_vectors.to_dict()
|
|
548
|
+
|
|
549
|
+
# Apply strength scaling
|
|
550
|
+
scaled_map = {}
|
|
551
|
+
for layer, vec in raw_map.items():
|
|
552
|
+
steering_vec = SteeringVector(vector=vec, scale=config.strength)
|
|
553
|
+
scaled_map[layer] = steering_vec
|
|
554
|
+
|
|
555
|
+
return SteeringPlan(
|
|
556
|
+
layers=scaled_map,
|
|
557
|
+
layers_description=[
|
|
558
|
+
f"{self.method_name.upper()} {config.to_dict()}"
|
|
559
|
+
],
|
|
560
|
+
)
|
|
561
|
+
|
|
562
|
+
def evaluate(
|
|
563
|
+
self,
|
|
564
|
+
steering_plan: SteeringPlan,
|
|
565
|
+
test_pairs: ContrastivePairSet,
|
|
566
|
+
evaluator,
|
|
567
|
+
task_name: str,
|
|
568
|
+
) -> Tuple[float, Dict[str, float]]:
|
|
569
|
+
"""
|
|
570
|
+
Evaluate a steering plan.
|
|
571
|
+
|
|
572
|
+
Args:
|
|
573
|
+
steering_plan: The steering plan to evaluate
|
|
574
|
+
test_pairs: Test pairs for evaluation
|
|
575
|
+
evaluator: Evaluator instance (from EvaluatorRotator)
|
|
576
|
+
task_name: Name of the task for evaluator context
|
|
577
|
+
|
|
578
|
+
Returns:
|
|
579
|
+
Tuple of (primary_score, metrics_dict)
|
|
580
|
+
"""
|
|
581
|
+
correct = 0
|
|
582
|
+
total = 0
|
|
583
|
+
|
|
584
|
+
for pair in test_pairs.pairs:
|
|
585
|
+
try:
|
|
586
|
+
# Generate response with steering applied
|
|
587
|
+
self.model.apply_steering(steering_plan)
|
|
588
|
+
generated_response = self.model.generate(
|
|
589
|
+
[[{"role": "user", "content": pair.prompt}]],
|
|
590
|
+
max_new_tokens=100,
|
|
591
|
+
use_steering=True,
|
|
592
|
+
steering_plan=steering_plan,
|
|
593
|
+
)[0]
|
|
594
|
+
self.model.clear_steering()
|
|
595
|
+
|
|
596
|
+
choices = [
|
|
597
|
+
pair.negative_response.model_response,
|
|
598
|
+
pair.positive_response.model_response,
|
|
599
|
+
]
|
|
600
|
+
expected = pair.positive_response.model_response
|
|
601
|
+
metadata = pair.metadata or {}
|
|
602
|
+
|
|
603
|
+
eval_result = evaluator.evaluate(
|
|
604
|
+
response=generated_response,
|
|
605
|
+
expected=expected,
|
|
606
|
+
model=self.model,
|
|
607
|
+
question=pair.prompt,
|
|
608
|
+
choices=choices,
|
|
609
|
+
steering_plan=steering_plan,
|
|
610
|
+
correct_answers=metadata.get("correct_answers", []),
|
|
611
|
+
incorrect_answers=metadata.get("incorrect_answers", []),
|
|
612
|
+
task_name=task_name,
|
|
613
|
+
)
|
|
614
|
+
|
|
615
|
+
if eval_result.ground_truth == "TRUTHFUL":
|
|
616
|
+
correct += 1
|
|
617
|
+
total += 1
|
|
618
|
+
except Exception as e:
|
|
619
|
+
logger.warning(f"Evaluation failed for pair: {e}")
|
|
620
|
+
total += 1
|
|
621
|
+
|
|
622
|
+
accuracy = correct / total if total > 0 else 0.0
|
|
623
|
+
|
|
624
|
+
return accuracy, {
|
|
625
|
+
"accuracy": accuracy,
|
|
626
|
+
"correct": correct,
|
|
627
|
+
"total": total,
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
def evaluate_baseline(
|
|
631
|
+
self,
|
|
632
|
+
test_pairs: ContrastivePairSet,
|
|
633
|
+
evaluator,
|
|
634
|
+
task_name: str,
|
|
635
|
+
) -> Tuple[float, Dict[str, float]]:
|
|
636
|
+
"""
|
|
637
|
+
Evaluate baseline (unsteered) performance.
|
|
638
|
+
|
|
639
|
+
Args:
|
|
640
|
+
test_pairs: Test pairs for evaluation
|
|
641
|
+
evaluator: Evaluator instance
|
|
642
|
+
task_name: Name of the task for evaluator context
|
|
643
|
+
|
|
644
|
+
Returns:
|
|
645
|
+
Tuple of (baseline_score, metrics_dict)
|
|
646
|
+
"""
|
|
647
|
+
self._log("Evaluating baseline (unsteered)...")
|
|
648
|
+
|
|
649
|
+
correct = 0
|
|
650
|
+
total = 0
|
|
651
|
+
|
|
652
|
+
for pair in test_pairs.pairs:
|
|
653
|
+
try:
|
|
654
|
+
# Generate response WITHOUT steering
|
|
655
|
+
generated_response = self.model.generate(
|
|
656
|
+
[[{"role": "user", "content": pair.prompt}]],
|
|
657
|
+
max_new_tokens=100,
|
|
658
|
+
)[0]
|
|
659
|
+
|
|
660
|
+
expected = pair.positive_response.model_response
|
|
661
|
+
metadata = pair.metadata or {}
|
|
662
|
+
|
|
663
|
+
eval_result = evaluator.evaluate(
|
|
664
|
+
response=generated_response,
|
|
665
|
+
expected=expected,
|
|
666
|
+
model=self.model,
|
|
667
|
+
question=pair.prompt,
|
|
668
|
+
choices=[
|
|
669
|
+
pair.negative_response.model_response,
|
|
670
|
+
pair.positive_response.model_response,
|
|
671
|
+
],
|
|
672
|
+
correct_answers=metadata.get("correct_answers", []),
|
|
673
|
+
incorrect_answers=metadata.get("incorrect_answers", []),
|
|
674
|
+
task_name=task_name,
|
|
675
|
+
)
|
|
676
|
+
|
|
677
|
+
if eval_result.ground_truth == "TRUTHFUL":
|
|
678
|
+
correct += 1
|
|
679
|
+
total += 1
|
|
680
|
+
except Exception as e:
|
|
681
|
+
logger.warning(f"Baseline evaluation failed for pair: {e}")
|
|
682
|
+
total += 1
|
|
683
|
+
|
|
684
|
+
accuracy = correct / total if total > 0 else 0.0
|
|
685
|
+
|
|
686
|
+
self._log(f"Baseline score: {accuracy:.4f} ({correct}/{total})")
|
|
687
|
+
|
|
688
|
+
return accuracy, {
|
|
689
|
+
"accuracy": accuracy,
|
|
690
|
+
"correct": correct,
|
|
691
|
+
"total": total,
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
def optimize(
|
|
695
|
+
self,
|
|
696
|
+
train_pairs: ContrastivePairSet,
|
|
697
|
+
test_pairs: ContrastivePairSet,
|
|
698
|
+
evaluator,
|
|
699
|
+
task_name: str,
|
|
700
|
+
configs: Optional[List[OptimizationConfig]] = None,
|
|
701
|
+
quick: bool = False,
|
|
702
|
+
progress_callback: Optional[Callable[[int, int, OptimizationResult], None]] = None,
|
|
703
|
+
) -> OptimizationSummary:
|
|
704
|
+
"""
|
|
705
|
+
Run optimization over configurations.
|
|
706
|
+
|
|
707
|
+
Args:
|
|
708
|
+
train_pairs: Training pairs for steering vector extraction
|
|
709
|
+
test_pairs: Test pairs for evaluation
|
|
710
|
+
evaluator: Evaluator instance
|
|
711
|
+
task_name: Name of task/benchmark
|
|
712
|
+
configs: Configurations to test (or generate automatically)
|
|
713
|
+
quick: Use quick search space if configs not provided
|
|
714
|
+
progress_callback: Called after each config with (idx, total, result)
|
|
715
|
+
|
|
716
|
+
Returns:
|
|
717
|
+
OptimizationSummary with best result and all results
|
|
718
|
+
"""
|
|
719
|
+
start_time = time.time()
|
|
720
|
+
|
|
721
|
+
# Evaluate baseline (unsteered) first
|
|
722
|
+
baseline_score, baseline_metrics = self.evaluate_baseline(
|
|
723
|
+
test_pairs, evaluator, task_name
|
|
724
|
+
)
|
|
725
|
+
|
|
726
|
+
# Generate configs if not provided
|
|
727
|
+
if configs is None:
|
|
728
|
+
configs = self.generate_search_space(
|
|
729
|
+
num_layers=self.model.num_layers,
|
|
730
|
+
quick=quick,
|
|
731
|
+
)
|
|
732
|
+
|
|
733
|
+
self._log(f"\n{'='*60}")
|
|
734
|
+
self._log(f"Optimizing {self.method_name.upper()} with {len(configs)} configurations")
|
|
735
|
+
self._log(f"Baseline: {baseline_score:.4f}")
|
|
736
|
+
self._log(f"{'='*60}\n")
|
|
737
|
+
|
|
738
|
+
results: List[OptimizationResult] = []
|
|
739
|
+
best_result: Optional[OptimizationResult] = None
|
|
740
|
+
|
|
741
|
+
for idx, config in enumerate(configs):
|
|
742
|
+
try:
|
|
743
|
+
self._log(f"[{idx+1}/{len(configs)}] Testing: layers={config.layers}, "
|
|
744
|
+
f"strength={config.strength}, token_agg={config.token_aggregation.value}")
|
|
745
|
+
|
|
746
|
+
# Collect activations
|
|
747
|
+
t0 = time.time()
|
|
748
|
+
train_with_acts = self.collect_activations(train_pairs, config)
|
|
749
|
+
|
|
750
|
+
# Train method
|
|
751
|
+
t1 = time.time()
|
|
752
|
+
steering_vectors, metadata = self.train_method(train_with_acts, config)
|
|
753
|
+
training_time = time.time() - t1
|
|
754
|
+
|
|
755
|
+
# Create steering plan
|
|
756
|
+
steering_plan = self.create_steering_plan(steering_vectors, config)
|
|
757
|
+
|
|
758
|
+
# Evaluate
|
|
759
|
+
t2 = time.time()
|
|
760
|
+
score, metrics = self.evaluate(
|
|
761
|
+
steering_plan, test_pairs, evaluator, task_name
|
|
762
|
+
)
|
|
763
|
+
evaluation_time = time.time() - t2
|
|
764
|
+
|
|
765
|
+
result = OptimizationResult(
|
|
766
|
+
config=config,
|
|
767
|
+
score=score,
|
|
768
|
+
metrics=metrics,
|
|
769
|
+
steering_vectors=steering_vectors,
|
|
770
|
+
training_time=training_time,
|
|
771
|
+
evaluation_time=evaluation_time,
|
|
772
|
+
metadata=metadata,
|
|
773
|
+
)
|
|
774
|
+
results.append(result)
|
|
775
|
+
|
|
776
|
+
self._log(f" Score: {score:.4f} (train: {training_time:.1f}s, eval: {evaluation_time:.1f}s)")
|
|
777
|
+
|
|
778
|
+
# Track best
|
|
779
|
+
if best_result is None or score > best_result.score:
|
|
780
|
+
best_result = result
|
|
781
|
+
self._log(f" *** New best! ***")
|
|
782
|
+
|
|
783
|
+
# Callback
|
|
784
|
+
if progress_callback:
|
|
785
|
+
progress_callback(idx, len(configs), result)
|
|
786
|
+
|
|
787
|
+
except Exception as e:
|
|
788
|
+
logger.error(f"Config {idx} failed: {e}")
|
|
789
|
+
self._log(f" FAILED: {e}")
|
|
790
|
+
|
|
791
|
+
total_time = time.time() - start_time
|
|
792
|
+
|
|
793
|
+
improvement = (best_result.score - baseline_score) if best_result else 0.0
|
|
794
|
+
|
|
795
|
+
self._log(f"\n{'='*60}")
|
|
796
|
+
self._log(f"Optimization complete in {total_time:.1f}s")
|
|
797
|
+
self._log(f"Baseline: {baseline_score:.4f}")
|
|
798
|
+
self._log(f"Best score: {best_result.score:.4f}" if best_result else "No results")
|
|
799
|
+
self._log(f"Improvement: {improvement:+.4f}" if best_result else "")
|
|
800
|
+
self._log(f"{'='*60}\n")
|
|
801
|
+
|
|
802
|
+
return OptimizationSummary(
|
|
803
|
+
best_result=best_result,
|
|
804
|
+
all_results=results,
|
|
805
|
+
method_name=self.method_name,
|
|
806
|
+
task_name=task_name,
|
|
807
|
+
total_time=total_time,
|
|
808
|
+
configs_tested=len(results),
|
|
809
|
+
baseline_score=baseline_score,
|
|
810
|
+
baseline_metrics=baseline_metrics,
|
|
811
|
+
)
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
def optimize_steering_method(
|
|
815
|
+
model,
|
|
816
|
+
method_name: str,
|
|
817
|
+
train_pairs: ContrastivePairSet,
|
|
818
|
+
test_pairs: ContrastivePairSet,
|
|
819
|
+
evaluator,
|
|
820
|
+
task_name: str,
|
|
821
|
+
quick: bool = False,
|
|
822
|
+
verbose: bool = True,
|
|
823
|
+
) -> OptimizationSummary:
|
|
824
|
+
"""
|
|
825
|
+
Convenience function to optimize a steering method.
|
|
826
|
+
|
|
827
|
+
This is the main entry point for optimizing any steering method.
|
|
828
|
+
It handles all the complexity of:
|
|
829
|
+
- Generating appropriate search spaces
|
|
830
|
+
- Collecting activations
|
|
831
|
+
- Training methods
|
|
832
|
+
- Evaluating results
|
|
833
|
+
|
|
834
|
+
Args:
|
|
835
|
+
model: WisentModel instance
|
|
836
|
+
method_name: Name of method to optimize (caa, prism, pulse, titan)
|
|
837
|
+
train_pairs: Training pairs
|
|
838
|
+
test_pairs: Test pairs
|
|
839
|
+
evaluator: Evaluator instance
|
|
840
|
+
task_name: Name of task/benchmark
|
|
841
|
+
quick: Use reduced search space
|
|
842
|
+
verbose: Print progress
|
|
843
|
+
|
|
844
|
+
Returns:
|
|
845
|
+
OptimizationSummary with results
|
|
846
|
+
"""
|
|
847
|
+
optimizer = MethodOptimizer(
|
|
848
|
+
model=model,
|
|
849
|
+
method_name=method_name,
|
|
850
|
+
verbose=verbose,
|
|
851
|
+
)
|
|
852
|
+
|
|
853
|
+
return optimizer.optimize(
|
|
854
|
+
train_pairs=train_pairs,
|
|
855
|
+
test_pairs=test_pairs,
|
|
856
|
+
evaluator=evaluator,
|
|
857
|
+
task_name=task_name,
|
|
858
|
+
quick=quick,
|
|
859
|
+
)
|