Update app.py
Browse files
app.py
CHANGED
|
@@ -424,41 +424,32 @@ def chat_rag(
|
|
| 424 |
return history, history
|
| 425 |
|
| 426 |
|
|
|
|
| 427 |
with gr.Blocks() as demo:
|
| 428 |
gr.Markdown("# QLoRA Fine-tuning & RAG-based Chat Demo using Custom R1 Model")
|
| 429 |
gr.Markdown("---")
|
| 430 |
|
| 431 |
-
|
| 432 |
[
|
| 433 |
gr.Interface(
|
| 434 |
fn=finetune_small_subset,
|
| 435 |
inputs=None,
|
| 436 |
outputs=gr.Textbox(label="Fine-tuning Status", interactive=False),
|
| 437 |
title="⚙️ Fine-tuning (Optional)",
|
| 438 |
-
description=""
|
| 439 |
-
### Optional Fine-tuning
|
| 440 |
-
This section allows you to fine-tune the custom R1 model on a small subset of the ServiceNow dataset.
|
| 441 |
-
This step is **optional** but can potentially improve the model's performance on ServiceNow-related tasks.
|
| 442 |
-
|
| 443 |
-
**Note:** This process may take up to 5 minutes. Click the button below to start fine-tuning.
|
| 444 |
-
"""
|
| 445 |
),
|
| 446 |
gr.Interface(
|
| 447 |
fn=predict,
|
| 448 |
inputs=[
|
| 449 |
gr.Textbox(lines=3, label="Input Prompt", placeholder="Enter your prompt here..."),
|
| 450 |
-
gr.Slider(0.0, 1.5, step=0.1, value=0.7, label="Temperature (Creativity)"
|
| 451 |
-
gr.Slider(0.0, 1.0, step=0.05, value=0.9, label="Top-p (Sampling Nucleus)"
|
| 452 |
-
gr.Slider(1, 2500, value=50, step=10, label="Min New Tokens"
|
| 453 |
-
gr.Slider(1, 2500, value=200, step=50, label="Max New Tokens"
|
| 454 |
],
|
| 455 |
outputs=gr.Textbox(label="Custom R1 Output", lines=8, interactive=False),
|
| 456 |
title="✍️ Direct Generation",
|
| 457 |
-
description=""
|
| 458 |
-
### Direct Text Generation
|
| 459 |
-
Enter a prompt to generate text directly using the custom R1 model.
|
| 460 |
-
This is standard text generation without retrieval augmentation.
|
| 461 |
-
"""
|
| 462 |
),
|
| 463 |
gr.Interface(
|
| 464 |
fn=compare_models,
|
|
@@ -474,22 +465,14 @@ with gr.Blocks() as demo:
|
|
| 474 |
gr.Textbox(label="Official R1 Output", lines=6, interactive=False)
|
| 475 |
],
|
| 476 |
title="🆚 Model Comparison",
|
| 477 |
-
description=""
|
| 478 |
-
### Model Output Comparison
|
| 479 |
-
Enter a prompt to compare the text generation of your fine-tuned custom R1 model with the official DeepSeek-R1-Distill-Llama-8B model.
|
| 480 |
-
This allows you to see the differences in output between the two models.
|
| 481 |
-
"""
|
| 482 |
),
|
| 483 |
gr.ChatInterface(
|
| 484 |
fn=chat_rag,
|
| 485 |
chatbot=gr.Chatbot(label="RAG Chatbot"),
|
| 486 |
textbox=gr.Textbox(placeholder="Ask a question to the RAG Chatbot...", lines=2, show_label=False),
|
| 487 |
title="💬 RAG Chat",
|
| 488 |
-
description=""
|
| 489 |
-
### RAG-Enhanced Chat with Custom R1
|
| 490 |
-
Chat with the custom R1 model, enhanced with retrieval-augmented generation (RAG).
|
| 491 |
-
The model retrieves relevant information to provide more informed and context-aware responses.
|
| 492 |
-
"""
|
| 493 |
)
|
| 494 |
]
|
| 495 |
)
|
|
|
|
| 424 |
return history, history
|
| 425 |
|
| 426 |
|
| 427 |
+
# Build the Gradio interface with tabs.
|
| 428 |
with gr.Blocks() as demo:
|
| 429 |
gr.Markdown("# QLoRA Fine-tuning & RAG-based Chat Demo using Custom R1 Model")
|
| 430 |
gr.Markdown("---")
|
| 431 |
|
| 432 |
+
gr.TabbedInterface(
|
| 433 |
[
|
| 434 |
gr.Interface(
|
| 435 |
fn=finetune_small_subset,
|
| 436 |
inputs=None,
|
| 437 |
outputs=gr.Textbox(label="Fine-tuning Status", interactive=False),
|
| 438 |
title="⚙️ Fine-tuning (Optional)",
|
| 439 |
+
description="This section allows you to fine-tune the custom R1 model on a small subset of the ServiceNow dataset. This step is optional but can potentially improve the model's performance on ServiceNow-related tasks. **Note:** This process may take up to 5 minutes."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 440 |
),
|
| 441 |
gr.Interface(
|
| 442 |
fn=predict,
|
| 443 |
inputs=[
|
| 444 |
gr.Textbox(lines=3, label="Input Prompt", placeholder="Enter your prompt here..."),
|
| 445 |
+
gr.Slider(0.0, 1.5, step=0.1, value=0.7, label="Temperature (Creativity)"),
|
| 446 |
+
gr.Slider(0.0, 1.0, step=0.05, value=0.9, label="Top-p (Sampling Nucleus)"),
|
| 447 |
+
gr.Slider(1, 2500, value=50, step=10, label="Min New Tokens"),
|
| 448 |
+
gr.Slider(1, 2500, value=200, step=50, label="Max New Tokens")
|
| 449 |
],
|
| 450 |
outputs=gr.Textbox(label="Custom R1 Output", lines=8, interactive=False),
|
| 451 |
title="✍️ Direct Generation",
|
| 452 |
+
description="Enter a prompt to generate text directly using the custom R1 model. This is standard text generation without retrieval augmentation."
|
|
|
|
|
|
|
|
|
|
|
|
|
| 453 |
),
|
| 454 |
gr.Interface(
|
| 455 |
fn=compare_models,
|
|
|
|
| 465 |
gr.Textbox(label="Official R1 Output", lines=6, interactive=False)
|
| 466 |
],
|
| 467 |
title="🆚 Model Comparison",
|
| 468 |
+
description="Enter a prompt to compare the text generation of your fine-tuned custom R1 model with the official DeepSeek-R1-Distill-Llama-8B model."
|
|
|
|
|
|
|
|
|
|
|
|
|
| 469 |
),
|
| 470 |
gr.ChatInterface(
|
| 471 |
fn=chat_rag,
|
| 472 |
chatbot=gr.Chatbot(label="RAG Chatbot"),
|
| 473 |
textbox=gr.Textbox(placeholder="Ask a question to the RAG Chatbot...", lines=2, show_label=False),
|
| 474 |
title="💬 RAG Chat",
|
| 475 |
+
description="Chat with the custom R1 model, enhanced with retrieval-augmented memory. The model retrieves relevant info for informed responses."
|
|
|
|
|
|
|
|
|
|
|
|
|
| 476 |
)
|
| 477 |
]
|
| 478 |
)
|