amaltese commited on
Commit
de78a7b
Β·
verified Β·
1 Parent(s): b595237

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -16
app.py CHANGED
@@ -104,17 +104,11 @@ def finetune_model(csv_file, sample_size=100, num_epochs=3, progress=gr.Progress
104
  # Load tokenizer
105
  progress(0.2, "Loading tokenizer...")
106
 
107
- # Try the non-gated Mistral model first
108
  model_name = "mistralai/Mistral-7B-v0.1"
109
- try:
110
- tokenizer = AutoTokenizer.from_pretrained(model_name, token=hf_token)
111
- print(f"Successfully loaded tokenizer for {model_name}")
112
- except Exception as e:
113
- print(f"Error loading {model_name}: {e}")
114
- print("Falling back to original Mistral model with token authentication...")
115
- model_name = "mistralai/Mistral-7B-v0.1"
116
- tokenizer = AutoTokenizer.from_pretrained(model_name, token=hf_token)
117
 
 
118
  tokenizer.pad_token = tokenizer.eos_token
119
 
120
  # Tokenize dataset
@@ -262,10 +256,10 @@ with gr.Blocks() as demo:
262
  # Check if we can access Mistral model
263
  try:
264
  from huggingface_hub import model_info
265
- info = model_info(" {model_name}", token=hf_token)
266
- status.append(f"βœ… Access to Mistral model verified: {info.modelId}")
267
  except Exception as e:
268
- status.append(f"❌ Cannot access Mistral model: {str(e)}")
269
 
270
  return "\n".join(status)
271
 
@@ -291,12 +285,12 @@ with gr.Blocks() as demo:
291
  gr.Markdown("""
292
  ## Fine-Tuning Mistral 7B for Student Bot
293
 
294
- This app fine-tunes the Mistral 7B model to respond like a student to teacher prompts.
295
 
296
  ### Requirements
297
  - CSV file with teacher-student conversation pairs
298
  - GPU acceleration (provided by this Space)
299
- - Hugging Face authentication for accessing gated models
300
 
301
  ### Process
302
  1. Upload your CSV file
@@ -305,9 +299,8 @@ with gr.Blocks() as demo:
305
  4. View test results with sample prompts
306
 
307
  ### Important Notes
308
- - The app tries to use Mistral-7B-Instruct-v0.2 which is not gated
309
- - If that fails, it falls back to the original Mistral-7B-v0.1 model (which requires authentication)
310
  - Fine-tuning can take several hours depending on your sample size and epochs
 
311
  """)
312
 
313
  # Launch app
 
104
  # Load tokenizer
105
  progress(0.2, "Loading tokenizer...")
106
 
107
+ # Use only the original Mistral model
108
  model_name = "mistralai/Mistral-7B-v0.1"
109
+ print(f"Using model: {model_name}")
 
 
 
 
 
 
 
110
 
111
+ tokenizer = AutoTokenizer.from_pretrained(model_name, token=hf_token)
112
  tokenizer.pad_token = tokenizer.eos_token
113
 
114
  # Tokenize dataset
 
256
  # Check if we can access Mistral model
257
  try:
258
  from huggingface_hub import model_info
259
+ info = model_info("mistralai/Mistral-7B-v0.1", token=hf_token)
260
+ status.append(f"βœ… Access to Mistral-7B-v0.1 model verified: {info.modelId}")
261
  except Exception as e:
262
+ status.append(f"❌ Cannot access Mistral-7B-v0.1 model: {str(e)}")
263
 
264
  return "\n".join(status)
265
 
 
285
  gr.Markdown("""
286
  ## Fine-Tuning Mistral 7B for Student Bot
287
 
288
+ This app fine-tunes the original Mistral-7B-v0.1 model to respond like a student to teacher prompts.
289
 
290
  ### Requirements
291
  - CSV file with teacher-student conversation pairs
292
  - GPU acceleration (provided by this Space)
293
+ - Hugging Face authentication for accessing Mistral-7B-v0.1 (which is a gated model)
294
 
295
  ### Process
296
  1. Upload your CSV file
 
299
  4. View test results with sample prompts
300
 
301
  ### Important Notes
 
 
302
  - Fine-tuning can take several hours depending on your sample size and epochs
303
+ - The model will be saved in the Space and can be downloaded for further use
304
  """)
305
 
306
  # Launch app