From 6c3c6a16c2e3b603078f1a350b23d670e4cc5e2b Mon Sep 17 00:00:00 2001 From: Chaim Date: Sun, 28 Jun 2026 22:44:55 +0000 Subject: [PATCH] =?UTF-8?q?tune(learning):=20lesson-synthesis=20cluster=20?= =?UTF-8?q?threshold=200.82=20=E2=86=92=200.68=20(#158)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit כיול אמפירי (dry-run על 81 לקחים): הלקחים מגוונים (חציון-דמיון ~0.48, מקס' ~0.72), כך ש-0.82 מיזג 0 אשכולות. 0.68 תופס 5 קונסולידציות אמיתיות (רישוי+השבחה+מבנה), כולן עברו את שער-ה-drift 0.80 (0.848–0.916) → נאמנות נשמרת. שער-ה-drift נשאר רשת-הביטחון מתחת לסף. Invariants: INV-LRN8 (כיול-סף בלבד; המנגנון/השערים ללא שינוי). depends-on #158. Co-Authored-By: Claude Opus 4.8 (1M context) --- mcp-server/src/legal_mcp/config.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mcp-server/src/legal_mcp/config.py b/mcp-server/src/legal_mcp/config.py index daf4158..4ba868c 100644 --- a/mcp-server/src/legal_mcp/config.py +++ b/mcp-server/src/legal_mcp/config.py @@ -286,7 +286,12 @@ LESSON_SYNTH_MODEL = os.environ.get("LESSON_SYNTH_MODEL", HALACHA_EXTRACT_MODEL) LESSON_SYNTH_EFFORT = os.environ.get("LESSON_SYNTH_EFFORT", "high") LESSON_SYNTH_DRIFT_FLOOR = float(os.environ.get("LESSON_SYNTH_DRIFT_FLOOR", "0.80")) # Cosine floor for two lessons to land in the same cluster (greedy, within shard). -LESSON_SYNTH_CLUSTER_THRESHOLD = float(os.environ.get("LESSON_SYNTH_CLUSTER_THRESHOLD", "0.82")) +# Tuned empirically (#158 dry-run, 81 lessons): the lessons are diverse (median +# pairwise cosine ~0.48, max ~0.72), so 0.82 merged nothing. 0.68 captures the real +# near-duplicates (5 faithful clusters across rishuy+betterment, all clearing the +# 0.80 drift gate) without merging weakly-related lessons; the drift gate is the +# quality backstop below this. +LESSON_SYNTH_CLUSTER_THRESHOLD = float(os.environ.get("LESSON_SYNTH_CLUSTER_THRESHOLD", "0.68")) # Mistral OCR (fallback for scanned PDFs — replaces Google Cloud Vision) MISTRAL_API_KEY = os.environ.get("MISTRAL_API_KEY", "")