sayed125 commited on
Commit
d951939
·
verified ·
1 Parent(s): b1bf0ed

Upload lhc_core.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. lhc_core.py +7 -4
lhc_core.py CHANGED
@@ -170,7 +170,7 @@ class SymbolicWorkspace:
170
  """
171
 
172
  FACT_MAX = 25
173
- LOOP_MAX = 10 ** 6 # v3: pedagogical loop cap (was unbounded a/b iterations)
174
  POW_MAX_EXP = 512 # v3: DoS guard (9^99999999 used to freeze the app)
175
  POW_MAX_DIGITS = 4000 # v3: result-size guard
176
  STEP_BUDGET = 200_000 # v3: global step budget
@@ -462,9 +462,12 @@ class LHC0:
462
  thr = 0.5 if conf_threshold is None else conf_threshold
463
  else:
464
  conf = 0.5 * float(score) + 0.5 * float(gap)
465
- # v3: thr=0.25 measured on KB sample (n=50): correct min 0.606, nonsense
466
- # max 0.231 -> 100% accept-correct / 100% reject-nonsense at 0.25.
467
- thr = 0.25 if conf_threshold is None else conf_threshold
 
 
 
468
  if conf < thr:
469
  return {"status": "uncertain", "confidence": conf, "top_score": score}
470
  speech = "".join(Articulator().speak(entry["response"]))
 
170
  """
171
 
172
  FACT_MAX = 25
173
+ LOOP_MAX = 10 ** 4 # v3: pedagogical loop cap (kid-scale only; 10^6 made 1000000/3 hit the budget)
174
  POW_MAX_EXP = 512 # v3: DoS guard (9^99999999 used to freeze the app)
175
  POW_MAX_DIGITS = 4000 # v3: result-size guard
176
  STEP_BUDGET = 200_000 # v3: global step budget
 
462
  thr = 0.5 if conf_threshold is None else conf_threshold
463
  else:
464
  conf = 0.5 * float(score) + 0.5 * float(gap)
465
+ # v3.1: thr=0.45 — two independent samples (n=42 queries):
466
+ # exact-KB min 0.709, paraphrase-in-KB min 0.439*, OOD max 0.386 (12
467
+ # realistic OOD). At 0.45: in-KB 30/30 accepted, OOD 12/12 rejected.
468
+ # Failure mode below thr = abstain ('لا أعرف'), never a silent guess.
469
+ # (*paraphrases can dip below -> false abstain; use P1 calibrator to tune.)
470
+ thr = 0.45 if conf_threshold is None else conf_threshold
471
  if conf < thr:
472
  return {"status": "uncertain", "confidence": conf, "top_score": score}
473
  speech = "".join(Articulator().speak(entry["response"]))