Spaces:
Sleeping
Sleeping
Aneesha Das commited on
Commit Β·
fba0197
1
Parent(s): 2491675
Updated
Browse files- __pycache__/environment.cpython-312.pyc +0 -0
- baseline_results.json +4 -4
- environment.py +23 -47
- inference.py +1 -1
- openenv.yaml +4 -4
- server/app.py +1 -1
__pycache__/environment.cpython-312.pyc
CHANGED
|
Binary files a/__pycache__/environment.cpython-312.pyc and b/__pycache__/environment.cpython-312.pyc differ
|
|
|
baseline_results.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
| 2 |
"model": "Qwen/Qwen2.5-72B-Instruct",
|
| 3 |
"benchmark": "email-triage-v1",
|
| 4 |
"tasks": {
|
| 5 |
-
"easy": 0.
|
| 6 |
-
"medium": 0.
|
| 7 |
-
"hard": 0.
|
| 8 |
},
|
| 9 |
-
"overall": 0.
|
| 10 |
}
|
|
|
|
| 2 |
"model": "Qwen/Qwen2.5-72B-Instruct",
|
| 3 |
"benchmark": "email-triage-v1",
|
| 4 |
"tasks": {
|
| 5 |
+
"easy": 0.892,
|
| 6 |
+
"medium": 0.9819,
|
| 7 |
+
"hard": 0.7475
|
| 8 |
},
|
| 9 |
+
"overall": 0.8738
|
| 10 |
}
|
environment.py
CHANGED
|
@@ -109,58 +109,34 @@ class EmailTriageEnv:
|
|
| 109 |
self._step_num: int = 0
|
| 110 |
self._done: bool = False
|
| 111 |
self._cumulative_reward: float = 0.0
|
| 112 |
-
self._constraints:
|
| 113 |
-
escalation_budget=0,
|
| 114 |
-
sla_tracker=[],
|
| 115 |
-
)
|
| 116 |
|
| 117 |
# ββ OpenEnv Interface βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 118 |
|
| 119 |
def reset(self) -> Observation:
|
| 120 |
"""Reset all state and return initial observation."""
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
self._constraints.sla_tracker.append(
|
| 144 |
-
SlaStatus(
|
| 145 |
-
email_id=raw["email"]["header"]["email_id"],
|
| 146 |
-
true_priority=gt_priority,
|
| 147 |
-
arrived_at_step=i,
|
| 148 |
-
deadline_step=deadline,
|
| 149 |
-
)
|
| 150 |
-
)
|
| 151 |
-
|
| 152 |
-
return self._make_observation()
|
| 153 |
-
|
| 154 |
-
except Exception as exc:
|
| 155 |
-
print(f"[DEBUG] reset() failed: {exc}", flush=True)
|
| 156 |
-
self._done = True
|
| 157 |
-
self._emails = []
|
| 158 |
-
self._processed_ids = []
|
| 159 |
-
self._actions_log = []
|
| 160 |
-
self._step_num = 0
|
| 161 |
-
self._cumulative_reward = 0.0
|
| 162 |
-
return self._make_observation()
|
| 163 |
-
|
| 164 |
|
| 165 |
def step(self, action: Action) -> Tuple[Observation, Reward, bool, Dict[str, Any]]:
|
| 166 |
"""
|
|
|
|
| 109 |
self._step_num: int = 0
|
| 110 |
self._done: bool = False
|
| 111 |
self._cumulative_reward: float = 0.0
|
| 112 |
+
self._constraints: SessionConstraints = SessionConstraints()
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
# ββ OpenEnv Interface βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 115 |
|
| 116 |
def reset(self) -> Observation:
|
| 117 |
"""Reset all state and return initial observation."""
|
| 118 |
+
self._emails = [_build_email_message(e) for e in self._dataset]
|
| 119 |
+
self._processed_ids = []
|
| 120 |
+
self._actions_log = []
|
| 121 |
+
self._step_num = 0
|
| 122 |
+
self._done = False
|
| 123 |
+
self._cumulative_reward = 0.0
|
| 124 |
+
|
| 125 |
+
budget = TASK_ESCALATION_BUDGET[self.task_id]
|
| 126 |
+
self._constraints = SessionConstraints(escalation_budget=budget)
|
| 127 |
+
|
| 128 |
+
# Register every email in the SLA tracker immediately
|
| 129 |
+
for i, raw in enumerate(self._dataset):
|
| 130 |
+
gt_priority = raw["ground_truth"]["priority"]
|
| 131 |
+
deadline = i + SLA_STEPS.get(gt_priority, 99)
|
| 132 |
+
self._constraints.sla_tracker.append(SlaStatus(
|
| 133 |
+
email_id = raw["email"]["header"]["email_id"],
|
| 134 |
+
true_priority = gt_priority,
|
| 135 |
+
arrived_at_step = i, # emails are revealed sequentially
|
| 136 |
+
deadline_step = deadline,
|
| 137 |
+
))
|
| 138 |
+
|
| 139 |
+
return self._make_observation()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
def step(self, action: Action) -> Tuple[Observation, Reward, bool, Dict[str, Any]]:
|
| 142 |
"""
|
inference.py
CHANGED
|
@@ -301,7 +301,7 @@ def run_task(client: Optional[OpenAI], task_id: str) -> float:
|
|
| 301 |
done=done, error=env_error)
|
| 302 |
|
| 303 |
# Compute final score from grader
|
| 304 |
-
from
|
| 305 |
grader_result = grade_episode(env._actions_log)
|
| 306 |
score = grader_result.get("label_score", 0.0)
|
| 307 |
score = min(max(score, 0.0), 1.0)
|
|
|
|
| 301 |
done=done, error=env_error)
|
| 302 |
|
| 303 |
# Compute final score from grader
|
| 304 |
+
from grader import grade_episode
|
| 305 |
grader_result = grade_episode(env._actions_log)
|
| 306 |
score = grader_result.get("label_score", 0.0)
|
| 307 |
score = min(max(score, 0.0), 1.0)
|
openenv.yaml
CHANGED
|
@@ -30,7 +30,7 @@ tasks:
|
|
| 30 |
n_emails: 5
|
| 31 |
escalation_budget: 3
|
| 32 |
expected_score_range: [0.75, 0.99]
|
| 33 |
-
grader:
|
| 34 |
|
| 35 |
- id: medium
|
| 36 |
name: Mixed Inbox Triage
|
|
@@ -43,7 +43,7 @@ tasks:
|
|
| 43 |
n_emails: 8
|
| 44 |
escalation_budget: 4
|
| 45 |
expected_score_range: [0.50, 0.80]
|
| 46 |
-
grader:
|
| 47 |
|
| 48 |
- id: hard
|
| 49 |
name: High-Stakes Inbox Triage
|
|
@@ -57,7 +57,7 @@ tasks:
|
|
| 57 |
n_emails: 10
|
| 58 |
escalation_budget: 5
|
| 59 |
expected_score_range: [0.35, 0.75]
|
| 60 |
-
grader:
|
| 61 |
|
| 62 |
observation_space:
|
| 63 |
type: object
|
|
@@ -218,7 +218,7 @@ baseline_scores:
|
|
| 218 |
|
| 219 |
environment:
|
| 220 |
python: ">=3.10"
|
| 221 |
-
entrypoint:
|
| 222 |
reset: reset
|
| 223 |
step: step
|
| 224 |
state: state
|
|
|
|
| 30 |
n_emails: 5
|
| 31 |
escalation_budget: 3
|
| 32 |
expected_score_range: [0.75, 0.99]
|
| 33 |
+
grader: grader.grade_episode
|
| 34 |
|
| 35 |
- id: medium
|
| 36 |
name: Mixed Inbox Triage
|
|
|
|
| 43 |
n_emails: 8
|
| 44 |
escalation_budget: 4
|
| 45 |
expected_score_range: [0.50, 0.80]
|
| 46 |
+
grader: grader.grade_episode
|
| 47 |
|
| 48 |
- id: hard
|
| 49 |
name: High-Stakes Inbox Triage
|
|
|
|
| 57 |
n_emails: 10
|
| 58 |
escalation_budget: 5
|
| 59 |
expected_score_range: [0.35, 0.75]
|
| 60 |
+
grader: grader.grade_episode
|
| 61 |
|
| 62 |
observation_space:
|
| 63 |
type: object
|
|
|
|
| 218 |
|
| 219 |
environment:
|
| 220 |
python: ">=3.10"
|
| 221 |
+
entrypoint: environment:EmailTriageEnv
|
| 222 |
reset: reset
|
| 223 |
step: step
|
| 224 |
state: state
|
server/app.py
CHANGED
|
@@ -16,7 +16,7 @@ class Action(BaseModel):
|
|
| 16 |
@app.post("/reset")
|
| 17 |
def reset(task: str = "easy"):
|
| 18 |
global env
|
| 19 |
-
env = EmailTriageEnv(
|
| 20 |
obs = env.reset()
|
| 21 |
return obs
|
| 22 |
|
|
|
|
| 16 |
@app.post("/reset")
|
| 17 |
def reset(task: str = "easy"):
|
| 18 |
global env
|
| 19 |
+
env = EmailTriageEnv(task_id=task)
|
| 20 |
obs = env.reset()
|
| 21 |
return obs
|
| 22 |
|