3v324v23 commited on
Commit
9f3a7c5
·
1 Parent(s): 49f7113

fix: normalize [END] score to (0,1) range — divide by 4.8 max score, clamp to (0.001, 0.999)

Browse files
Files changed (1) hide show
  1. inference.py +9 -4
inference.py CHANGED
@@ -145,17 +145,22 @@ def run_task(task_name: str) -> dict:
145
  print(f" REWARD : {summary['total_reward']:.3f} / 4.8 max")
146
  print(f"{'='*60}\n")
147
 
148
- # Required structured block
 
 
 
 
 
149
  print(
150
- f"[END] task={task_name} score={summary['total_reward']:.3f} steps={steps_taken}",
151
  flush=True,
152
  )
153
  return summary
154
 
155
  except Exception as exc:
156
  print(f"[ERROR] run_task({task_name}) failed: {exc}", flush=True)
157
- # Still emit END block so validator can parse something
158
- print(f"[END] task={task_name} score=0.0 steps=0", flush=True)
159
  return {"task_id": task_name, "status": "error", "total_reward": 0.0, "wrong_steps": 0, "fail_reason": str(exc), "steps": []}
160
 
161
 
 
145
  print(f" REWARD : {summary['total_reward']:.3f} / 4.8 max")
146
  print(f"{'='*60}\n")
147
 
148
+ # Required structured block — score must be strictly in (0, 1)
149
+ MAX_SCORE = 4.8 # 4 steps × 1.2 max reward each
150
+ raw_score = summary['total_reward']
151
+ normalized = raw_score / MAX_SCORE
152
+ # Clamp strictly between 0 and 1 (not 0.0, not 1.0)
153
+ final_score = max(0.001, min(0.999, normalized))
154
  print(
155
+ f"[END] task={task_name} score={final_score:.4f} steps={steps_taken}",
156
  flush=True,
157
  )
158
  return summary
159
 
160
  except Exception as exc:
161
  print(f"[ERROR] run_task({task_name}) failed: {exc}", flush=True)
162
+ # Emit END block with minimum valid score (strictly > 0)
163
+ print(f"[END] task={task_name} score=0.001 steps=0", flush=True)
164
  return {"task_id": task_name, "status": "error", "total_reward": 0.0, "wrong_steps": 0, "fail_reason": str(exc), "steps": []}
165
 
166