wuhp commited on
Commit
42ada3a
·
verified ·
1 Parent(s): 63d877e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -12
app.py CHANGED
@@ -237,7 +237,7 @@ def compare_models(
237
  Args:
238
  prompt (str): The input prompt for text generation.
239
  temperature (float): Sampling temperature.
240
- top_p (float): Top-p sampling probability.
241
  min_new_tokens (int): Minimum number of new tokens to generate.
242
  max_new_tokens (int): Maximum number of new tokens to generate.
243
 
@@ -385,7 +385,7 @@ def chat_rag(
385
  user_input (str): The user's chat input.
386
  history (list[list[str]]): The chat history.
387
  temperature (float): Sampling temperature.
388
- top_p (float): Top-p sampling probability.
389
  min_new_tokens (int): Minimum number of new tokens to generate.
390
  max_new_tokens (int): Maximum number of new tokens to generate.
391
 
@@ -429,27 +429,37 @@ 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,16 +475,24 @@ with gr.Blocks() as demo:
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
- )
479
 
480
  demo.launch()
 
237
  Args:
238
  prompt (str): The input prompt for text generation.
239
  temperature (float): Sampling temperature.
240
+ top_p (float): Sampling top-p.
241
  min_new_tokens (int): Minimum number of new tokens to generate.
242
  max_new_tokens (int): Maximum number of new tokens to generate.
243
 
 
385
  user_input (str): The user's chat input.
386
  history (list[list[str]]): The chat history.
387
  temperature (float): Sampling temperature.
388
+ top_p (float): Sampling top-p.
389
  min_new_tokens (int): Minimum number of new tokens to generate.
390
  max_new_tokens (int): Maximum number of new tokens to generate.
391
 
 
429
  gr.Markdown("# QLoRA Fine-tuning & RAG-based Chat Demo using Custom R1 Model")
430
  gr.Markdown("---")
431
 
432
+ with 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="""
440
+ ### Optional Fine-tuning
441
+ This section allows you to fine-tune the custom R1 model on a small subset of the ServiceNow dataset.
442
+ This step is **optional** but can potentially improve the model's performance on ServiceNow-related tasks.
443
+
444
+ **Note:** This process may take up to 5 minutes. Click the button below to start fine-tuning.
445
+ """
446
  ),
447
  gr.Interface(
448
  fn=predict,
449
  inputs=[
450
  gr.Textbox(lines=3, label="Input Prompt", placeholder="Enter your prompt here..."),
451
+ gr.Slider(0.0, 1.5, step=0.1, value=0.7, label="Temperature (Creativity)", info="Adjust the randomness of the output. Higher values mean more creative but potentially less coherent text."),
452
+ gr.Slider(0.0, 1.0, step=0.05, value=0.9, label="Top-p (Sampling Nucleus)", info="Controls the sampling pool. Lower values make the output more focused."),
453
+ gr.Slider(1, 2500, value=50, step=10, label="Min New Tokens", info="Minimum number of tokens to generate."),
454
+ gr.Slider(1, 2500, value=200, step=50, label="Max New Tokens", info="Maximum number of tokens to generate.")
455
  ],
456
  outputs=gr.Textbox(label="Custom R1 Output", lines=8, interactive=False),
457
  title="✍️ Direct Generation",
458
+ description="""
459
+ ### Direct Text Generation
460
+ Enter a prompt to generate text directly using the custom R1 model.
461
+ This is standard text generation without retrieval augmentation.
462
+ """
463
  ),
464
  gr.Interface(
465
  fn=compare_models,
 
475
  gr.Textbox(label="Official R1 Output", lines=6, interactive=False)
476
  ],
477
  title="🆚 Model Comparison",
478
+ description="""
479
+ ### Model Output Comparison
480
+ Enter a prompt to compare the text generation of your fine-tuned custom R1 model with the official DeepSeek-R1-Distill-Llama-8B model.
481
+ This allows you to see the differences in output between the two models.
482
+ """
483
  ),
484
  gr.ChatInterface(
485
  fn=chat_rag,
486
  chatbot=gr.Chatbot(label="RAG Chatbot"),
487
  textbox=gr.Textbox(placeholder="Ask a question to the RAG Chatbot...", lines=2, show_label=False),
488
  title="💬 RAG Chat",
489
+ description="""
490
+ ### RAG-Enhanced Chat with Custom R1
491
+ Chat with the custom R1 model, enhanced with retrieval-augmented generation (RAG).
492
+ The model retrieves relevant information to provide more informed and context-aware responses.
493
+ """
494
  )
495
  ]
496
+ ).render() # Added .render() here for potential future theme application
497
 
498
  demo.launch()