Spaces:
Running
Running
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +66 -38
src/streamlit_app.py
CHANGED
|
@@ -1,40 +1,68 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
import streamlit as st
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Streamlit app to display the NPU Arabic leaderboard."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import json
|
| 6 |
+
from datetime import datetime
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
from typing import List, Sequence
|
| 9 |
+
|
| 10 |
import streamlit as st
|
| 11 |
|
| 12 |
+
_DATA_PATH = Path("leaderboard.json")
|
| 13 |
+
_COLUMNS: Sequence[str] = (
|
| 14 |
+
"model_name",
|
| 15 |
+
"avg_tps",
|
| 16 |
+
"iwslt2017-en-ar_sacrebleu",
|
| 17 |
+
"mlqa_ar_ar_f1",
|
| 18 |
+
"xquad_ar_f1",
|
| 19 |
+
"timestamp",
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def _load_rows() -> List[dict]:
|
| 24 |
+
if not _DATA_PATH.exists():
|
| 25 |
+
return []
|
| 26 |
+
try:
|
| 27 |
+
raw = json.loads(_DATA_PATH.read_text(encoding="utf-8"))
|
| 28 |
+
except json.JSONDecodeError:
|
| 29 |
+
return []
|
| 30 |
+
|
| 31 |
+
if isinstance(raw, dict):
|
| 32 |
+
data = [raw]
|
| 33 |
+
elif isinstance(raw, list):
|
| 34 |
+
data = [item for item in raw if isinstance(item, dict)]
|
| 35 |
+
else:
|
| 36 |
+
data = []
|
| 37 |
+
|
| 38 |
+
# Filter to desired columns and sort newest-first.
|
| 39 |
+
filtered: List[dict] = []
|
| 40 |
+
for row in data:
|
| 41 |
+
compact = {key: row.get(key) for key in _COLUMNS}
|
| 42 |
+
filtered.append(compact)
|
| 43 |
+
|
| 44 |
+
def _sort_key(item: dict) -> tuple:
|
| 45 |
+
stamp = item.get("timestamp")
|
| 46 |
+
try:
|
| 47 |
+
return (datetime.fromisoformat(str(stamp)),)
|
| 48 |
+
except Exception:
|
| 49 |
+
return (datetime.min,)
|
| 50 |
+
|
| 51 |
+
filtered.sort(key=_sort_key, reverse=True)
|
| 52 |
+
return filtered
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
st.set_page_config(page_title="Intel NPU Arabic Leaderboard", layout="wide")
|
| 56 |
+
st.title("Intel® NPU Arabic Leaderboard")
|
| 57 |
+
|
| 58 |
+
rows = _load_rows()
|
| 59 |
+
if not rows:
|
| 60 |
+
st.info("No evaluations uploaded yet. Trigger a run to populate the leaderboard.")
|
| 61 |
+
else:
|
| 62 |
+
st.write(
|
| 63 |
+
"Latest evaluation per model. Add new results by emailing the evaluation endpoint "
|
| 64 |
+
"or running the CLI with the Hugging Face publishing flags."
|
| 65 |
+
)
|
| 66 |
+
st.dataframe(rows, column_config={col: st.column_config.Column(col) for col in _COLUMNS})
|
| 67 |
+
|
| 68 |
+
st.caption("Data auto-synced from leaderboard.json produced by the evaluation pipeline.")
|