maitri01 commited on
Commit
ee9b849
·
verified ·
1 Parent(s): c78eae3

Update task_template.py

Browse files
Files changed (1) hide show
  1. task_template.py +41 -26
task_template.py CHANGED
@@ -1,7 +1,7 @@
1
  """Model equality challenge - task template (task 33-model-equality).
2
 
3
  You are given
4
- 18 API endpoints, ep-01 ... ep-18 (in this order), some of which serve the same model.
5
  Each team can collect up to 100 answers per endpoint (at most 256 generated tokens per answer, prompts up to 1,024
6
  tokens), with at most 4 requests at a time.
7
 
@@ -14,12 +14,19 @@ This file shows you how to
14
  3. write a random, valid submission file (make_random_submission()), as an example of the file format.
15
  Put your method in solve().
16
 
17
- Submission file: a plain 18 x 18 matrix of 0 and 1 in a .csv file (no header, no ID column), one line per endpoint,
18
- rows and columns in the order ep-01 ... ep-18. Entry [i][j] = 1 means "endpoint i and endpoint j serve the same
19
- model". The matrix must be symmetric with 1 on the diagonal. Submit it with submission.py.
 
 
 
 
 
 
20
 
21
- Score: Matthews correlation coefficient (MCC), clipped at 0, over the 153 endpoint pairs. Answering "all different" or
22
- "all same" scores 0. The leaderboard shows the score on a public part of the pairs; the final ranking uses the rest.
 
23
 
24
  Needs: pip install requests
25
  """
@@ -45,7 +52,8 @@ OUTPUT_FILE = Path("submission.csv")
45
  QUERY = False # set to True to query the endpoints
46
  RANDOM_SUBMISSION = False # set to True to write a random example submission
47
 
48
- ENDPOINTS = [f"ep-{i:02d}" for i in range(1, 19)]
 
49
  REPEATS = 1 # answers per prompt and endpoint (answers are sampled, so they differ)
50
  MAX_TOKENS = 256 # the server caps answers at 256 tokens
51
  PARALLEL = 4 # the most requests the server allows at once per team
@@ -160,26 +168,31 @@ def query(prompts: list, output: Path = ANSWERS_FILE, endpoints: list = ENDPOINT
160
  print(f"Finished: {output}")
161
 
162
 
163
- def write_submission(matrix: list, path: Path = OUTPUT_FILE) -> None:
164
- """Writes an n x n 0/1 matrix as a plain CSV (no header, no ID column)."""
 
165
  with path.open("w", newline="") as handle:
166
- csv.writer(handle).writerows(matrix)
 
 
167
 
168
 
169
- def make_random_submission(n: int = len(ENDPOINTS), groups: int = None, seed: int = None) -> list:
170
- """A random valid submission: the endpoints are split into random groups, so "same" is consistent
171
- (if i~j and j~k then i~k). The matrix is symmetric with a diagonal of 1."""
172
  rng = random.Random(seed)
173
- groups = groups or max(1, n // 2)
174
- group_of = [rng.randrange(groups) for _ in range(n)]
175
- return [[int(group_of[i] == group_of[j]) for j in range(n)] for i in range(n)]
 
 
176
 
177
 
178
- def solve() -> list:
179
- """TODO: your method. Must return an 18 x 18 symmetric 0/1 matrix (list of lists) with 1 on the diagonal,
180
- rows and columns in the order ep-01 ... ep-18. This baseline says "all different" (it scores 0)."""
181
- n = len(ENDPOINTS)
182
- return [[int(i == j) for j in range(n)] for i in range(n)]
183
 
184
 
185
  def main() -> None:
@@ -187,21 +200,23 @@ def main() -> None:
187
  print("Set API_KEY at the top of task_template.py to your team's API key.", file=sys.stderr)
188
  raise SystemExit(1)
189
 
 
190
  print("Budget left per endpoint:")
191
- for ep, n in get_budget(make_session()).items():
192
  print(f" {ep}: {n}")
 
193
 
194
  if QUERY:
195
  if not PROMPTS_FILE.exists():
196
  print(f"Error: {PROMPTS_FILE} not found. Write your prompts there (one per line).", file=sys.stderr)
197
  raise SystemExit(1)
198
- query(read_prompts(PROMPTS_FILE))
199
 
200
  if RANDOM_SUBMISSION:
201
- matrix = make_random_submission()
202
  else:
203
- matrix = solve()
204
- write_submission(matrix)
205
  print(f"Saved submission to {OUTPUT_FILE}. Upload it with submission.py.")
206
 
207
 
 
1
  """Model equality challenge - task template (task 33-model-equality).
2
 
3
  You are given
4
+ 33 API endpoints, ep-01 ... ep-33 (in this order), some of which serve the same model.
5
  Each team can collect up to 100 answers per endpoint (at most 256 generated tokens per answer, prompts up to 1,024
6
  tokens), with at most 4 requests at a time.
7
 
 
14
  3. write a random, valid submission file (make_random_submission()), as an example of the file format.
15
  Put your method in solve().
16
 
17
+ Submission file: a CSV with one line per endpoint and three columns, endpoint,family,model (the header line is optional,
18
+ the order of the lines does not matter). Labels are any text you like (no commas):
19
+ endpoint,family,model
20
+ ep-01,A,A1
21
+ ep-02,B,B1
22
+ ep-03,A,A2
23
+ Endpoints with the same family label are built on the same base model. Endpoints with the same model label serve exactly
24
+ the same model; they must also share the family label. Submit it with submission.py. The old matrix format is no longer
25
+ accepted.
26
 
27
+ Score: Matthews correlation coefficient (MCC, below 0 counts as 0) over pairs of endpoints. 10 % of the score is for the
28
+ same-family question (all pairs), 90 % for the same-model question (only pairs within one family). The leaderboard shows
29
+ the score on a part of the pairs; the final ranking uses the rest.
30
 
31
  Needs: pip install requests
32
  """
 
52
  QUERY = False # set to True to query the endpoints
53
  RANDOM_SUBMISSION = False # set to True to write a random example submission
54
 
55
+ NUM_ENDPOINTS = 33 # the server lists the real endpoints: python task_template.py prints them
56
+ ENDPOINTS = [f"ep-{i:02d}" for i in range(1, NUM_ENDPOINTS + 1)]
57
  REPEATS = 1 # answers per prompt and endpoint (answers are sampled, so they differ)
58
  MAX_TOKENS = 256 # the server caps answers at 256 tokens
59
  PARALLEL = 4 # the most requests the server allows at once per team
 
168
  print(f"Finished: {output}")
169
 
170
 
171
+ def write_submission(rows: list, path: Path = OUTPUT_FILE) -> None:
172
+ """Writes the submission as a CSV with the header endpoint,family,model and one (endpoint, family, model) row per
173
+ endpoint."""
174
  with path.open("w", newline="") as handle:
175
+ writer = csv.writer(handle)
176
+ writer.writerow(["endpoint", "family", "model"])
177
+ writer.writerows(rows)
178
 
179
 
180
+ def make_random_submission(endpoints: list = ENDPOINTS, families: int = 3, seed: int = None) -> list:
181
+ """A random valid submission: every endpoint gets a random family, and inside a family a random model label.
182
+ Two endpoints with the same model label always share the family label. Returns [(endpoint, family, model), ...]."""
183
  rng = random.Random(seed)
184
+ rows = []
185
+ for endpoint in endpoints:
186
+ family = f"F{rng.randrange(families)}"
187
+ rows.append((endpoint, family, f"{family}-M{rng.randrange(3)}"))
188
+ return rows
189
 
190
 
191
+ def solve(endpoints: list = ENDPOINTS) -> list:
192
+ """TODO: your method. Must return [(endpoint, family, model), ...], one row per endpoint. Endpoints with the same
193
+ model label must share the family label. This baseline says "all different" (every endpoint in its own family and
194
+ model); it scores 0."""
195
+ return [(endpoint, f"F{i}", f"M{i}") for i, endpoint in enumerate(endpoints, 1)]
196
 
197
 
198
  def main() -> None:
 
200
  print("Set API_KEY at the top of task_template.py to your team's API key.", file=sys.stderr)
201
  raise SystemExit(1)
202
 
203
+ budget = get_budget(make_session())
204
  print("Budget left per endpoint:")
205
+ for ep, n in budget.items():
206
  print(f" {ep}: {n}")
207
+ endpoints = [ep for ep in budget if ep.startswith("ep-")] # the server also lists the ref-* practice endpoints
208
 
209
  if QUERY:
210
  if not PROMPTS_FILE.exists():
211
  print(f"Error: {PROMPTS_FILE} not found. Write your prompts there (one per line).", file=sys.stderr)
212
  raise SystemExit(1)
213
+ query(read_prompts(PROMPTS_FILE), endpoints=endpoints)
214
 
215
  if RANDOM_SUBMISSION:
216
+ rows = make_random_submission(endpoints)
217
  else:
218
+ rows = solve(endpoints)
219
+ write_submission(rows)
220
  print(f"Saved submission to {OUTPUT_FILE}. Upload it with submission.py.")
221
 
222