(path)
| 18 | |
| 19 | |
| 20 | def load_split(path): |
| 21 | rows = [] |
| 22 | with open(path) as f: |
| 23 | for line in f: |
| 24 | if line.strip(): |
| 25 | rows.append(json.loads(line)) |
| 26 | texts, labels = [], [] |
| 27 | for row in rows: |
| 28 | for m in reversed(row.get("messages", [])): |
| 29 | if m.get("role") == "user": |
| 30 | text = _normalize_content(m.get("content", "")) |
| 31 | if text.strip(): |
| 32 | texts.append(text) |
| 33 | labels.append(row["target_tier_id"]) |
| 34 | break |
| 35 | return texts, labels |
| 36 | |
| 37 | |
| 38 | def make_contrastive_pairs(texts, labels, n_pairs=5000, seed=42): |
no test coverage detected