Spaces:
Running
Running
File size: 1,891 Bytes
8f895ab 2401bad 18e3c32 8f895ab |
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 |
"""Streamlit app to display the NPU Arabic leaderboard."""
from __future__ import annotations
import json
from datetime import datetime
from pathlib import Path
from typing import List, Sequence
import streamlit as st
_DATA_PATH = Path("../leaderboard.json")
_COLUMNS: Sequence[str] = (
"model_name",
"avg_tps",
"iwslt2017-en-ar_sacrebleu",
"mlqa_ar_ar_f1",
"xquad_ar_f1",
"timestamp",
)
def _load_rows() -> List[dict]:
if not _DATA_PATH.exists():
return []
try:
raw = json.loads(_DATA_PATH.read_text(encoding="utf-8"))
except json.JSONDecodeError:
return []
if isinstance(raw, dict):
data = [raw]
elif isinstance(raw, list):
data = [item for item in raw if isinstance(item, dict)]
else:
data = []
# Filter to desired columns and sort newest-first.
filtered: List[dict] = []
for row in data:
compact = {key: row.get(key) for key in _COLUMNS}
filtered.append(compact)
def _sort_key(item: dict) -> tuple:
stamp = item.get("timestamp")
try:
return (datetime.fromisoformat(str(stamp)),)
except Exception:
return (datetime.min,)
filtered.sort(key=_sort_key, reverse=True)
return filtered
st.set_page_config(page_title="Intel NPU Arabic Leaderboard", layout="wide")
st.title("Intel® NPU Arabic Leaderboard")
rows = _load_rows()
if not rows:
st.info("No evaluations uploaded yet. Trigger a run to populate the leaderboard.")
else:
st.write(
"Latest evaluation per model. Add new results by emailing the evaluation endpoint "
"or running the CLI with the Hugging Face publishing flags."
)
st.dataframe(rows, column_config={col: st.column_config.Column(col) for col in _COLUMNS})
st.caption("Data auto-synced from leaderboard.json produced by the evaluation pipeline.") |