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

Update task_template.py

Browse files
Files changed (1) hide show
  1. task_template.py +16 -5
task_template.py CHANGED
@@ -13,6 +13,8 @@ This file shows you how to
13
  2. send prompts to the endpoints and save the answers (query()),
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):
@@ -177,14 +179,24 @@ def write_submission(rows: list, path: Path = OUTPUT_FILE) -> None:
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
 
@@ -192,7 +204,7 @@ 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:
@@ -204,8 +216,7 @@ def main() -> None:
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)
 
13
  2. send prompts to the endpoints and save the answers (query()),
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
+ To test your method first on endpoints with known answers, use the reference endpoints ref-01 ... ref-09 with
17
+ query_reference.py (no query limit, never scored).
18
 
19
  Submission file: a CSV with one line per endpoint and three columns, endpoint,family,model (the header line is optional,
20
  the order of the lines does not matter). Labels are any text you like (no commas):
 
179
  writer.writerows(rows)
180
 
181
 
182
+ def letters(i: int) -> str:
183
+ """0 -> A, 1 -> B, ..., 25 -> Z, 26 -> AA, ... (family labels in the style of the example above)."""
184
+ name = ""
185
+ i += 1
186
+ while i:
187
+ i, r = divmod(i - 1, 26)
188
+ name = chr(65 + r) + name
189
+ return name
190
+
191
+
192
  def make_random_submission(endpoints: list = ENDPOINTS, families: int = 3, seed: int = None) -> list:
193
  """A random valid submission: every endpoint gets a random family, and inside a family a random model label.
194
  Two endpoints with the same model label always share the family label. Returns [(endpoint, family, model), ...]."""
195
  rng = random.Random(seed)
196
  rows = []
197
  for endpoint in endpoints:
198
+ family = letters(rng.randrange(families))
199
+ rows.append((endpoint, family, f"{family}{rng.randrange(3) + 1}"))
200
  return rows
201
 
202
 
 
204
  """TODO: your method. Must return [(endpoint, family, model), ...], one row per endpoint. Endpoints with the same
205
  model label must share the family label. This baseline says "all different" (every endpoint in its own family and
206
  model); it scores 0."""
207
+ return [(endpoint, letters(i), f"{letters(i)}1") for i, endpoint in enumerate(endpoints)]
208
 
209
 
210
  def main() -> None:
 
216
  print("Budget left per endpoint:")
217
  for ep, n in budget.items():
218
  print(f" {ep}: {n}")
219
+ endpoints = [ep for ep in budget if ep.startswith("ep-")] # the scored endpoints
 
220
  if QUERY:
221
  if not PROMPTS_FILE.exists():
222
  print(f"Error: {PROMPTS_FILE} not found. Write your prompts there (one per line).", file=sys.stderr)