feat: consolida backend RAG e documentação
This commit is contained in:
parent
7c18727f62
commit
d72572ee6f
28 changed files with 2193 additions and 275 deletions
33
scripts/rag_eval.py
Normal file
33
scripts/rag_eval.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Score a redacted RAG run artifact against a versioned dataset."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "rag-api"))
|
||||
from evaluation import evaluate # noqa: E402
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--dataset", required=True, type=Path)
|
||||
parser.add_argument("--results", required=True, type=Path)
|
||||
parser.add_argument("--k", type=int, default=5)
|
||||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
dataset = json.loads(args.dataset.read_text(encoding="utf-8"))
|
||||
results = json.loads(args.results.read_text(encoding="utf-8"))
|
||||
report = evaluate(dataset, results, k=args.k)
|
||||
except (OSError, json.JSONDecodeError, ValueError) as exc:
|
||||
parser.error(str(exc))
|
||||
print(json.dumps(report, ensure_ascii=False, indent=2))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue