Spaces:
Sleeping
Sleeping
GodreignElgin commited on
Commit ·
bbcb74d
1
Parent(s): d7b4a83
Clamp final task scores to open interval
Browse files- README.md +7 -5
- ethicsguard/grader.py +9 -1
- tests/test_env.py +10 -0
- tests/test_grader.py +11 -4
README.md
CHANGED
|
@@ -35,7 +35,7 @@ This makes the benchmark useful for evaluating agent planning, policy following,
|
|
| 35 |
| Actions | `approve`, `flag_remove`, `escalate`, `skip` |
|
| 36 |
| Episode End | Queue empty or 15 steps reached |
|
| 37 |
| Policy | Configurable JSON policy mapping with ordered priority tiers |
|
| 38 |
-
| Output Score | Normalized final score in `
|
| 39 |
|
| 40 |
## Tasks
|
| 41 |
|
|
@@ -79,6 +79,8 @@ Final normalized score is computed as:
|
|
| 79 |
- 30% partial-order tier compliance
|
| 80 |
- 20% efficiency for resolving all tier-1 items within the first 40% of the step budget
|
| 81 |
|
|
|
|
|
|
|
| 82 |
## Baselines
|
| 83 |
|
| 84 |
Implemented baselines in [`ethicsguard/baselines.py`](C:/Users/GODREIGN/Desktop/scalerrrr/Scaler-hack/ethicsguard/baselines.py):
|
|
@@ -101,17 +103,17 @@ Measured results from the current runtime:
|
|
| 101 |
| --- | --- | ---: | ---: | ---: | ---: |
|
| 102 |
| Easy | random | 0.2629 | 0.1327 | 0.0158 | 0.6243 |
|
| 103 |
| Easy | greedy_by_hint | 0.5743 | 0.1804 | 0.1548 | 0.9375 |
|
| 104 |
-
| Easy | rule_based |
|
| 105 |
| Easy | always_escalate | 0.2882 | 0.1496 | 0.0000 | 0.5821 |
|
| 106 |
| Easy | always_approve | 0.3307 | 0.1808 | 0.0375 | 0.6537 |
|
| 107 |
| Medium | random | 0.2947 | 0.1172 | 0.1065 | 0.7667 |
|
| 108 |
| Medium | greedy_by_hint | 0.4538 | 0.1403 | 0.2224 | 0.9000 |
|
| 109 |
-
| Medium | rule_based | 0.
|
| 110 |
| Medium | always_escalate | 0.3104 | 0.1453 | 0.0097 | 0.6625 |
|
| 111 |
| Medium | always_approve | 0.2894 | 0.1205 | 0.1097 | 0.6532 |
|
| 112 |
| Hard | random | 0.2778 | 0.1113 | 0.0187 | 0.7361 |
|
| 113 |
| Hard | greedy_by_hint | 0.3905 | 0.1245 | 0.1583 | 0.9328 |
|
| 114 |
-
| Hard | rule_based | 0.
|
| 115 |
| Hard | always_escalate | 0.2665 | 0.1097 | 0.0805 | 0.6617 |
|
| 116 |
| Hard | always_approve | 0.2594 | 0.1102 | 0.0477 | 0.6888 |
|
| 117 |
|
|
@@ -247,7 +249,7 @@ The following submission gates have been exercised successfully:
|
|
| 247 |
- `docker build` succeeds
|
| 248 |
- `inference.py` runs and produces structured logs
|
| 249 |
- all local tests pass
|
| 250 |
-
- 3 tasks are exposed and scored
|
| 251 |
|
| 252 |
## Comparison
|
| 253 |
|
|
|
|
| 35 |
| Actions | `approve`, `flag_remove`, `escalate`, `skip` |
|
| 36 |
| Episode End | Queue empty or 15 steps reached |
|
| 37 |
| Policy | Configurable JSON policy mapping with ordered priority tiers |
|
| 38 |
+
| Output Score | Normalized final score in `(0.0, 1.0)` |
|
| 39 |
|
| 40 |
## Tasks
|
| 41 |
|
|
|
|
| 79 |
- 30% partial-order tier compliance
|
| 80 |
- 20% efficiency for resolving all tier-1 items within the first 40% of the step budget
|
| 81 |
|
| 82 |
+
To satisfy the benchmark validator, the final published task score is clamped to the open interval `(0, 1)` using a small epsilon. Exact `0.0` and `1.0` are not emitted.
|
| 83 |
+
|
| 84 |
## Baselines
|
| 85 |
|
| 86 |
Implemented baselines in [`ethicsguard/baselines.py`](C:/Users/GODREIGN/Desktop/scalerrrr/Scaler-hack/ethicsguard/baselines.py):
|
|
|
|
| 103 |
| --- | --- | ---: | ---: | ---: | ---: |
|
| 104 |
| Easy | random | 0.2629 | 0.1327 | 0.0158 | 0.6243 |
|
| 105 |
| Easy | greedy_by_hint | 0.5743 | 0.1804 | 0.1548 | 0.9375 |
|
| 106 |
+
| Easy | rule_based | 0.9999 | 0.0000 | 0.9999 | 0.9999 |
|
| 107 |
| Easy | always_escalate | 0.2882 | 0.1496 | 0.0000 | 0.5821 |
|
| 108 |
| Easy | always_approve | 0.3307 | 0.1808 | 0.0375 | 0.6537 |
|
| 109 |
| Medium | random | 0.2947 | 0.1172 | 0.1065 | 0.7667 |
|
| 110 |
| Medium | greedy_by_hint | 0.4538 | 0.1403 | 0.2224 | 0.9000 |
|
| 111 |
+
| Medium | rule_based | 0.9959 | 0.0280 | 0.8000 | 0.9999 |
|
| 112 |
| Medium | always_escalate | 0.3104 | 0.1453 | 0.0097 | 0.6625 |
|
| 113 |
| Medium | always_approve | 0.2894 | 0.1205 | 0.1097 | 0.6532 |
|
| 114 |
| Hard | random | 0.2778 | 0.1113 | 0.0187 | 0.7361 |
|
| 115 |
| Hard | greedy_by_hint | 0.3905 | 0.1245 | 0.1583 | 0.9328 |
|
| 116 |
+
| Hard | rule_based | 0.9886 | 0.0462 | 0.8000 | 0.9999 |
|
| 117 |
| Hard | always_escalate | 0.2665 | 0.1097 | 0.0805 | 0.6617 |
|
| 118 |
| Hard | always_approve | 0.2594 | 0.1102 | 0.0477 | 0.6888 |
|
| 119 |
|
|
|
|
| 249 |
- `docker build` succeeds
|
| 250 |
- `inference.py` runs and produces structured logs
|
| 251 |
- all local tests pass
|
| 252 |
+
- 3 tasks are exposed and scored strictly inside `(0, 1)`
|
| 253 |
|
| 254 |
## Comparison
|
| 255 |
|
ethicsguard/grader.py
CHANGED
|
@@ -5,6 +5,9 @@ import math
|
|
| 5 |
from ethicsguard.models import EpisodeHistory, QueueItem
|
| 6 |
|
| 7 |
|
|
|
|
|
|
|
|
|
|
| 8 |
def _latest_non_skip_actions(history: EpisodeHistory) -> dict[str, tuple[str, int]]:
|
| 9 |
actions: dict[str, tuple[str, int]] = {}
|
| 10 |
for record in history.records:
|
|
@@ -70,4 +73,9 @@ def grade_episode(history: EpisodeHistory, queue_items: list[QueueItem], policy:
|
|
| 70 |
accuracy = _compute_accuracy(history, queue_items)
|
| 71 |
order_compliance = _compute_order_compliance(history, queue_items, policy)
|
| 72 |
efficiency = _compute_efficiency(history, queue_items)
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
from ethicsguard.models import EpisodeHistory, QueueItem
|
| 6 |
|
| 7 |
|
| 8 |
+
SCORE_EPSILON = 0.0001
|
| 9 |
+
|
| 10 |
+
|
| 11 |
def _latest_non_skip_actions(history: EpisodeHistory) -> dict[str, tuple[str, int]]:
|
| 12 |
actions: dict[str, tuple[str, int]] = {}
|
| 13 |
for record in history.records:
|
|
|
|
| 73 |
accuracy = _compute_accuracy(history, queue_items)
|
| 74 |
order_compliance = _compute_order_compliance(history, queue_items, policy)
|
| 75 |
efficiency = _compute_efficiency(history, queue_items)
|
| 76 |
+
raw_score = (0.5 * accuracy) + (0.3 * order_compliance) + (0.2 * efficiency)
|
| 77 |
+
if raw_score <= 0.0:
|
| 78 |
+
return SCORE_EPSILON
|
| 79 |
+
if raw_score >= 1.0:
|
| 80 |
+
return round(1.0 - SCORE_EPSILON, 4)
|
| 81 |
+
return round(raw_score, 4)
|
tests/test_env.py
CHANGED
|
@@ -26,3 +26,13 @@ def test_unknown_item_returns_error_without_ending_episode() -> None:
|
|
| 26 |
result = asyncio.run(env.step(EthicsGuardAction(item_id="missing", action_type="approve")))
|
| 27 |
assert result.done is False
|
| 28 |
assert result.last_action_error is not None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
result = asyncio.run(env.step(EthicsGuardAction(item_id="missing", action_type="approve")))
|
| 27 |
assert result.done is False
|
| 28 |
assert result.last_action_error is not None
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def test_terminal_score_is_in_open_interval() -> None:
|
| 32 |
+
env = EthicsGuardEnv(difficulty="easy", seed=1000)
|
| 33 |
+
result = asyncio.run(env.reset())
|
| 34 |
+
while not result.done:
|
| 35 |
+
item_id = result.observation.remaining_queue[0].id
|
| 36 |
+
result = asyncio.run(env.step(EthicsGuardAction(item_id=item_id, action_type="approve")))
|
| 37 |
+
assert result.score is not None
|
| 38 |
+
assert 0.0 < result.score < 1.0
|
tests/test_grader.py
CHANGED
|
@@ -4,7 +4,7 @@ from ethicsguard.models import EpisodeHistory, StepRecord
|
|
| 4 |
from ethicsguard.policy import DEFAULT_POLICY
|
| 5 |
|
| 6 |
|
| 7 |
-
def
|
| 8 |
queue = generate_queue(seed=1000, difficulty="easy")
|
| 9 |
ordered_queue = sorted(queue, key=lambda item: (item.priority_tier, item.id))
|
| 10 |
history = EpisodeHistory(
|
|
@@ -23,10 +23,16 @@ def test_perfect_episode_scores_one() -> None:
|
|
| 23 |
for index, item in enumerate(ordered_queue, start=1)
|
| 24 |
],
|
| 25 |
)
|
| 26 |
-
assert grade_episode(history, queue, DEFAULT_POLICY) ==
|
| 27 |
|
| 28 |
|
| 29 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
queue = generate_queue(seed=1000, difficulty="easy")
|
| 31 |
history = EpisodeHistory(
|
| 32 |
total_items=len(queue),
|
|
@@ -43,4 +49,5 @@ def test_skipped_items_reduce_score() -> None:
|
|
| 43 |
)
|
| 44 |
],
|
| 45 |
)
|
| 46 |
-
|
|
|
|
|
|
| 4 |
from ethicsguard.policy import DEFAULT_POLICY
|
| 5 |
|
| 6 |
|
| 7 |
+
def test_perfect_episode_scores_strictly_below_one() -> None:
|
| 8 |
queue = generate_queue(seed=1000, difficulty="easy")
|
| 9 |
ordered_queue = sorted(queue, key=lambda item: (item.priority_tier, item.id))
|
| 10 |
history = EpisodeHistory(
|
|
|
|
| 23 |
for index, item in enumerate(ordered_queue, start=1)
|
| 24 |
],
|
| 25 |
)
|
| 26 |
+
assert grade_episode(history, queue, DEFAULT_POLICY) == 0.9999
|
| 27 |
|
| 28 |
|
| 29 |
+
def test_empty_progress_scores_strictly_above_zero() -> None:
|
| 30 |
+
queue = generate_queue(seed=1000, difficulty="easy")
|
| 31 |
+
history = EpisodeHistory(total_items=len(queue), max_steps=15, records=[])
|
| 32 |
+
assert grade_episode(history, queue, DEFAULT_POLICY) == 0.0001
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def test_skipped_items_keep_score_in_open_interval() -> None:
|
| 36 |
queue = generate_queue(seed=1000, difficulty="easy")
|
| 37 |
history = EpisodeHistory(
|
| 38 |
total_items=len(queue),
|
|
|
|
| 49 |
)
|
| 50 |
],
|
| 51 |
)
|
| 52 |
+
score = grade_episode(history, queue, DEFAULT_POLICY)
|
| 53 |
+
assert 0.0 < score < 1.0
|