Spaces:
Sleeping
Sleeping
Commit ·
11dd1d6
1
Parent(s): 888871f
Clamp all step rewards strictly between 0.001 and 0.999
Browse files- inference.py +6 -5
inference.py
CHANGED
|
@@ -208,6 +208,9 @@ def run_episode(client: OpenAI, difficulty: str, task_id: str) -> dict:
|
|
| 208 |
done = False
|
| 209 |
error_str = str(e)[:100]
|
| 210 |
|
|
|
|
|
|
|
|
|
|
| 211 |
rewards.append(reward)
|
| 212 |
steps = step
|
| 213 |
|
|
@@ -225,9 +228,7 @@ def run_episode(client: OpenAI, difficulty: str, task_id: str) -> dict:
|
|
| 225 |
# Score strictly between 0 and 1 exclusive
|
| 226 |
# Score strictly between 0 and 1 exclusive — never 0.0 or 1.0
|
| 227 |
if rewards:
|
| 228 |
-
|
| 229 |
-
shifted = [max(0.01, r + 0.5) for r in rewards]
|
| 230 |
-
raw_score = sum(shifted) / len(shifted)
|
| 231 |
else:
|
| 232 |
raw_score = 0.5
|
| 233 |
|
|
@@ -240,8 +241,8 @@ def run_episode(client: OpenAI, difficulty: str, task_id: str) -> dict:
|
|
| 240 |
success = False
|
| 241 |
|
| 242 |
finally:
|
| 243 |
-
# Ensure rewards list for log_end is never empty
|
| 244 |
-
safe_rewards =
|
| 245 |
log_end(
|
| 246 |
success = success,
|
| 247 |
steps = steps,
|
|
|
|
| 208 |
done = False
|
| 209 |
error_str = str(e)[:100]
|
| 210 |
|
| 211 |
+
# Clamp reward strictly between 0.001 and 0.999
|
| 212 |
+
reward = max(0.001, min(0.999, reward + 0.5))
|
| 213 |
+
|
| 214 |
rewards.append(reward)
|
| 215 |
steps = step
|
| 216 |
|
|
|
|
| 228 |
# Score strictly between 0 and 1 exclusive
|
| 229 |
# Score strictly between 0 and 1 exclusive — never 0.0 or 1.0
|
| 230 |
if rewards:
|
| 231 |
+
raw_score = sum(rewards) / len(rewards)
|
|
|
|
|
|
|
| 232 |
else:
|
| 233 |
raw_score = 0.5
|
| 234 |
|
|
|
|
| 241 |
success = False
|
| 242 |
|
| 243 |
finally:
|
| 244 |
+
# Ensure rewards list for log_end is never empty
|
| 245 |
+
safe_rewards = rewards if rewards else [0.5]
|
| 246 |
log_end(
|
| 247 |
success = success,
|
| 248 |
steps = steps,
|