Sergidev commited on
Commit
4a07f1a
·
verified ·
1 Parent(s): e976f4f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import subprocess
3
+ import os
4
+
5
+ def run_self_lengthen(model_path, instruct_count, max_iter):
6
+ # Set environment variables
7
+ os.environ["MODEL_PATH"] = model_path
8
+ os.environ["INSTRUCT_COUNT"] = str(instruct_count)
9
+ os.environ["MAX_ITER"] = str(max_iter)
10
+
11
+ # Run the self-lengthen process
12
+ try:
13
+ subprocess.run(["/app/start.sh"], check=True)
14
+ return "Training completed successfully! Check the results in the output directory."
15
+ except subprocess.CalledProcessError as e:
16
+ return f"Error during training: {str(e)}"
17
+
18
+ # Create Gradio interface
19
+ iface = gr.Interface(
20
+ fn=run_self_lengthen,
21
+ inputs=[
22
+ gr.Textbox(label="Model Path", value="models/base_model"),
23
+ gr.Number(label="Instruction Count", value=5000, minimum=100),
24
+ gr.Number(label="Max Iterations", value=3, minimum=1)
25
+ ],
26
+ outputs=gr.Textbox(label="Status"),
27
+ title="Self-Lengthen Training Interface",
28
+ description="Train language models to generate longer texts using the Self-Lengthen approach."
29
+ )
30
+
31
+ iface.launch(server_name="0.0.0.0", server_port=7860)