jatingocodeo commited on
Commit
2862eb9
·
verified ·
1 Parent(s): d370ed4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -11
app.py CHANGED
@@ -204,18 +204,12 @@ def load_model():
204
  print("Adding special tokens...")
205
  tokenizer.add_special_tokens(special_tokens)
206
 
207
- print("Loading model configuration...")
208
- config = SmolLM2Config()
209
-
210
- print("Initializing model...")
211
- model = SmolLM2ForCausalLM(config)
212
-
213
- print("Loading model weights...")
214
- state_dict = torch.load(
215
- os.path.join(model_id, "pytorch_model.bin"),
216
- map_location="cpu"
217
  )
218
- model.load_state_dict(state_dict)
219
 
220
  # Move model to device manually
221
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
 
204
  print("Adding special tokens...")
205
  tokenizer.add_special_tokens(special_tokens)
206
 
207
+ print("Loading model from Hugging Face Hub...")
208
+ model = AutoModelForCausalLM.from_pretrained(
209
+ model_id,
210
+ torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
211
+ trust_remote_code=True
 
 
 
 
 
212
  )
 
213
 
214
  # Move model to device manually
215
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")