Tonic commited on
Commit
aa91997
·
1 Parent(s): b9eff4b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -15,6 +15,16 @@ model_name = "allenai/tulu-2-dpo-13b"
15
  tokenizer = AutoTokenizer.from_pretrained("allenai/tulu-2-dpo-13b")
16
  model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
17
 
 
 
 
 
 
 
 
 
 
 
18
  class TuluChatBot:
19
  def __init__(self, model, tokenizer, system_message="You are 🌷Tulu, an AI language model created by Tonic-AI. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior."):
20
  self.model = model
@@ -30,7 +40,7 @@ class TuluChatBot:
30
 
31
  def Tulu(self, user_message, temperature, max_new_tokens, top_p, repetition_penalty, do_sample):
32
  prompt = self.format_prompt(user_message)
33
- inputs = self.tokenizer(prompt, return_tensors='pt', add_special_tokens=False)
34
  input_ids = inputs["input_ids"].to(self.model.device)
35
  attention_mask = inputs["attention_mask"].to(self.model.device)
36
 
 
15
  tokenizer = AutoTokenizer.from_pretrained("allenai/tulu-2-dpo-13b")
16
  model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
17
 
18
+ bos_token_id = 1
19
+ eos_token_id = 2
20
+ tokenizer.bos_token_id = bos_token_id
21
+ tokenizer.eos_token_id = eos_token_id
22
+ model.config.bos_token_id = bos_token_id
23
+ model.config.eos_token_id = eos_token_id
24
+ if tokenizer.pad_token is None:
25
+ tokenizer.pad_token = tokenizer.eos_token
26
+ model.config.pad_token_id = tokenizer.convert_tokens_to_ids(tokenizer.pad_token)
27
+
28
  class TuluChatBot:
29
  def __init__(self, model, tokenizer, system_message="You are 🌷Tulu, an AI language model created by Tonic-AI. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior."):
30
  self.model = model
 
40
 
41
  def Tulu(self, user_message, temperature, max_new_tokens, top_p, repetition_penalty, do_sample):
42
  prompt = self.format_prompt(user_message)
43
+ inputs = self.tokenizer(prompt, return_tensors='pt', add_special_tokens=True)
44
  input_ids = inputs["input_ids"].to(self.model.device)
45
  attention_mask = inputs["attention_mask"].to(self.model.device)
46