Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -575,32 +575,36 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 575 |
download_csv_file = gr.File(label="CSV File")
|
| 576 |
download_csv_btn.click(fn=get_csv_file, outputs=download_csv_file)
|
| 577 |
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
**GRPO Fine-tuning** (run offline or in a training Space):
|
| 581 |
-
- Click **Export GRPO Preferences** to produce `data/grpo_prefs.jsonl` of (prompt, chosen, rejected).
|
| 582 |
-
- Click **Write Trainer Script** to create `train/grpo_train.py`.
|
| 583 |
-
- Then run:
|
| 584 |
-
```bash
|
| 585 |
-
pip install trl accelerate peft transformers datasets
|
| 586 |
-
python train/grpo_train.py
|
| 587 |
-
|
| 588 |
-
Set BASE_MODEL/OUTPUT_DIR env vars if you like.
|
| 589 |
-
""")
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
grpo_btn.
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
gr.
|
| 597 |
-
gr.Markdown(
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 602 |
download_grpo_btn.click(fn=get_grpo_file, outputs=[download_grpo_file])
|
| 603 |
|
| 604 |
-
|
| 605 |
if __name__ == "__main__":
|
| 606 |
demo.queue(max_size=50).launch(share=True)
|
|
|
|
| 575 |
download_csv_file = gr.File(label="CSV File")
|
| 576 |
download_csv_btn.click(fn=get_csv_file, outputs=download_csv_file)
|
| 577 |
|
| 578 |
+
with gr.Tab("🧪 GRPO / Dataset"):
|
| 579 |
+
gr.Markdown("""
|
| 580 |
+
**GRPO Fine-tuning** (run offline or in a training Space):
|
| 581 |
+
- Click **Export GRPO Preferences** to produce `data/grpo_prefs.jsonl` of (prompt, chosen, rejected).
|
| 582 |
+
- Click **Write Trainer Script** to create `train/grpo_train.py`.
|
| 583 |
+
- Then run:
|
| 584 |
+
```bash
|
| 585 |
+
pip install trl accelerate peft transformers datasets
|
| 586 |
+
python train/grpo_train.py
|
| 587 |
+
|
| 588 |
+
Set BASE_MODEL/OUTPUT_DIR env vars if you like.
|
| 589 |
+
```""")
|
| 590 |
+
|
| 591 |
+
# These lines need to be indented to be inside the Tab's context
|
| 592 |
+
grpo_btn = gr.Button("📦 Export GRPO Preferences")
|
| 593 |
+
grpo_status = gr.Markdown()
|
| 594 |
+
grpo_btn.click(fn=export_grpo_preferences, outputs=[grpo_status])
|
| 595 |
+
|
| 596 |
+
write_script_btn = gr.Button("📝 Write grpo_train.py")
|
| 597 |
+
write_script_status = gr.Markdown()
|
| 598 |
+
write_script_btn.click(fn=lambda: f"✅ Trainer script written to {_write_trainer_script()}", outputs=[write_script_status])
|
| 599 |
+
|
| 600 |
+
gr.Markdown("---")
|
| 601 |
+
gr.Markdown("### ⬇️ Download GRPO Dataset")
|
| 602 |
+
|
| 603 |
+
with gr.Row():
|
| 604 |
+
download_grpo_btn = gr.Button("⬇️ Download GRPO Data (grpo_prefs.jsonl)")
|
| 605 |
+
download_grpo_file = gr.File(label="GRPO Dataset File")
|
| 606 |
download_grpo_btn.click(fn=get_grpo_file, outputs=[download_grpo_file])
|
| 607 |
|
| 608 |
+
# The `if __name__ == "__main__":` block should be at the top level
|
| 609 |
if __name__ == "__main__":
|
| 610 |
demo.queue(max_size=50).launch(share=True)
|