Andrewwwwww commited on
Commit
43203f0
1 Parent(s): 95923dc

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +7 -4
handler.py CHANGED
@@ -32,10 +32,13 @@ class EndpointHandler:
32
 
33
  #for chat in prompts:
34
  #print(chat)
35
- input_ids = self.tokenizer(prompt, return_tensors="pt").input_ids.to("cuda")
36
- generated_ids = self.model.generate(input_ids, max_new_tokens=750, temperature=0.8, repetition_penalty=1.1, do_sample=True, eos_token_id=self.tokenizer.eos_token_id)
37
- response = self.tokenizer.decode(generated_ids[0][input_ids.shape[-1]:], skip_special_tokens=True, clean_up_tokenization_space=True)
38
- return response
 
 
 
39
 
40
  """
41
  encodeds = self.tokenizer.encode(prompt, return_tensors="pt")
 
32
 
33
  #for chat in prompts:
34
  #print(chat)
35
+
36
+ encodeds = self.tokenizer.encode(prompt, return_tensors="pt")
37
+ model_inputs = encodeds.to(device)
38
+ self.model.to(device)
39
+ generated_ids = self.model.generate(model_inputs, max_new_tokens=1000, do_sample=True)
40
+ decoded = self.tokenizer.decode(generated_ids[0])
41
+ return decoded
42
 
43
  """
44
  encodeds = self.tokenizer.encode(prompt, return_tensors="pt")