Upload 2 files
Browse files- practice_answers.csv +10 -0
- score_practice.py +58 -0
practice_answers.csv
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
endpoint,family,model,kind
|
| 2 |
+
ref-01,P,S,plain
|
| 3 |
+
ref-02,P,T1,quantized (fp8)
|
| 4 |
+
ref-03,P,S,system prompt
|
| 5 |
+
ref-04,P,T3,LoRA at strength 0.7
|
| 6 |
+
ref-05,P,S,persona
|
| 7 |
+
ref-06,P,S,watermark
|
| 8 |
+
ref-07,P,T4,LoRA at strength 1.5
|
| 9 |
+
ref-08,P,S,sampling at temperature 1.0
|
| 10 |
+
ref-09,P,T2,LoRA at strength 0.3
|
score_practice.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Score your answer for the practice endpoints (ref-01 ... ref-09) against their published answers.
|
| 2 |
+
|
| 3 |
+
The practice endpoints are a separate small model with the same kinds of disguises and traps as the scored endpoints.
|
| 4 |
+
They are never scored on the server; use them to check your method. Write your practice answer in the same format as a
|
| 5 |
+
submission (one line per endpoint: endpoint,family,model; a header line is allowed) and run:
|
| 6 |
+
|
| 7 |
+
python score_practice.py my_practice_answer.csv [practice_answers.csv]
|
| 8 |
+
|
| 9 |
+
Lines for scored endpoints (ep-..) are ignored, so you can also run it on your full working file. It prints the
|
| 10 |
+
Matthews correlation coefficient (MCC) over the practice pairs ("same model?"), as the server computes the model part
|
| 11 |
+
of the score, and lists the pairs you got wrong. No packages needed beyond Python 3.
|
| 12 |
+
"""
|
| 13 |
+
import csv
|
| 14 |
+
import itertools
|
| 15 |
+
import math
|
| 16 |
+
import sys
|
| 17 |
+
from pathlib import Path
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def read(path, with_kind=False):
|
| 21 |
+
rows = [[c.strip() for c in r] for r in csv.reader(open(path, newline="", encoding="utf-8-sig")) if any(c.strip() for c in r)]
|
| 22 |
+
if rows and rows[0][:3] == ["endpoint", "family", "model"]:
|
| 23 |
+
rows = rows[1:]
|
| 24 |
+
out = {}
|
| 25 |
+
for r in rows:
|
| 26 |
+
if len(r) >= 3 and r[0].startswith("ref-"):
|
| 27 |
+
out[r[0]] = (r[1], r[2], r[3] if with_kind and len(r) > 3 else "")
|
| 28 |
+
return out
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def main():
|
| 32 |
+
if len(sys.argv) < 2:
|
| 33 |
+
sys.exit(__doc__)
|
| 34 |
+
answers = read(sys.argv[2] if len(sys.argv) > 2 else Path(__file__).with_name("practice_answers.csv"), with_kind=True)
|
| 35 |
+
mine = read(sys.argv[1])
|
| 36 |
+
missing = sorted(set(answers) - set(mine))
|
| 37 |
+
if missing:
|
| 38 |
+
sys.exit(f"Your file has no line for: {', '.join(missing)}")
|
| 39 |
+
same = lambda d, a, b: (d[a][0], d[a][1]) == (d[b][0], d[b][1]) # same model = same family and same model label
|
| 40 |
+
tp = fp = fn = tn = 0
|
| 41 |
+
wrong = []
|
| 42 |
+
for a, b in itertools.combinations(sorted(answers), 2):
|
| 43 |
+
truth, guess = same(answers, a, b), same(mine, a, b)
|
| 44 |
+
tp += truth and guess; fp += (not truth) and guess; fn += truth and not guess; tn += (not truth) and not guess
|
| 45 |
+
if truth != guess:
|
| 46 |
+
wrong.append(f" {a} ({answers[a][2]}) and {b} ({answers[b][2]}): you said {'same' if guess else 'different'}, "
|
| 47 |
+
f"they are {'the same model' if truth else 'different models'}")
|
| 48 |
+
d = math.sqrt((tp + fp) * (tp + fn) * (tn + fp) * (tn + fn))
|
| 49 |
+
mcc = max(0.0, (tp * tn - fp * fn) / d) if d else 0.0
|
| 50 |
+
print(f"Practice score (MCC over {tp + fp + fn + tn} pairs, same model or not): {mcc:.3f}")
|
| 51 |
+
print(f"Right: {tp + tn} pairs, wrong: {fp + fn} ({fp} wrongly called the same, {fn} wrongly called different)")
|
| 52 |
+
if wrong:
|
| 53 |
+
print("Wrong pairs:")
|
| 54 |
+
print("\n".join(wrong))
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
if __name__ == "__main__":
|
| 58 |
+
main()
|