Ray2333 commited on
Commit
a41cd27
·
verified ·
1 Parent(s): 91f5dee

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +3 -0
README.md CHANGED
@@ -68,6 +68,9 @@ message_template = tokenizer.apply_chat_template(message, tokenize=False)
68
  kwargs = {"padding": 'longest', "truncation": True, "return_tensors": "pt"}
69
  tokens = tokenizer.encode_plus(message_template, **kwargs)
70
 
 
 
 
71
  with torch.no_grad():
72
  reward_tensor = reward_model(tokens["input_ids"][0].view(1,-1).to(device), attention_mask=tokens["attention_mask"][0].view(1,-1).to(device))[0]
73
  reward = reward_tensor.cpu().detach().item()
 
68
  kwargs = {"padding": 'longest', "truncation": True, "return_tensors": "pt"}
69
  tokens = tokenizer.encode_plus(message_template, **kwargs)
70
 
71
+ # The encode_plus may add another bos token though no impact on the final performance, but you can also avoid this by using the following code:
72
+ # tokens = tokenizer.apply_chat_template(message, tokenize=True, return_dict=True, **kwargs)
73
+
74
  with torch.no_grad():
75
  reward_tensor = reward_model(tokens["input_ids"][0].view(1,-1).to(device), attention_mask=tokens["attention_mask"][0].view(1,-1).to(device))[0]
76
  reward = reward_tensor.cpu().detach().item()