Spaces:
Build error
Build error
File size: 1,091 Bytes
11d79f9 | 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 | from __future__ import annotations
import json
import sys
from pathlib import Path
if __package__ in {None, ""}:
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from lab03.config import BuildConfig
from lab03.dataset_utils import MedicalRecord
from lab03.evaluation import evaluate_retriever, save_evaluation_report
from lab03.retriever import load_runtime_retriever
def load_records(records_path) -> list[MedicalRecord]:
records: list[MedicalRecord] = []
with open(records_path, "r", encoding="utf-8") as handle:
for line in handle:
payload = json.loads(line)
records.append(MedicalRecord(**payload))
return records
def main() -> None:
config = BuildConfig()
config.ensure_dirs()
retriever = load_runtime_retriever(config)
records = load_records(config.artifacts_dir / "records.jsonl")
report = evaluate_retriever(retriever, records, limit=config.eval_limit)
save_evaluation_report(report, config.evaluation_dir / "retrieval_metrics.json")
print(report)
if __name__ == "__main__":
main()
|