Emeritus-21 commited on
Commit
befd148
·
verified ·
1 Parent(s): 5a60fb2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -25
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
- 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
- grpo_btn = gr.Button("📦 Export GRPO Preferences")
591
- grpo_status = gr.Markdown()
592
- grpo_btn.click(fn=export_grpo_preferences, outputs=[grpo_status])
593
- write_script_btn = gr.Button("📝 Write grpo_train.py")
594
- write_script_status = gr.Markdown()
595
- write_script_btn.click(fn=lambda: f"✅ Trainer script written to {_write_trainer_script()}", outputs=[write_script_status])
596
- gr.Markdown("---")
597
- gr.Markdown("### ⬇️ Download GRPO Dataset")
598
-
599
- with gr.Row():
600
- download_grpo_btn = gr.Button("⬇️ Download GRPO Data (grpo_prefs.jsonl)")
601
- download_grpo_file = gr.File(label="GRPO Dataset File")
 
 
 
 
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)