bragour commited on
Commit
9ebefd7
1 Parent(s): 230646e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -5,7 +5,9 @@ from awq import AutoAWQForCausalLM
5
 
6
  model_path = "bragour/Camel-7b-chat-awq"
7
 
8
- model = AutoAWQForCausalLM.from_quantized(model_path, fuse_layers=True, trust_remote_code=False, safetensors=True)
 
 
9
  tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=False)
10
 
11
 
@@ -14,7 +16,7 @@ def respond(
14
  ):
15
  formatted_prompt = f"<s>[INST]{message}[/INST]"
16
 
17
- tokens = tokenizer(formatted_prompt, return_tensors='pt').input_ids.cuda()
18
 
19
  # Generate the response from the API
20
  result = model.generate(
 
5
 
6
  model_path = "bragour/Camel-7b-chat-awq"
7
 
8
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
9
+
10
+ model = AutoAWQForCausalLM.from_quantized(model_path, fuse_layers=True, trust_remote_code=False, safetensors=True).to(device)
11
  tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=False)
12
 
13
 
 
16
  ):
17
  formatted_prompt = f"<s>[INST]{message}[/INST]"
18
 
19
+ tokens = tokenizer(formatted_prompt, return_tensors='pt').input_ids.to(device)
20
 
21
  # Generate the response from the API
22
  result = model.generate(