Spaces:
Running
Running
Sibam commited on
Commit Β·
447a565
1
Parent(s): a4c268d
feat: update inference, models, and server logic
Browse filesFiles changed (3)
- inference.py+9-1
- models.py+2-3
- server/app.py+32
228 unmodified lines229230231232232233234235236237238239240241242243228 unmodified lines scores.append(run_task(env, "likert", "likert-scoring")) scores.append(run_task(env, "consistency", "consistency-ranking"))
if scores: print(f"\nOverall avg: {sum(scores) / len(scores):.2f}", flush=True) print(f"\nOverall avg: {sum(scores) / len(scores):.2f}", flush=True)
if len(scores) >= 3: print("\n=== CURRICULUM LEARNING DEMO ===") print(f"Task 1 Pairwise (Easy): {scores[0]:.2f}") print(f"Task 2 Likert (Medium): {scores[1]:.2f}") print(f"Task 3 Consistency (Hard): {scores[2]:.2f}") print(f"Difficulty progression: {scores[0]:.2f} β {scores[1]:.2f} β {scores[2]:.2f}")
if __name__ == "__main__":31 unmodified lines323334353637353637383931 unmodified lines description="Optional reasoning for the choice (not used for grading).", ) confidence: float = Field( default=0.8, ge=0.0, le=1.0, description="Annotator confidence in this choice (0.0-1.0)" default=0.8, ge=0.0, le=1.0, description="Annotator confidence (0.0-1.0)" )
55 unmodified lines565758596061626364656667686970717273747576777879808182838485868788899091929355 unmodified lines max_concurrent_envs=MAX_CONCURRENT_ENVS, )
from collections import defaultdictfrom threading import Lockfrom pydantic import BaseModel, Field
leaderboard = defaultdict(list)leaderboard_lock = Lock()
class LeaderboardEntry(BaseModel): model: str = Field(..., min_length=1, max_length=255) score: float = Field(..., ge=0.0, le=1.0)
@app.get("/leaderboard")def get_leaderboard(): with leaderboard_lock: return { model: { "avg_score": sum(scores)/len(scores) if scores else 0, "runs": len(scores), "scores": scores[-50:] # Limit returned scores to last 50 } for model, scores in leaderboard.items() }
@app.post("/leaderboard/submit")def submit_score(entry: LeaderboardEntry): with leaderboard_lock: leaderboard[entry.model].append(entry.score) # Limit stored scores to prevent memory issues if len(leaderboard[entry.model]) > 1000: leaderboard[entry.model] = leaderboard[entry.model][-1000:] return {"status": "recorded"}
# ββ Browser housekeeping routes ββββββββββββββββββββββββββββββββ# Browsers auto-request these; returning proper responses preventsinference.py+9-1
models.py+2-3
server/app.py+32