Spaces:
Running
Running
Radianis commited on
Commit ·
b72be6b
1
Parent(s): ac62897
Clarify HF runner names and descriptions
Browse files
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title: LBW Guard
|
| 3 |
emoji: 🚀
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
|
@@ -23,17 +23,19 @@ Copyright (c) Qluon Inc. All rights reserved.
|
|
| 23 |
|
| 24 |
Provided for Learn-By-Wire Guard evaluation and customer testing under the applicable Qluon license terms.
|
| 25 |
|
| 26 |
-
# LBW Guard
|
| 27 |
|
| 28 |
-
This private Space
|
| 29 |
|
| 30 |
-
- `LBW_Guard_Easy_Test_COLAB.ipynb`
|
| 31 |
-
- `LBW_Guard_Ablation_Test_COLAB.ipynb`
|
|
|
|
|
|
|
| 32 |
|
| 33 |
It installs `lbw-guard` from PyPI and does not vendor the local `lbw/` source folder.
|
| 34 |
|
| 35 |
Paper: https://arxiv.org/abs/2605.19008
|
| 36 |
|
| 37 |
-
Use GPU hardware for meaningful runtime. CPU can load the app, but training is intentionally capped to tiny smoke settings.
|
| 38 |
|
| 39 |
The app writes run artifacts to the Space working directory. Add persistent storage if you need outputs to survive Space restarts.
|
|
|
|
| 1 |
---
|
| 2 |
+
title: LBW Guard HF Evaluation Runner
|
| 3 |
emoji: 🚀
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
|
|
|
| 23 |
|
| 24 |
Provided for Learn-By-Wire Guard evaluation and customer testing under the applicable Qluon license terms.
|
| 25 |
|
| 26 |
+
# LBW Guard HF Evaluation Runner
|
| 27 |
|
| 28 |
+
This private Hugging Face Space provides two GPU-ready LBW Guard evaluation runners:
|
| 29 |
|
| 30 |
+
- **Quick Comparison**: a short AdamW vs `lbw_guard` WikiText LoRA run based on `LBW_Guard_Easy_Test_COLAB.ipynb`.
|
| 31 |
+
- **Ablation Matrix**: a scenario sweep for optimizer, learning rate, schedule, steps, data size, and LoRA rank based on `LBW_Guard_Ablation_Test_COLAB.ipynb`.
|
| 32 |
+
|
| 33 |
+
Both runners produce JSON and CSV artifacts in the Space working directory. The quick runner writes final metrics plus LBW-vs-AdamW gains. The ablation runner writes per-scenario metrics plus LBW-vs-AdamW gains for each scenario.
|
| 34 |
|
| 35 |
It installs `lbw-guard` from PyPI and does not vendor the local `lbw/` source folder.
|
| 36 |
|
| 37 |
Paper: https://arxiv.org/abs/2605.19008
|
| 38 |
|
| 39 |
+
Use GPU hardware for meaningful runtime. CPU can load the app, but training is intentionally capped to tiny smoke settings so users do not accidentally start long CPU jobs.
|
| 40 |
|
| 41 |
The app writes run artifacts to the Space working directory. Add persistent storage if you need outputs to survive Space restarts.
|
app.py
CHANGED
|
@@ -521,7 +521,7 @@ def run_easy_test(
|
|
| 521 |
):
|
| 522 |
yield (
|
| 523 |
"This Space is currently on `cpu-basic`. CPU mode is capped to 1 step, 20k train chars, "
|
| 524 |
-
"8k eval chars, and sampled validation. Switch the Space hardware to GPU for the
|
| 525 |
None,
|
| 526 |
None,
|
| 527 |
None,
|
|
@@ -612,7 +612,8 @@ def run_easy_test(
|
|
| 612 |
|
| 613 |
gains = _gain_rows(rows)
|
| 614 |
payload = {
|
| 615 |
-
"source": "
|
|
|
|
| 616 |
"config": {
|
| 617 |
"model_name": resolved_model,
|
| 618 |
"device": device_name,
|
|
@@ -644,9 +645,9 @@ def run_easy_test(
|
|
| 644 |
"gains": gains,
|
| 645 |
"logs": logs,
|
| 646 |
}
|
| 647 |
-
json_path = run_dir / "
|
| 648 |
-
csv_path = run_dir / "
|
| 649 |
-
gains_path = run_dir / "
|
| 650 |
json_path.write_text(json.dumps(payload, indent=2), encoding="utf-8")
|
| 651 |
_write_csv(csv_path, rows)
|
| 652 |
_write_csv(gains_path, gains)
|
|
@@ -1185,7 +1186,8 @@ def run_ablation_test(
|
|
| 1185 |
|
| 1186 |
gains = _build_ablation_gain_rows(rows)
|
| 1187 |
payload = {
|
| 1188 |
-
"source": "
|
|
|
|
| 1189 |
"model_name": resolved_model,
|
| 1190 |
"device": device_name,
|
| 1191 |
"optimizers": optimizers,
|
|
@@ -1196,9 +1198,9 @@ def run_ablation_test(
|
|
| 1196 |
"gains": gains,
|
| 1197 |
"logs": logs,
|
| 1198 |
}
|
| 1199 |
-
json_path = run_dir / "
|
| 1200 |
-
metrics_path = run_dir / "
|
| 1201 |
-
gains_path = run_dir / "
|
| 1202 |
json_path.write_text(json.dumps(payload, indent=2), encoding="utf-8")
|
| 1203 |
_write_csv(metrics_path, rows)
|
| 1204 |
_write_csv(gains_path, gains)
|
|
@@ -1218,21 +1220,25 @@ def run_ablation_test(
|
|
| 1218 |
|
| 1219 |
|
| 1220 |
INTRO = """
|
| 1221 |
-
# LBW Guard
|
| 1222 |
|
| 1223 |
-
|
| 1224 |
|
| 1225 |
-
- `
|
| 1226 |
-
-
|
| 1227 |
|
| 1228 |
-
|
| 1229 |
"""
|
| 1230 |
|
| 1231 |
|
| 1232 |
-
with gr.Blocks(title="LBW Guard
|
| 1233 |
gr.Markdown(INTRO)
|
| 1234 |
with gr.Tabs():
|
| 1235 |
-
with gr.Tab("
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1236 |
with gr.Row():
|
| 1237 |
easy_model_name = gr.Textbox(value="TinyLlama/TinyLlama_v1.1", label="Model")
|
| 1238 |
easy_run_lbw_guard = gr.Checkbox(value=True, label="Run LBW Guard comparison")
|
|
@@ -1252,7 +1258,7 @@ with gr.Blocks(title="LBW Guard Colab Tests") as demo:
|
|
| 1252 |
easy_full_wikitext_train = gr.Checkbox(value=False, label="Full WikiText train")
|
| 1253 |
easy_full_wikitext_eval = gr.Checkbox(value=False, label="Full WikiText eval")
|
| 1254 |
easy_full_validation_ppl = gr.Checkbox(value=False, label="Full validation PPL")
|
| 1255 |
-
easy_run_button = gr.Button("Run
|
| 1256 |
easy_summary = gr.Markdown()
|
| 1257 |
easy_json_file = gr.File(label="Raw JSON")
|
| 1258 |
easy_results_file = gr.File(label="Results CSV")
|
|
@@ -1279,7 +1285,11 @@ with gr.Blocks(title="LBW Guard Colab Tests") as demo:
|
|
| 1279 |
outputs=[easy_summary, easy_json_file, easy_results_file, easy_gains_file],
|
| 1280 |
)
|
| 1281 |
|
| 1282 |
-
with gr.Tab("Ablation
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1283 |
with gr.Row():
|
| 1284 |
ablation_model_name = gr.Textbox(value="Qwen/Qwen2.5-0.5B", label="Model")
|
| 1285 |
ablation_run_lbw_guard = gr.Checkbox(value=True, label="Run LBW Guard comparison")
|
|
@@ -1311,7 +1321,7 @@ with gr.Blocks(title="LBW Guard Colab Tests") as demo:
|
|
| 1311 |
lr_sweep_text = gr.Textbox(value="1e-3, 5e-4", label="LR sweep")
|
| 1312 |
step_sweep_text = gr.Textbox(value="100, 200", label="Step sweep")
|
| 1313 |
lora_r_sweep_text = gr.Textbox(value="4, 8, 16", label="LoRA r sweep")
|
| 1314 |
-
ablation_run_button = gr.Button("Run Ablation
|
| 1315 |
ablation_summary = gr.Markdown()
|
| 1316 |
ablation_json_file = gr.File(label="Raw JSON")
|
| 1317 |
ablation_metrics_file = gr.File(label="Metrics CSV")
|
|
|
|
| 521 |
):
|
| 522 |
yield (
|
| 523 |
"This Space is currently on `cpu-basic`. CPU mode is capped to 1 step, 20k train chars, "
|
| 524 |
+
"8k eval chars, and sampled validation. Switch the Space hardware to GPU for the Quick Comparison defaults.",
|
| 525 |
None,
|
| 526 |
None,
|
| 527 |
None,
|
|
|
|
| 612 |
|
| 613 |
gains = _gain_rows(rows)
|
| 614 |
payload = {
|
| 615 |
+
"source": "HF Quick Comparison Runner",
|
| 616 |
+
"based_on_colab": "LBW_Guard_Easy_Test_COLAB.ipynb",
|
| 617 |
"config": {
|
| 618 |
"model_name": resolved_model,
|
| 619 |
"device": device_name,
|
|
|
|
| 645 |
"gains": gains,
|
| 646 |
"logs": logs,
|
| 647 |
}
|
| 648 |
+
json_path = run_dir / "lbw_guard_hf_quick_comparison_results.json"
|
| 649 |
+
csv_path = run_dir / "lbw_guard_hf_quick_comparison_results.csv"
|
| 650 |
+
gains_path = run_dir / "lbw_guard_hf_quick_comparison_gains.csv"
|
| 651 |
json_path.write_text(json.dumps(payload, indent=2), encoding="utf-8")
|
| 652 |
_write_csv(csv_path, rows)
|
| 653 |
_write_csv(gains_path, gains)
|
|
|
|
| 1186 |
|
| 1187 |
gains = _build_ablation_gain_rows(rows)
|
| 1188 |
payload = {
|
| 1189 |
+
"source": "HF Ablation Matrix Runner",
|
| 1190 |
+
"based_on_colab": "LBW_Guard_Ablation_Test_COLAB.ipynb",
|
| 1191 |
"model_name": resolved_model,
|
| 1192 |
"device": device_name,
|
| 1193 |
"optimizers": optimizers,
|
|
|
|
| 1198 |
"gains": gains,
|
| 1199 |
"logs": logs,
|
| 1200 |
}
|
| 1201 |
+
json_path = run_dir / "lbw_guard_hf_ablation_matrix_results.json"
|
| 1202 |
+
metrics_path = run_dir / "lbw_guard_hf_ablation_matrix_metrics.csv"
|
| 1203 |
+
gains_path = run_dir / "lbw_guard_hf_ablation_matrix_gains.csv"
|
| 1204 |
json_path.write_text(json.dumps(payload, indent=2), encoding="utf-8")
|
| 1205 |
_write_csv(metrics_path, rows)
|
| 1206 |
_write_csv(gains_path, gains)
|
|
|
|
| 1220 |
|
| 1221 |
|
| 1222 |
INTRO = """
|
| 1223 |
+
# LBW Guard HF Evaluation Runner
|
| 1224 |
|
| 1225 |
+
This private Space has two HF-specific runners based on the customer Colab notebooks:
|
| 1226 |
|
| 1227 |
+
- **Quick Comparison**: a short AdamW vs `lbw_guard` WikiText LoRA run.
|
| 1228 |
+
- **Ablation Matrix**: a selectable scenario sweep across optimizer, LR, schedule, steps, data, and LoRA rank.
|
| 1229 |
|
| 1230 |
+
Each run writes JSON and CSV artifacts. GPU hardware is recommended; CPU mode is only for tiny smoke checks.
|
| 1231 |
"""
|
| 1232 |
|
| 1233 |
|
| 1234 |
+
with gr.Blocks(title="LBW Guard HF Evaluation Runner") as demo:
|
| 1235 |
gr.Markdown(INTRO)
|
| 1236 |
with gr.Tabs():
|
| 1237 |
+
with gr.Tab("Quick Comparison"):
|
| 1238 |
+
gr.Markdown(
|
| 1239 |
+
"Runs the HF version of the Easy Test flow: one shared WikiText slice, then AdamW and optional "
|
| 1240 |
+
"`lbw_guard` LoRA training with final perplexity and gain CSV output."
|
| 1241 |
+
)
|
| 1242 |
with gr.Row():
|
| 1243 |
easy_model_name = gr.Textbox(value="TinyLlama/TinyLlama_v1.1", label="Model")
|
| 1244 |
easy_run_lbw_guard = gr.Checkbox(value=True, label="Run LBW Guard comparison")
|
|
|
|
| 1258 |
easy_full_wikitext_train = gr.Checkbox(value=False, label="Full WikiText train")
|
| 1259 |
easy_full_wikitext_eval = gr.Checkbox(value=False, label="Full WikiText eval")
|
| 1260 |
easy_full_validation_ppl = gr.Checkbox(value=False, label="Full validation PPL")
|
| 1261 |
+
easy_run_button = gr.Button("Run Quick Comparison", variant="primary")
|
| 1262 |
easy_summary = gr.Markdown()
|
| 1263 |
easy_json_file = gr.File(label="Raw JSON")
|
| 1264 |
easy_results_file = gr.File(label="Results CSV")
|
|
|
|
| 1285 |
outputs=[easy_summary, easy_json_file, easy_results_file, easy_gains_file],
|
| 1286 |
)
|
| 1287 |
|
| 1288 |
+
with gr.Tab("Ablation Matrix"):
|
| 1289 |
+
gr.Markdown(
|
| 1290 |
+
"Runs the HF version of the ablation flow: build selected scenarios, run AdamW and optional "
|
| 1291 |
+
"`lbw_guard` for each scenario, then export metrics and LBW-vs-AdamW gains."
|
| 1292 |
+
)
|
| 1293 |
with gr.Row():
|
| 1294 |
ablation_model_name = gr.Textbox(value="Qwen/Qwen2.5-0.5B", label="Model")
|
| 1295 |
ablation_run_lbw_guard = gr.Checkbox(value=True, label="Run LBW Guard comparison")
|
|
|
|
| 1321 |
lr_sweep_text = gr.Textbox(value="1e-3, 5e-4", label="LR sweep")
|
| 1322 |
step_sweep_text = gr.Textbox(value="100, 200", label="Step sweep")
|
| 1323 |
lora_r_sweep_text = gr.Textbox(value="4, 8, 16", label="LoRA r sweep")
|
| 1324 |
+
ablation_run_button = gr.Button("Run Ablation Matrix", variant="primary")
|
| 1325 |
ablation_summary = gr.Markdown()
|
| 1326 |
ablation_json_file = gr.File(label="Raw JSON")
|
| 1327 |
ablation_metrics_file = gr.File(label="Metrics CSV")
|