Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -19,6 +19,14 @@ PID_FILE = "./training.pid"
|
|
| 19 |
RESULTS_FILE = f"{PLOTS_DIR}/results.json"
|
| 20 |
TASK_ID_FILE = "./.task_id"
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# ---------------------------------------------------------------------------
|
| 23 |
# Trainer hub config — same across all 3 trainer Spaces, the active task
|
| 24 |
# is selected by the contents of `.task_id` at the Space root.
|
|
@@ -234,6 +242,46 @@ st.markdown("---")
|
|
| 234 |
# ---------------------------------------------------------------------------
|
| 235 |
|
| 236 |
active_cfg = TASKS[LOCAL_TASK]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
st.subheader(f"▶ {active_cfg['title']} · run training here")
|
| 238 |
st.markdown(
|
| 239 |
f"Trains via SFT → GRPO on the live `{LOCAL_TASK}_review` task of the "
|
|
|
|
| 19 |
RESULTS_FILE = f"{PLOTS_DIR}/results.json"
|
| 20 |
TASK_ID_FILE = "./.task_id"
|
| 21 |
|
| 22 |
+
# Pre-staged artifacts from a previous successful run — judges see these
|
| 23 |
+
# without having to actually click "Run Training". Purely additive: if the
|
| 24 |
+
# files don't exist, nothing renders.
|
| 25 |
+
SAMPLE_LOG_FILE = "./sample_run.log"
|
| 26 |
+
SAMPLE_BEFORE_AFTER_PNG = "./sample_before_after.png"
|
| 27 |
+
SAMPLE_REWARD_PNG = "./sample_reward_curve.png"
|
| 28 |
+
SAMPLE_RESULTS_JSON = "./sample_results.json"
|
| 29 |
+
|
| 30 |
# ---------------------------------------------------------------------------
|
| 31 |
# Trainer hub config — same across all 3 trainer Spaces, the active task
|
| 32 |
# is selected by the contents of `.task_id` at the Space root.
|
|
|
|
| 242 |
# ---------------------------------------------------------------------------
|
| 243 |
|
| 244 |
active_cfg = TASKS[LOCAL_TASK]
|
| 245 |
+
|
| 246 |
+
# ---------------------------------------------------------------------------
|
| 247 |
+
# Pre-staged sample-run artifacts (additive, only show if files exist).
|
| 248 |
+
# Lets judges see real output without having to click Run.
|
| 249 |
+
# ---------------------------------------------------------------------------
|
| 250 |
+
have_sample = (
|
| 251 |
+
os.path.exists(SAMPLE_LOG_FILE)
|
| 252 |
+
or os.path.exists(SAMPLE_BEFORE_AFTER_PNG)
|
| 253 |
+
or os.path.exists(SAMPLE_RESULTS_JSON)
|
| 254 |
+
)
|
| 255 |
+
if have_sample:
|
| 256 |
+
st.subheader(f"📊 {active_cfg['title']} · sample run (already trained)")
|
| 257 |
+
st.markdown(
|
| 258 |
+
f"Below is the recorded output of a successful **{LOCAL_TASK}** "
|
| 259 |
+
f"training run on this Space — the same run that produced the "
|
| 260 |
+
f"`{active_cfg['delta']}` headline number. You can read the log + "
|
| 261 |
+
f"plots without having to launch a new run."
|
| 262 |
+
)
|
| 263 |
+
if os.path.exists(SAMPLE_RESULTS_JSON):
|
| 264 |
+
try:
|
| 265 |
+
r = json.load(open(SAMPLE_RESULTS_JSON))
|
| 266 |
+
c1, c2, c3 = st.columns(3)
|
| 267 |
+
c1.metric("Baseline mean", f"{r.get('baseline_mean', 0):.3f}")
|
| 268 |
+
c2.metric("Trained mean", f"{r.get('trained_mean', 0):.3f}")
|
| 269 |
+
c3.metric("Improvement", f"{r.get('improvement', 0):+.3f}")
|
| 270 |
+
except Exception:
|
| 271 |
+
pass
|
| 272 |
+
pcols = st.columns(2)
|
| 273 |
+
if os.path.exists(SAMPLE_BEFORE_AFTER_PNG):
|
| 274 |
+
pcols[0].image(SAMPLE_BEFORE_AFTER_PNG, caption="Before vs After SFT (sample run)")
|
| 275 |
+
if os.path.exists(SAMPLE_REWARD_PNG):
|
| 276 |
+
pcols[1].image(SAMPLE_REWARD_PNG, caption="Training Loss (sample run)")
|
| 277 |
+
if os.path.exists(SAMPLE_LOG_FILE):
|
| 278 |
+
with st.expander("📜 Sample training log (full output)"):
|
| 279 |
+
try:
|
| 280 |
+
st.text(open(SAMPLE_LOG_FILE).read())
|
| 281 |
+
except Exception as e:
|
| 282 |
+
st.error(f"Could not read sample log: {e}")
|
| 283 |
+
st.markdown("---")
|
| 284 |
+
|
| 285 |
st.subheader(f"▶ {active_cfg['title']} · run training here")
|
| 286 |
st.markdown(
|
| 287 |
f"Trains via SFT → GRPO on the live `{LOCAL_TASK}_review` task of the "
|