← Lesson
Choosing Models
Joeven
Run
Reset
Python loads on first run
def score_model(m, task): json_ok = m["json_rate"] if task == "json" else 1.0 quality = m["quality"] cost = m["cost"] latency = m["p95_ms"] if json_ok < 0.95 and task == "json": return -1.0 return quality - 0.01 * cost - 0.0001 * latency small = {"name": "small", "json_rate": 0.99, "quality": 0.7, "cost": 0.2, "p95_ms": 400} large = {"name": "large", "json_rate": 0.70, "quality": 0.9, "cost": 3.0, "p95_ms": 2000} for task in ["json", "plan"]: s = score_model(small, task) l = score_model(large, task) winner = small["name"] if s >= l else large["name"] print("task", task, "small", round(s, 3), "large", round(l, 3), "pick", winner)
Run to execute this in your browser. Nothing is sent to a server.