Update README.md
Browse files
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()
|