Datasets:
Formats:
parquet
Languages:
English
Size:
10M - 100M
Tags:
biology
chemistry
drug-discovery
clinical-trials
protein-protein-interaction
gene-essentiality
License:
File size: 6,333 Bytes
6d1bbc7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | """Tests for LLM benchmark dataset integrity."""
import json
from collections import Counter
from pathlib import Path
import pytest
EXPORTS_DIR = Path(__file__).resolve().parent.parent / "exports" / "llm_benchmarks"
def _load_jsonl(filename: str) -> list[dict]:
"""Load JSONL file from exports/llm_benchmarks/."""
path = EXPORTS_DIR / filename
if not path.exists():
pytest.skip(f"{path} not found (run build scripts first)")
with open(path) as f:
return [json.loads(line) for line in f]
# ── L1 MCQ Dataset ────────────────────────────────────────────────────────────
class TestL1Dataset:
@pytest.fixture
def records(self):
return _load_jsonl("l1_mcq.jsonl")
def test_total_count(self, records):
# After cross-class dedup + per-class compound cap, count may be < 2000
assert len(records) >= 1800
assert len(records) <= 2000
def test_class_distribution(self, records):
counts = Counter(r["class"] for r in records)
# After dedup, classes may be slightly below target
assert counts["active"] >= 350
assert counts["inactive"] >= 750
assert counts["inconclusive"] >= 200 # DAVIS 68-compound panel limits this
assert counts["conditional"] >= 350
def test_correct_answers(self, records):
answer_map = {
"active": "A",
"inactive": "B",
"inconclusive": "C",
"conditional": "D",
}
for r in records:
assert r["correct_answer"] == answer_map[r["class"]]
def test_split_distribution(self, records):
counts = Counter(r["split"] for r in records)
assert counts["fewshot"] == 200
assert counts["val"] == 200
assert counts["test"] >= 1400 # rest goes to test
def test_fewshot_balanced(self, records):
"""Each class should have 50 few-shot examples."""
fewshot = [r for r in records if r["split"] == "fewshot"]
counts = Counter(r["class"] for r in fewshot)
for cls in ["active", "inactive", "inconclusive", "conditional"]:
assert counts[cls] == 50
def test_required_fields(self, records):
required = [
"question_id", "class", "correct_answer", "difficulty",
"compound_name", "compound_smiles", "target_uniprot",
"context_text", "split",
]
for r in records:
for field in required:
assert field in r, f"Missing {field} in {r.get('question_id')}"
def test_unique_question_ids(self, records):
ids = [r["question_id"] for r in records]
assert len(ids) == len(set(ids))
def test_difficulty_levels(self, records):
difficulties = set(r["difficulty"] for r in records)
assert difficulties.issubset({"easy", "medium", "hard"})
def test_context_text_not_empty(self, records):
for r in records:
assert len(r["context_text"]) > 50
def test_no_cross_class_pair_conflicts(self, records):
"""C-2: Same compound-target pair must not appear in multiple classes."""
pair_classes = {}
for r in records:
ik = r.get("compound_inchikey", "")[:14]
uni = r.get("target_uniprot", "")
pair = (ik, uni)
pair_classes.setdefault(pair, set()).add(r["class"])
conflicts = {p: cls for p, cls in pair_classes.items() if len(cls) > 1}
assert len(conflicts) == 0, f"Cross-class conflicts: {len(conflicts)}"
# ── L4 Tested/Untested Dataset ───────────────────────────────────────────────
class TestL4Dataset:
@pytest.fixture
def records(self):
return _load_jsonl("l4_tested_untested.jsonl")
def test_total_count(self, records):
assert len(records) == 500
def test_class_balance(self, records):
counts = Counter(r["class"] for r in records)
assert counts["tested"] == 250
assert counts["untested"] == 250
def test_temporal_split(self, records):
"""Tested pairs should have temporal groups."""
tested = [r for r in records if r["class"] == "tested"]
temporal = Counter(r.get("temporal_group") for r in tested)
assert temporal["pre_2023"] == 125
assert temporal["post_2024"] == 125
def test_untested_types(self, records):
untested = [r for r in records if r["class"] == "untested"]
types = Counter(r.get("untested_type") for r in untested)
assert types["trick"] == 125
assert types["tdark"] == 125
def test_split_distribution(self, records):
counts = Counter(r["split"] for r in records)
assert counts["fewshot"] == 50
assert counts["val"] == 50
assert counts["test"] == 400
def test_correct_answers(self, records):
for r in records:
assert r["correct_answer"] == r["class"]
def test_unique_question_ids(self, records):
ids = [r["question_id"] for r in records]
assert len(ids) == len(set(ids))
# ── L3 Reasoning Pilot ───────────────────────────────────────────────────────
class TestL3Dataset:
@pytest.fixture
def records(self):
return _load_jsonl("l3_reasoning_pilot.jsonl")
def test_total_count(self, records):
assert len(records) == 50
def test_split_distribution(self, records):
counts = Counter(r["split"] for r in records)
assert counts["fewshot"] == 5
assert counts["val"] == 5
assert counts["test"] == 40
def test_required_fields(self, records):
required = [
"question_id", "compound_name", "compound_smiles",
"target_uniprot", "context_text", "split",
]
for r in records:
for field in required:
assert field in r
def test_evidence_quality(self, records):
"""All L3 pairs should be silver quality."""
for r in records:
assert r.get("evidence_quality") == "silver"
|