zetavg commited on
Commit
e9c5abc
1 Parent(s): 35fba55
app.py CHANGED
@@ -42,7 +42,7 @@ def main(
42
  with gr.Blocks(title=get_page_title(), css=main_page_custom_css()) as demo:
43
  main_page()
44
 
45
- demo.queue().launch(server_name=server_name, share=share)
46
 
47
 
48
  if __name__ == "__main__":
 
42
  with gr.Blocks(title=get_page_title(), css=main_page_custom_css()) as demo:
43
  main_page()
44
 
45
+ demo.queue(concurrency_count=2).launch(server_name=server_name, share=share)
46
 
47
 
48
  if __name__ == "__main__":
llama_lora/lib/finetune.py CHANGED
@@ -214,10 +214,9 @@ def train(
214
  if torch.__version__ >= "2" and sys.platform != "win32":
215
  model = torch.compile(model)
216
 
217
- trainer.train(resume_from_checkpoint=resume_from_checkpoint)
218
 
219
  model.save_pretrained(output_dir)
 
220
 
221
- print(
222
- "\n If there's a warning about missing keys above, please disregard :)"
223
- )
 
214
  if torch.__version__ >= "2" and sys.platform != "win32":
215
  model = torch.compile(model)
216
 
217
+ result = trainer.train(resume_from_checkpoint=resume_from_checkpoint)
218
 
219
  model.save_pretrained(output_dir)
220
+ print(f"Model saved to {output_dir}.")
221
 
222
+ return result
 
 
llama_lora/ui/finetune_ui.py CHANGED
@@ -360,7 +360,7 @@ Train data (first 10):
360
 
361
  Global.should_stop_training = False
362
 
363
- return Global.train_fn(
364
  get_base_model(), # base_model
365
  get_tokenizer(), # tokenizer
366
  os.path.join(Global.data_dir, "lora_models",
@@ -529,19 +529,19 @@ def finetune_ui():
529
  with gr.Row():
530
  with gr.Column():
531
  micro_batch_size = gr.Slider(
532
- minimum=1, maximum=100, value=1,
533
  label="Micro Batch Size",
534
  info="The number of examples in each mini-batch for gradient computation. A smaller micro_batch_size reduces memory usage but may increase training time."
535
  )
536
 
537
  gradient_accumulation_steps = gr.Slider(
538
- minimum=1, maximum=10, value=1,
539
  label="Gradient Accumulation Steps",
540
  info="The number of steps to accumulate gradients before updating model parameters. This can be used to simulate a larger effective batch size without increasing memory usage."
541
  )
542
 
543
  epochs = gr.Slider(
544
- minimum=1, maximum=100, value=1,
545
  label="Epochs",
546
  info="The number of times to iterate over the entire training dataset. A larger number of epochs may improve model performance but also increase the risk of overfitting.")
547
 
@@ -553,19 +553,19 @@ def finetune_ui():
553
 
554
  with gr.Column():
555
  lora_r = gr.Slider(
556
- minimum=1, maximum=16, value=8,
557
  label="LoRA R",
558
  info="The rank parameter for LoRA, which controls the dimensionality of the rank decomposition matrices. A larger lora_r increases the expressiveness and flexibility of LoRA but also increases the number of trainable parameters and memory usage."
559
  )
560
 
561
  lora_alpha = gr.Slider(
562
- minimum=1, maximum=128, value=16,
563
  label="LoRA Alpha",
564
  info="The scaling parameter for LoRA, which controls how much LoRA affects the original pre-trained model weights. A larger lora_alpha amplifies the impact of LoRA but may also distort or override the pre-trained knowledge."
565
  )
566
 
567
  lora_dropout = gr.Slider(
568
- minimum=0, maximum=1, value=0.01,
569
  label="LoRA Dropout",
570
  info="The dropout probability for LoRA, which controls the fraction of LoRA parameters that are set to zero during training. A larger lora_dropout increases the regularization effect of LoRA but also increases the risk of underfitting."
571
  )
 
360
 
361
  Global.should_stop_training = False
362
 
363
+ return "Done. " + Global.train_fn(
364
  get_base_model(), # base_model
365
  get_tokenizer(), # tokenizer
366
  os.path.join(Global.data_dir, "lora_models",
 
529
  with gr.Row():
530
  with gr.Column():
531
  micro_batch_size = gr.Slider(
532
+ minimum=1, maximum=100, step=1, value=4,
533
  label="Micro Batch Size",
534
  info="The number of examples in each mini-batch for gradient computation. A smaller micro_batch_size reduces memory usage but may increase training time."
535
  )
536
 
537
  gradient_accumulation_steps = gr.Slider(
538
+ minimum=1, maximum=10, step=1, value=32,
539
  label="Gradient Accumulation Steps",
540
  info="The number of steps to accumulate gradients before updating model parameters. This can be used to simulate a larger effective batch size without increasing memory usage."
541
  )
542
 
543
  epochs = gr.Slider(
544
+ minimum=1, maximum=100, step=1, value=1,
545
  label="Epochs",
546
  info="The number of times to iterate over the entire training dataset. A larger number of epochs may improve model performance but also increase the risk of overfitting.")
547
 
 
553
 
554
  with gr.Column():
555
  lora_r = gr.Slider(
556
+ minimum=1, maximum=16, step=1, value=8,
557
  label="LoRA R",
558
  info="The rank parameter for LoRA, which controls the dimensionality of the rank decomposition matrices. A larger lora_r increases the expressiveness and flexibility of LoRA but also increases the number of trainable parameters and memory usage."
559
  )
560
 
561
  lora_alpha = gr.Slider(
562
+ minimum=1, maximum=128, step=1, value=16,
563
  label="LoRA Alpha",
564
  info="The scaling parameter for LoRA, which controls how much LoRA affects the original pre-trained model weights. A larger lora_alpha amplifies the impact of LoRA but may also distort or override the pre-trained knowledge."
565
  )
566
 
567
  lora_dropout = gr.Slider(
568
+ minimum=0, maximum=1, value=0.05,
569
  label="LoRA Dropout",
570
  info="The dropout probability for LoRA, which controls the fraction of LoRA parameters that are set to zero during training. A larger lora_dropout increases the regularization effect of LoRA but also increases the risk of underfitting."
571
  )
llama_lora/ui/inference_ui.py CHANGED
@@ -335,6 +335,14 @@ def inference_ui():
335
  // Add tooltips
336
  setTimeout(function () {
337
 
 
 
 
 
 
 
 
 
338
  tippy("#inference_prompt_template", {
339
  placement: 'bottom-start',
340
  delay: [500, 0],
 
335
  // Add tooltips
336
  setTimeout(function () {
337
 
338
+ tippy("#inference_lora_model", {
339
+ placement: 'bottom-start',
340
+ delay: [500, 0],
341
+ animation: 'scale-subtle',
342
+ content: 'Select a LoRA model form your data directory, or type in a model name on HF (e.g.: <code>tloen/alpaca-lora-7b</code>).',
343
+ allowHTML: true,
344
+ });
345
+
346
  tippy("#inference_prompt_template", {
347
  placement: 'bottom-start',
348
  delay: [500, 0],