Update README.md
Browse files
README.md
CHANGED
@@ -40,8 +40,15 @@ messages = [{
|
|
40 |
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True)
|
41 |
inputs = inputs[:, 1:] # remove bos token
|
42 |
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
response = tokenizer.decode(outputs[0])
|
46 |
|
47 |
outputs = model.generate(inputs=input_ids.cuda(), attention_mask=attention_mask.cuda(), max_new_tokens=10)
|
|
|
40 |
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True)
|
41 |
inputs = inputs[:, 1:] # remove bos token
|
42 |
|
43 |
+
terminators = [
|
44 |
+
tokenizer.eos_token_id,
|
45 |
+
tokenizer.convert_tokens_to_ids("<|eot_id|>")
|
46 |
+
]
|
47 |
+
|
48 |
+
outputs = model.generate(input_ids=inputs.cuda()[:, 1:],
|
49 |
+
max_new_tokens=20,
|
50 |
+
eos_token_id=terminators)
|
51 |
+
|
52 |
response = tokenizer.decode(outputs[0])
|
53 |
|
54 |
outputs = model.generate(inputs=input_ids.cuda(), attention_mask=attention_mask.cuda(), max_new_tokens=10)
|