sravaniamere commited on
Commit
a785d13
Β·
1 Parent(s): 0a9f157

fix reward range to strict (0,1) exclusive

Browse files
Files changed (1) hide show
  1. sql_env/grader.py +4 -4
sql_env/grader.py CHANGED
@@ -34,18 +34,18 @@ def grade(action: SQLAction, task: SQLTask) -> SQLReward:
34
  """
35
  4-level grader with partial progress signals.
36
 
37
- 1.0 β€” exact normalized match
38
  0.7 β€” same tokens, minor whitespace/alias differences
39
  0.4 β€” key SQL keywords all present and correct table/column names
40
  0.2 β€” basic SELECT/FROM structure present
41
- 0.0 β€” completely wrong
42
  """
43
  agent = _normalize(action.corrected_query)
44
  correct = _normalize(task.canonical_answer)
45
 
46
  # ── Level 1: Exact match ─────────────────────────────────
47
  if agent == correct:
48
- return SQLReward(value=1.0, reason="Exact match β€” perfect correction.")
49
 
50
  # ── Level 2: Same token set (right words, minor ordering) ─
51
  agent_tokens = _tokenize(action.corrected_query)
@@ -77,7 +77,7 @@ def grade(action: SQLAction, task: SQLTask) -> SQLReward:
77
  )
78
 
79
  # ── Level 0: No recognizable SQL ─────────────────────────
80
- return SQLReward(value=0.0, reason="Response is not valid SQL.")
81
 
82
 
83
  def generate_feedback(action: SQLAction, task: SQLTask, reward: SQLReward) -> str:
 
34
  """
35
  4-level grader with partial progress signals.
36
 
37
+ 0.99 β€” exact normalized match
38
  0.7 β€” same tokens, minor whitespace/alias differences
39
  0.4 β€” key SQL keywords all present and correct table/column names
40
  0.2 β€” basic SELECT/FROM structure present
41
+ 0.01 β€” completely wrong
42
  """
43
  agent = _normalize(action.corrected_query)
44
  correct = _normalize(task.canonical_answer)
45
 
46
  # ── Level 1: Exact match ─────────────────────────────────
47
  if agent == correct:
48
+ return SQLReward(value=0.99, reason="Exact match β€” perfect correction.")
49
 
50
  # ── Level 2: Same token set (right words, minor ordering) ─
51
  agent_tokens = _tokenize(action.corrected_query)
 
77
  )
78
 
79
  # ── Level 0: No recognizable SQL ─────────────────────────
80
+ return SQLReward(value=0.01, reason="Response is not valid SQL.")
81
 
82
 
83
  def generate_feedback(action: SQLAction, task: SQLTask, reward: SQLReward) -> str: