Proposal: torchmetrics-openeval-adapter (text metrics ↔ EvalPort result format) #3476
adhabnr-ux
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
EvalPort (https://github.com/adhabnr-ux/evalport) is an open interchange spec + SDK for portable LLM/eval datasets and results — a JSON schema for test suites and result sets, validated through
openeval.validate.validate_suite()/validate_result_set()in theevalport-sdkpackage on PyPI. The idea is that eval data (test cases, graders, scored results) can move between frameworks instead of being locked into one tool's format.I think torchmetrics' text metrics are a genuinely clean fit, and wanted to float the idea here before building anything, per the "submit an issue, discuss scope" guidance in CONTRIBUTING.md — though to be clear, this wouldn't touch torchmetrics' own code at all. It'd be a standalone adapter package living in the EvalPort repo, zero footprint on this repo.
Why it fits
Metric(src/torchmetrics/metric.py) is torchmetrics' base class, and every text metric undersrc/torchmetrics/text/—BLEUScore,ROUGEScore,CHRFScore,CharErrorRate,Perplexity,BERTScore, etc. — follows the sameupdate(preds, target)/compute() -> Tensorshape. That single-tensor-per-call return is exactly what maps onto EvalPort'sGraderResult.score(a float in[0, 1]), and a handful of the most common text metrics — BLEU, ROUGE variants, chrF/100 — already report natively in that range, so no lossy rescaling is needed for those.Before / after sketch, using
BLEUScore's own real usage (frombleu.py's docstring):With the proposed adapter:
One honesty note I'd document rather than paper over: torchmetrics'
update/computeaccumulates n-gram counts across calls (seeBLEUScore'snumerator/denominatorstate), so callingcompute()on a single example gives a real BLEU number, but it isn't identical in meaning to a true corpus-level BLEU computed over the whole batch — the same caveat that applies to any sentence-level BLEU. The adapter would report both: the real per-example score forGraderResult.score, and the real whole-batchcompute()result preserved inmetadata, so nothing is fabricated or interpolated. Metrics without a natural[0, 1]range (Perplexity,WER,CER) would map to EvalPort'scustomgrader type with the raw value carried in metadata rather than being force-clamped into a misleading score.If this sounds useful, I'd build
torchmetrics-openeval-adapter(mirroring the existinghuggingface-evaluate-openeval-adapterin structure —pyproject.tomldepending onevalport-sdkplus a self-referencing pinnedtorchmetricsextra,to_openeval()/from_openeval(), tests, README) and submit it as a PR to the EvalPort repo, not to torchmetrics. No action needed on your end beyond a thumbs-up (or a correction if I've got theMetricshape wrong somewhere).— Sahi, independent contributor, maintaining EvalPort
All reactions