malvin noel commited on
Commit
90310a8
·
1 Parent(s): b73d328

load model correction

Browse files
Files changed (1) hide show
  1. scripts/generate_scripts.py +4 -3
scripts/generate_scripts.py CHANGED
@@ -9,15 +9,16 @@ import spaces
9
  import torch
10
  from transformers import AutoModelForCausalLM, AutoTokenizer
11
 
12
- model_id = "Qwen/Qwen2.5-0.5B"
13
 
14
- tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
15
- model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float32, trust_remote_code=True).to(device)
16
 
17
 
18
  @spaces.GPU()
19
  def generate_local(prompt: str, max_new_tokens: int = 350, temperature: float = 0.7) -> str:
 
20
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu") # get the device the model is on
 
 
 
21
  inputs = tokenizer(prompt, return_tensors="pt").to(device)
22
 
23
  output_ids = model.generate(
 
9
  import torch
10
  from transformers import AutoModelForCausalLM, AutoTokenizer
11
 
 
12
 
 
 
13
 
14
 
15
  @spaces.GPU()
16
  def generate_local(prompt: str, max_new_tokens: int = 350, temperature: float = 0.7) -> str:
17
+ model_id = "Qwen/Qwen2.5-0.5B"
18
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu") # get the device the model is on
19
+
20
+ tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
21
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float32, trust_remote_code=True).to(device)
22
  inputs = tokenizer(prompt, return_tensors="pt").to(device)
23
 
24
  output_ids = model.generate(