AlexHung29629 commited on
Commit
713bc6b
·
verified ·
1 Parent(s): 2ef161a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -45,8 +45,8 @@ CHAT_TEMPLATE="""{%- set default_system_message = "A user will ask you to solve
45
 
46
  if torch.cuda.is_available():
47
  model_id = "mistralai/Mistral-Small-24B-Instruct-2501"
48
- model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
49
- tokenizer = AutoTokenizer.from_pretrained(model_id)
50
 
51
 
52
  @spaces.GPU
@@ -61,7 +61,7 @@ def generate(
61
  ) -> Iterator[str]:
62
  conversation = [*chat_history, {"role": "user", "content": message}]
63
 
64
- input_ids = tokenizer.apply_chat_template(conversation, chat_template=CHAT_TEMPLATE, return_tensors="pt")
65
  if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
66
  input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
67
  gr.Warning(f"Trimmed input from conversation as it was longer than {MAX_INPUT_TOKEN_LENGTH} tokens.")
 
45
 
46
  if torch.cuda.is_available():
47
  model_id = "mistralai/Mistral-Small-24B-Instruct-2501"
48
+ model = AutoModelForCausalLM.from_pretrained("AlexHung29629/fix_magistra4b", torch_dtype=torch.bfloat16, device_map="auto")
49
+ tokenizer = AutoTokenizer.from_pretrained("AlexHung29629/fix_magistra4")
50
 
51
 
52
  @spaces.GPU
 
61
  ) -> Iterator[str]:
62
  conversation = [*chat_history, {"role": "user", "content": message}]
63
 
64
+ input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
65
  if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
66
  input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
67
  gr.Warning(f"Trimmed input from conversation as it was longer than {MAX_INPUT_TOKEN_LENGTH} tokens.")