feat(cwb): add focused merge presets
This commit is contained in:
@@ -177,13 +177,17 @@ Dense nodes offer `balanced_mean`, `robust_medn`, `selective_mean`,
|
||||
|
||||
Embedding nodes offer `balanced_idx_mean`, `balanced_sim_mean`,
|
||||
`robust_idx_medn`, `robust_sim_medn`, `varied_sim_mean_rn_softcb`, and
|
||||
`diverse_sim_medn_rn_dsc_softcb`.
|
||||
`diverse_sim_medn_rn_dsc_softcb`, `focused_strong_sim_medn`,
|
||||
`focused_balance_sim_medn`, `focused_soft_sim_medn`, and
|
||||
`focused_weak_sim_medn`.
|
||||
|
||||
LoRA nodes offer `broad_sim_medn_rn_softcb`,
|
||||
`moderate_sim_medn_rn_softcb`, `conservative_sim_medn_rn_softcb`,
|
||||
`direct_idx_medn_rn_softcb`, `broad_sim_mean_rn_softcb`,
|
||||
`neutral_sim_medn_rn`, `focused_sim_medn_rn_dsc_softcb`, and
|
||||
`strongfocus_sim_medn_rn_dsc_softcb`.
|
||||
`strongfocus_sim_medn_rn_dsc_softcb`, `focused_strong_sim_medn`,
|
||||
`focused_balance_sim_medn`, `focused_soft_sim_medn`, and
|
||||
`focused_weak_sim_medn`.
|
||||
|
||||
The LoRA default is `broad_sim_medn_rn_softcb`: median consensus,
|
||||
similarity alignment, zero similarity threshold, alpha 2, beta 4, norm
|
||||
@@ -204,6 +208,13 @@ Every LoRA preset fixes all 12 controls explicitly:
|
||||
| `neutral_sim_medn_rn` | median | similarity | 0 | 0 | 2 | 0 | on | 1 | off | off | 0.05 | off | Similarity weighting without diversity modulation |
|
||||
| `focused_sim_medn_rn_dsc_softcb` | median | similarity | 0 | 0 | 2 | 4 | on | 1 | on | on | 0.05 | off | Moderate DSC concentration |
|
||||
| `strongfocus_sim_medn_rn_dsc_softcb` | median | similarity | 0 | 0 | 2 | 7 | on | 1 | on | on | 0.05 | off | Strong DSC concentration |
|
||||
| `focused_strong_sim_medn` | median | similarity | 0.85 | 0.60 | 1.25 | 0 | off | 1 | off | off | 0.20 | off | Strongly focused matching |
|
||||
| `focused_balance_sim_medn` | median | similarity | 0.75 | 0.55 | 1.25 | 0 | off | 1 | off | off | 0.20 | off | Balanced focused matching |
|
||||
| `focused_soft_sim_medn` | median | similarity | 0.55 | 0.50 | 1.25 | 0 | off | 1 | off | off | 0.20 | off | Soft focused matching |
|
||||
| `focused_weak_sim_medn` | median | similarity | 0.25 | 0.35 | 1.25 | 0 | off | 1 | off | off | 0.20 | off | Weak focused matching |
|
||||
|
||||
The four focused median similarity presets have identical settings in the
|
||||
embedding and LoRA registries.
|
||||
|
||||
The LoRA Multi-Merge counterfactual weight sweep reuses each consensus vector
|
||||
already computed by the active merge. It reports mean and median consensus
|
||||
|
||||
@@ -157,6 +157,38 @@ EMBEDDING_CWB_PRESETS = {
|
||||
dynamic_similarity_contrast=True, soft_comfort_bandpass=True,
|
||||
position_weight=0.1, preserve_common_prefix=False,
|
||||
),
|
||||
"focused_strong_sim_medn": _preset(
|
||||
consensus_type="median", alignment_method="similarity",
|
||||
alignment_threshold=0.85, similarity_threshold=0.60,
|
||||
power_alpha=1.25, diversity_beta=0.0, rescale_norm=False,
|
||||
global_scale=1.0, dynamic_similarity_contrast=False,
|
||||
soft_comfort_bandpass=False, position_weight=0.20,
|
||||
preserve_common_prefix=False,
|
||||
),
|
||||
"focused_balance_sim_medn": _preset(
|
||||
consensus_type="median", alignment_method="similarity",
|
||||
alignment_threshold=0.75, similarity_threshold=0.55,
|
||||
power_alpha=1.25, diversity_beta=0.0, rescale_norm=False,
|
||||
global_scale=1.0, dynamic_similarity_contrast=False,
|
||||
soft_comfort_bandpass=False, position_weight=0.20,
|
||||
preserve_common_prefix=False,
|
||||
),
|
||||
"focused_soft_sim_medn": _preset(
|
||||
consensus_type="median", alignment_method="similarity",
|
||||
alignment_threshold=0.55, similarity_threshold=0.50,
|
||||
power_alpha=1.25, diversity_beta=0.0, rescale_norm=False,
|
||||
global_scale=1.0, dynamic_similarity_contrast=False,
|
||||
soft_comfort_bandpass=False, position_weight=0.20,
|
||||
preserve_common_prefix=False,
|
||||
),
|
||||
"focused_weak_sim_medn": _preset(
|
||||
consensus_type="median", alignment_method="similarity",
|
||||
alignment_threshold=0.25, similarity_threshold=0.35,
|
||||
power_alpha=1.25, diversity_beta=0.0, rescale_norm=False,
|
||||
global_scale=1.0, dynamic_similarity_contrast=False,
|
||||
soft_comfort_bandpass=False, position_weight=0.20,
|
||||
preserve_common_prefix=False,
|
||||
),
|
||||
}
|
||||
|
||||
LORA_CWB_PRESETS = {
|
||||
@@ -224,6 +256,38 @@ LORA_CWB_PRESETS = {
|
||||
soft_comfort_bandpass=True, position_weight=0.05,
|
||||
preserve_common_prefix=False,
|
||||
),
|
||||
"focused_strong_sim_medn": _preset(
|
||||
consensus_type="median", alignment_method="similarity",
|
||||
alignment_threshold=0.85, similarity_threshold=0.60,
|
||||
power_alpha=1.25, diversity_beta=0.0, rescale_norm=False,
|
||||
global_scale=1.0, dynamic_similarity_contrast=False,
|
||||
soft_comfort_bandpass=False, position_weight=0.20,
|
||||
preserve_common_prefix=False,
|
||||
),
|
||||
"focused_balance_sim_medn": _preset(
|
||||
consensus_type="median", alignment_method="similarity",
|
||||
alignment_threshold=0.75, similarity_threshold=0.55,
|
||||
power_alpha=1.25, diversity_beta=0.0, rescale_norm=False,
|
||||
global_scale=1.0, dynamic_similarity_contrast=False,
|
||||
soft_comfort_bandpass=False, position_weight=0.20,
|
||||
preserve_common_prefix=False,
|
||||
),
|
||||
"focused_soft_sim_medn": _preset(
|
||||
consensus_type="median", alignment_method="similarity",
|
||||
alignment_threshold=0.55, similarity_threshold=0.50,
|
||||
power_alpha=1.25, diversity_beta=0.0, rescale_norm=False,
|
||||
global_scale=1.0, dynamic_similarity_contrast=False,
|
||||
soft_comfort_bandpass=False, position_weight=0.20,
|
||||
preserve_common_prefix=False,
|
||||
),
|
||||
"focused_weak_sim_medn": _preset(
|
||||
consensus_type="median", alignment_method="similarity",
|
||||
alignment_threshold=0.25, similarity_threshold=0.35,
|
||||
power_alpha=1.25, diversity_beta=0.0, rescale_norm=False,
|
||||
global_scale=1.0, dynamic_similarity_contrast=False,
|
||||
soft_comfort_bandpass=False, position_weight=0.20,
|
||||
preserve_common_prefix=False,
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -135,6 +135,39 @@ def test_lora_alignment_presets_use_sweep_verified_thresholds(cwb):
|
||||
] == pytest.approx(0.0025)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("registry_name", "preset", "alignment_threshold", "similarity_threshold"),
|
||||
[
|
||||
(registry_name, preset, alignment_threshold, similarity_threshold)
|
||||
for registry_name in ("EMBEDDING_CWB_PRESETS", "LORA_CWB_PRESETS")
|
||||
for preset, alignment_threshold, similarity_threshold in (
|
||||
("focused_strong_sim_medn", 0.85, 0.60),
|
||||
("focused_balance_sim_medn", 0.75, 0.55),
|
||||
("focused_soft_sim_medn", 0.55, 0.50),
|
||||
("focused_weak_sim_medn", 0.25, 0.35),
|
||||
)
|
||||
],
|
||||
)
|
||||
def test_focused_median_similarity_presets(
|
||||
cwb, registry_name, preset, alignment_threshold, similarity_threshold
|
||||
):
|
||||
settings = getattr(cwb, registry_name)[preset]
|
||||
assert settings == {
|
||||
"consensus_type": "median",
|
||||
"alignment_method": "similarity",
|
||||
"alignment_threshold": alignment_threshold,
|
||||
"similarity_threshold": similarity_threshold,
|
||||
"power_alpha": 1.25,
|
||||
"diversity_beta": 0.0,
|
||||
"rescale_norm": False,
|
||||
"global_scale": 1.0,
|
||||
"dynamic_similarity_contrast": False,
|
||||
"soft_comfort_bandpass": False,
|
||||
"position_weight": 0.20,
|
||||
"preserve_common_prefix": False,
|
||||
}
|
||||
|
||||
|
||||
def test_cwb_math_index_prefix_and_scale(cwb):
|
||||
settings = _settings(
|
||||
cwb,
|
||||
@@ -647,7 +680,7 @@ def test_use_case_preset_names_match_complete_settings(cwb):
|
||||
cwb.EMBEDDING_CWB_PRESETS,
|
||||
cwb.LORA_CWB_PRESETS,
|
||||
):
|
||||
assert 6 <= len(registry) <= 8
|
||||
assert len(registry) >= 6
|
||||
for name, values in registry.items():
|
||||
assert set(values) == fields
|
||||
assert ("_rn" in name) is values["rescale_norm"]
|
||||
|
||||
Reference in New Issue
Block a user