Rthur2003 commited on
Commit
ba5cc97
·
1 Parent(s): e68824c

feat: adjust confidence calculation in score fusion to improve agreement handling

Browse files
Files changed (1) hide show
  1. app/services/score_fusion.py +3 -8
app/services/score_fusion.py CHANGED
@@ -286,23 +286,18 @@ def _fuse(
286
 
287
  mode: str = "production"
288
 
289
- # Clamp to valid range
290
- confidence = max(0.51, min(0.97, confidence))
291
- confidence = round(confidence, 4)
292
-
293
- # Agreement bonus
294
  if len(scores) > 1:
295
  all_ai = all(s > 0.5 for s, _, _ in scores)
296
  all_human = all(s <= 0.5 for s, _, _ in scores)
297
  if all_ai:
298
- # More layers agreeing → bigger boost
299
  boost = 1.0 + 0.02 * len(scores)
300
  confidence = min(0.97, confidence * boost)
301
  elif all_human:
302
  dampen = 1.0 - 0.02 * len(scores)
303
- confidence = max(0.51, confidence * dampen)
304
 
305
- confidence = round(max(0.51, min(0.97, confidence)), 4)
306
 
307
  sources_str = ", ".join(f"{src}={s:.3f}" for s, _, src in scores)
308
  logger.info(
 
286
 
287
  mode: str = "production"
288
 
289
+ # Agreement bonus/dampen
 
 
 
 
290
  if len(scores) > 1:
291
  all_ai = all(s > 0.5 for s, _, _ in scores)
292
  all_human = all(s <= 0.5 for s, _, _ in scores)
293
  if all_ai:
 
294
  boost = 1.0 + 0.02 * len(scores)
295
  confidence = min(0.97, confidence * boost)
296
  elif all_human:
297
  dampen = 1.0 - 0.02 * len(scores)
298
+ confidence = max(0.03, confidence * dampen)
299
 
300
+ confidence = round(max(0.03, min(0.97, confidence)), 4)
301
 
302
  sources_str = ", ".join(f"{src}={s:.3f}" for s, _, src in scores)
303
  logger.info(