Spaces:
Sleeping
Sleeping
Commit Β·
a785d13
1
Parent(s): 0a9f157
fix reward range to strict (0,1) exclusive
Browse files- 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 |
-
|
| 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.
|
| 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=
|
| 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.
|
| 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:
|