Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,23 +3,30 @@ 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.
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
],
|
@@ -28,4 +35,5 @@ iface = gr.Interface(
|
|
28 |
description="Train language models to generate longer texts using the Self-Lengthen approach."
|
29 |
)
|
30 |
|
31 |
-
|
|
|
|
3 |
import os
|
4 |
|
5 |
def run_self_lengthen(model_path, instruct_count, max_iter):
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
try:
|
7 |
+
process = subprocess.Popen([
|
8 |
+
"bash",
|
9 |
+
"/app/qwen/run.sh",
|
10 |
+
f"--base_model={model_path}",
|
11 |
+
f"--instruct_count={instruct_count}",
|
12 |
+
f"--max_iter={max_iter}"
|
13 |
+
], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
14 |
+
|
15 |
+
stdout, stderr = process.communicate()
|
16 |
+
|
17 |
+
if process.returncode == 0:
|
18 |
+
subprocess.run(["python", "/app/qwen/collect_data.py"])
|
19 |
+
return "Training completed successfully!"
|
20 |
+
else:
|
21 |
+
return f"Error during training: {stderr.decode()}"
|
22 |
+
except Exception as e:
|
23 |
+
return f"Error: {str(e)}"
|
24 |
|
25 |
# Create Gradio interface
|
26 |
iface = gr.Interface(
|
27 |
fn=run_self_lengthen,
|
28 |
inputs=[
|
29 |
+
gr.Textbox(label="Model Path", value="/app/models/base_model"),
|
30 |
gr.Number(label="Instruction Count", value=5000, minimum=100),
|
31 |
gr.Number(label="Max Iterations", value=3, minimum=1)
|
32 |
],
|
|
|
35 |
description="Train language models to generate longer texts using the Self-Lengthen approach."
|
36 |
)
|
37 |
|
38 |
+
if __name__ == "__main__":
|
39 |
+
iface.launch(server_name="0.0.0.0", server_port=7860)
|