Sibam commited on
Commit
447a565
Β·
1 Parent(s): a4c268d

feat: update inference, models, and server logic

Browse files
Files changed (3) hide show
  1. inference.py +9 -1
  2. models.py +2 -3
  3. server/app.py +32 -0
inference.py CHANGED
@@ -229,7 +229,15 @@ def main():
229
  scores.append(run_task(env, "likert", "likert-scoring"))
230
  scores.append(run_task(env, "consistency", "consistency-ranking"))
231
 
232
- print(f"\nOverall avg: {sum(scores) / len(scores):.2f}", flush=True)
 
 
 
 
 
 
 
 
233
 
234
 
235
  if __name__ == "__main__":
 
229
  scores.append(run_task(env, "likert", "likert-scoring"))
230
  scores.append(run_task(env, "consistency", "consistency-ranking"))
231
 
232
+ if scores:
233
+ print(f"\nOverall avg: {sum(scores) / len(scores):.2f}", flush=True)
234
+
235
+ if len(scores) >= 3:
236
+ print("\n=== CURRICULUM LEARNING DEMO ===")
237
+ print(f"Task 1 Pairwise (Easy): {scores[0]:.2f}")
238
+ print(f"Task 2 Likert (Medium): {scores[1]:.2f}")
239
+ print(f"Task 3 Consistency (Hard): {scores[2]:.2f}")
240
+ print(f"Difficulty progression: {scores[0]:.2f} β†’ {scores[1]:.2f} β†’ {scores[2]:.2f}")
241
 
242
 
243
  if __name__ == "__main__":
models.py CHANGED
@@ -32,9 +32,8 @@ class PairwiseAction(Action):
32
  description="Optional reasoning for the choice (not used for grading).",
33
  )
34
  confidence: float = Field(
35
- default=0.8,
36
- ge=0.0, le=1.0,
37
- description="Annotator confidence in this choice (0.0-1.0)"
38
  )
39
 
40
 
 
32
  description="Optional reasoning for the choice (not used for grading).",
33
  )
34
  confidence: float = Field(
35
+ default=0.8, ge=0.0, le=1.0,
36
+ description="Annotator confidence (0.0-1.0)"
 
37
  )
38
 
39
 
server/app.py CHANGED
@@ -56,6 +56,38 @@ if not ENABLE_WEB_INTERFACE:
56
  max_concurrent_envs=MAX_CONCURRENT_ENVS,
57
  )
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
  # ── Browser housekeeping routes ────────────────────────────────
61
  # Browsers auto-request these; returning proper responses prevents
 
56
  max_concurrent_envs=MAX_CONCURRENT_ENVS,
57
  )
58
 
59
+ from collections import defaultdict
60
+ from threading import Lock
61
+ from pydantic import BaseModel, Field
62
+
63
+ leaderboard = defaultdict(list)
64
+ leaderboard_lock = Lock()
65
+
66
+ class LeaderboardEntry(BaseModel):
67
+ model: str = Field(..., min_length=1, max_length=255)
68
+ score: float = Field(..., ge=0.0, le=1.0)
69
+
70
+ @app.get("/leaderboard")
71
+ def get_leaderboard():
72
+ with leaderboard_lock:
73
+ return {
74
+ model: {
75
+ "avg_score": sum(scores)/len(scores) if scores else 0,
76
+ "runs": len(scores),
77
+ "scores": scores[-50:] # Limit returned scores to last 50
78
+ }
79
+ for model, scores in leaderboard.items()
80
+ }
81
+
82
+ @app.post("/leaderboard/submit")
83
+ def submit_score(entry: LeaderboardEntry):
84
+ with leaderboard_lock:
85
+ leaderboard[entry.model].append(entry.score)
86
+ # Limit stored scores to prevent memory issues
87
+ if len(leaderboard[entry.model]) > 1000:
88
+ leaderboard[entry.model] = leaderboard[entry.model][-1000:]
89
+ return {"status": "recorded"}
90
+
91
 
92
  # ── Browser housekeeping routes ────────────────────────────────
93
  # Browsers auto-request these; returning proper responses prevents