Imaginephoenix commited on
Commit
33f792e
·
verified ·
1 Parent(s): d547d85

Update graders.py

Browse files
Files changed (1) hide show
  1. graders.py +10 -4
graders.py CHANGED
@@ -12,9 +12,10 @@ ROUTE_ALIAS_MAP = {
12
  "general": ["general", "inbox", "operations"],
13
  }
14
 
 
15
 
16
  def _clip_score(score_value: float) -> float:
17
- """Clip a score to the inclusive range [0.0, 1.0].
18
 
19
  Args:
20
  score_value: Raw score.
@@ -22,7 +23,12 @@ def _clip_score(score_value: float) -> float:
22
  Returns:
23
  Clipped score.
24
  """
25
- return max(0.0, min(1.0, score_value))
 
 
 
 
 
26
 
27
 
28
  def _normalized_text(text_value: str) -> str:
@@ -210,8 +216,8 @@ def grade_medium(actions: list[TriageAction], ground_truths: list[dict]) -> Rewa
210
  comparable_count = min(len(actions), len(ground_truths))
211
  if comparable_count == 0:
212
  return RewardResult(
213
- score=0.0,
214
- breakdown={"emails_scored": 0.0, "weighted_average": 0.0},
215
  feedback="No actions available for grading.",
216
  )
217
 
 
12
  "general": ["general", "inbox", "operations"],
13
  }
14
 
15
+ SCORE_EPSILON = 1e-6
16
 
17
  def _clip_score(score_value: float) -> float:
18
+ """Clip a score to the strict range (0.0, 1.0).
19
 
20
  Args:
21
  score_value: Raw score.
 
23
  Returns:
24
  Clipped score.
25
  """
26
+ clipped = max(0.0, min(1.0, score_value))
27
+ if clipped <= 0.0:
28
+ return SCORE_EPSILON
29
+ if clipped >= 1.0:
30
+ return 1.0 - SCORE_EPSILON
31
+ return clipped
32
 
33
 
34
  def _normalized_text(text_value: str) -> str:
 
216
  comparable_count = min(len(actions), len(ground_truths))
217
  if comparable_count == 0:
218
  return RewardResult(
219
+ score=SCORE_EPSILON,
220
+ breakdown={"emails_scored": 0.0, "weighted_average": SCORE_EPSILON},
221
  feedback="No actions available for grading.",
222
  )
223