Spaces:
Sleeping
Sleeping
Commit Β·
ef20791
1
Parent(s): f2d88cb
Clamp all reward scores strictly between 0.001 and 0.999
Browse files- env/models.py +1 -1
- env/reward.py +5 -5
env/models.py
CHANGED
|
@@ -97,7 +97,7 @@ class Reward(BaseModel):
|
|
| 97 |
@field_validator("score")
|
| 98 |
@classmethod
|
| 99 |
def clamp_score(cls, v):
|
| 100 |
-
return max(
|
| 101 |
|
| 102 |
model_config = {"json_schema_extra": {
|
| 103 |
"example": {
|
|
|
|
| 97 |
@field_validator("score")
|
| 98 |
@classmethod
|
| 99 |
def clamp_score(cls, v):
|
| 100 |
+
return max(0.001, min(0.999, round(v, 4)))
|
| 101 |
|
| 102 |
model_config = {"json_schema_extra": {
|
| 103 |
"example": {
|
env/reward.py
CHANGED
|
@@ -96,11 +96,10 @@ def compute_reward(
|
|
| 96 |
# ββ Edge case: null action ββββββββββββββββββββββββββββββββββββ
|
| 97 |
if action is None or action.payload is None:
|
| 98 |
return Reward(
|
| 99 |
-
score=
|
| 100 |
-
breakdown={"invalid_action":
|
| 101 |
-
feedback="Invalid or null action received.
|
| 102 |
)
|
| 103 |
-
|
| 104 |
action_type_val = action.action_type.value if hasattr(action.action_type, "value") else str(action.action_type)
|
| 105 |
action_type_enum = action.action_type
|
| 106 |
|
|
@@ -170,7 +169,8 @@ def compute_reward(
|
|
| 170 |
feedback_parts.append("Approaching max steps limit. Penalty applied.")
|
| 171 |
|
| 172 |
# ββ Clamp to [-1.0, 1.0] βββββββββββββββββββββββββββββββββββββ
|
| 173 |
-
|
|
|
|
| 174 |
breakdown["total"] = final_score
|
| 175 |
|
| 176 |
feedback = " ".join(feedback_parts) if feedback_parts else "Step processed."
|
|
|
|
| 96 |
# ββ Edge case: null action ββββββββββββββββββββββββββββββββββββ
|
| 97 |
if action is None or action.payload is None:
|
| 98 |
return Reward(
|
| 99 |
+
score=0.001,
|
| 100 |
+
breakdown={"invalid_action": 0.001},
|
| 101 |
+
feedback="Invalid or null action received."
|
| 102 |
)
|
|
|
|
| 103 |
action_type_val = action.action_type.value if hasattr(action.action_type, "value") else str(action.action_type)
|
| 104 |
action_type_enum = action.action_type
|
| 105 |
|
|
|
|
| 169 |
feedback_parts.append("Approaching max steps limit. Penalty applied.")
|
| 170 |
|
| 171 |
# ββ Clamp to [-1.0, 1.0] βββββββββββββββββββββββββββββββββββββ
|
| 172 |
+
# Clamp strictly between 0.001 and 0.999 for validator compliance
|
| 173 |
+
final_score = round(max(0.001, min(0.999, final_score)), 4)
|
| 174 |
breakdown["total"] = final_score
|
| 175 |
|
| 176 |
feedback = " ".join(feedback_parts) if feedback_parts else "Step processed."
|