fix: always emit [END] log and clamp score strictly between 0 and 1
Browse files- inference.py +4 -12
inference.py
CHANGED
|
@@ -199,7 +199,7 @@ def run_episode(client: OpenAI, task_name: str) -> None:
|
|
| 199 |
rewards: List[float] = []
|
| 200 |
steps_taken = 0
|
| 201 |
success = False
|
| 202 |
-
score = 0.0
|
| 203 |
|
| 204 |
try:
|
| 205 |
obs = env_reset(task_name)
|
|
@@ -233,22 +233,14 @@ def run_episode(client: OpenAI, task_name: str) -> None:
|
|
| 233 |
if done:
|
| 234 |
break
|
| 235 |
|
| 236 |
-
# Get the raw score from the environment (e.g., 0.0 or 1.0)
|
| 237 |
raw_score = env_score()
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
# 0.0 becomes 0.0001 and 1.0 becomes 0.9999
|
| 241 |
-
epsilon = 0.0001
|
| 242 |
-
score = max(epsilon, min(1.0 - epsilon, raw_score))
|
| 243 |
-
|
| 244 |
-
# Determine success using the original raw score logic
|
| 245 |
success = raw_score >= 0.8
|
| 246 |
-
# --- FIX ENDS HERE ---
|
| 247 |
|
| 248 |
except Exception as e:
|
| 249 |
print(f"[DEBUG] Episode failed: {e}", flush=True)
|
| 250 |
-
|
| 251 |
-
score = 0.0001
|
| 252 |
success = False
|
| 253 |
|
| 254 |
finally:
|
|
|
|
| 199 |
rewards: List[float] = []
|
| 200 |
steps_taken = 0
|
| 201 |
success = False
|
| 202 |
+
score = 0.001 # default: strictly > 0
|
| 203 |
|
| 204 |
try:
|
| 205 |
obs = env_reset(task_name)
|
|
|
|
| 233 |
if done:
|
| 234 |
break
|
| 235 |
|
|
|
|
| 236 |
raw_score = env_score()
|
| 237 |
+
# Clamp strictly between 0 and 1 (exclusive)
|
| 238 |
+
score = max(0.001, min(0.999, raw_score))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
success = raw_score >= 0.8
|
|
|
|
| 240 |
|
| 241 |
except Exception as e:
|
| 242 |
print(f"[DEBUG] Episode failed: {e}", flush=True)
|
| 243 |
+
score = 0.001
|
|
|
|
| 244 |
success = False
|
| 245 |
|
| 246 |
finally:
|