Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
from dotenv import load_dotenv
|
4 |
+
|
5 |
+
# Load environment variables
|
6 |
+
load_dotenv()
|
7 |
+
|
8 |
+
# Model details
|
9 |
+
MODEL_NAME = "unsloth/DeepSeek-R1-Distill-Qwen-14B-bnb-4bit"
|
10 |
+
SPACE_NAME = os.getenv("HF_SPACE_NAME", "qwen4bit")
|
11 |
+
|
12 |
+
def generate_response(prompt, max_new_tokens=256):
|
13 |
+
"""
|
14 |
+
This is a placeholder function that will be replaced with actual model inference
|
15 |
+
after fine-tuning is complete.
|
16 |
+
"""
|
17 |
+
# Currently returns a placeholder message
|
18 |
+
return f"""[Placeholder Response]
|
19 |
+
This is a demo of the {MODEL_NAME} model.
|
20 |
+
Once fine-tuning is complete, this will respond to:
|
21 |
+
"{prompt}"
|
22 |
+
|
23 |
+
This space will be updated with the fine-tuned model."""
|
24 |
+
|
25 |
+
# Create the Gradio interface
|
26 |
+
with gr.Blocks(title=f"Fine-tuned {MODEL_NAME}") as demo:
|
27 |
+
gr.Markdown(f"""
|
28 |
+
# Fine-tuned DeepSeek-R1-Distill-Qwen-14B Model
|
29 |
+
|
30 |
+
This space will host the fine-tuned version of `{MODEL_NAME}` once training is complete.
|
31 |
+
|
32 |
+
**Model Details**:
|
33 |
+
- Base model: `{MODEL_NAME}`
|
34 |
+
- Fine-tuned on: `phi4-cognitive-dataset`
|
35 |
+
- 4-bit quantized (already, not further quantized)
|
36 |
+
|
37 |
+
**Current Status**: Preparing for fine-tuning
|
38 |
+
""")
|
39 |
+
|
40 |
+
with gr.Row():
|
41 |
+
with gr.Column():
|
42 |
+
input_text = gr.Textbox(
|
43 |
+
label="Enter your prompt",
|
44 |
+
placeholder="Type your prompt here...",
|
45 |
+
lines=4
|
46 |
+
)
|
47 |
+
max_tokens = gr.Slider(
|
48 |
+
minimum=32,
|
49 |
+
maximum=1024,
|
50 |
+
value=256,
|
51 |
+
step=32,
|
52 |
+
label="Max new tokens"
|
53 |
+
)
|
54 |
+
submit_btn = gr.Button("Generate Response")
|
55 |
+
|
56 |
+
with gr.Column():
|
57 |
+
output_text = gr.Textbox(
|
58 |
+
label="Model Response",
|
59 |
+
lines=10
|
60 |
+
)
|
61 |
+
|
62 |
+
submit_btn.click(
|
63 |
+
fn=generate_response,
|
64 |
+
inputs=[input_text, max_tokens],
|
65 |
+
outputs=output_text
|
66 |
+
)
|
67 |
+
|
68 |
+
gr.Markdown("""
|
69 |
+
### Note
|
70 |
+
This is a placeholder application. The actual fine-tuned model will be deployed
|
71 |
+
to this space once training is complete.
|
72 |
+
""")
|
73 |
+
|
74 |
+
# Launch the app
|
75 |
+
if __name__ == "__main__":
|
76 |
+
demo.launch()
|