MisterAI commited on
Commit
50cfc1c
·
verified ·
1 Parent(s): f5a62d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -13
app.py CHANGED
@@ -48,24 +48,15 @@ def generate_response(input_text):
48
  # data_collator = DataCollatorForLanguageModeling(tokenizer=tokenizer, mlm=False)
49
 
50
 
51
-
52
-
53
  def fine_tune_model(dataset_path, dataset_file, epochs, batch_size, prefix):
54
  import json # Assurez-vous que json est importé
55
 
56
  # Récupération du fichier à partir de l'URL fournie
57
- response = requests.get(dataset_path)
58
  dataset_lines = response.text.strip().split('\n')
59
 
60
- # Vérifier si le fichier est au format JSONL ou JSON
61
- if dataset_path.endswith('.jsonl'):
62
- # Convertir les lignes en dictionnaires pour JSONL
63
- dataset_dict = [json.loads(line) for line in dataset_lines if line]
64
- elif dataset_path.endswith('.json'):
65
- # Charger le fichier JSON directement
66
- dataset_dict = json.loads(response.text)
67
- else:
68
- raise ValueError("Format de fichier non supporté. Utilisez .jsonl ou .json.")
69
 
70
  # Créer un Dataset Hugging Face
71
  dataset = Dataset.from_dict({
@@ -89,7 +80,10 @@ def fine_tune_model(dataset_path, dataset_file, epochs, batch_size, prefix):
89
  training_args = TrainingArguments(
90
  output_dir=f"./{prefix}_{model_name.split('/')[-1]}",
91
  num_train_epochs=epochs,
92
- per_device_train_batch_size=batch_size,
 
 
 
93
  save_steps=10_000,
94
  save_total_limit=2,
95
  push_to_hub=True,
@@ -124,6 +118,10 @@ def fine_tune_model(dataset_path, dataset_file, epochs, batch_size, prefix):
124
 
125
 
126
 
 
 
 
 
127
  # Interface Gradio
128
  with gr.Blocks() as demo:
129
  with gr.Tab("Chatbot"):
 
48
  # data_collator = DataCollatorForLanguageModeling(tokenizer=tokenizer, mlm=False)
49
 
50
 
 
 
51
  def fine_tune_model(dataset_path, dataset_file, epochs, batch_size, prefix):
52
  import json # Assurez-vous que json est importé
53
 
54
  # Récupération du fichier à partir de l'URL fournie
55
+ response = requests.get(f"{dataset_path}/resolve/main/{dataset_file}")
56
  dataset_lines = response.text.strip().split('\n')
57
 
58
+ # Convertir les lignes en dictionnaires pour JSONL
59
+ dataset_dict = [json.loads(line) for line in dataset_lines if line]
 
 
 
 
 
 
 
60
 
61
  # Créer un Dataset Hugging Face
62
  dataset = Dataset.from_dict({
 
80
  training_args = TrainingArguments(
81
  output_dir=f"./{prefix}_{model_name.split('/')[-1]}",
82
  num_train_epochs=epochs,
83
+ per_device_train_batch_size=batch_sl"
84
+ )
85
+
86
+ return "Fine-tuning terminé et modèle sauvegardé."ize,
87
  save_steps=10_000,
88
  save_total_limit=2,
89
  push_to_hub=True,
 
118
 
119
 
120
 
121
+
122
+
123
+
124
+
125
  # Interface Gradio
126
  with gr.Blocks() as demo:
127
  with gr.Tab("Chatbot"):