Update README.md
Browse files
README.md
CHANGED
|
@@ -37,10 +37,10 @@ tokenizer = AutoTokenizer.from_pretrained(
|
|
| 37 |
)
|
| 38 |
device = next(model.model.parameters()).device
|
| 39 |
|
| 40 |
-
# if
|
| 41 |
-
|
| 42 |
-
# if
|
| 43 |
-
formatted_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt = True, enable_thinking = False)
|
| 44 |
|
| 45 |
input_ids = tokenizer.encode(formatted_prompt, return_tensors='pt').to(device)
|
| 46 |
outputs = model.generate(
|
|
@@ -48,10 +48,10 @@ outputs = model.generate(
|
|
| 48 |
max_new_tokens=1000,
|
| 49 |
do_sample=True
|
| 50 |
)
|
| 51 |
-
# if
|
| 52 |
-
|
| 53 |
-
# if
|
| 54 |
-
ans = [i.split("<|im_start|> assistant\n<think>\n\n</think>", 1)[1].strip() for i in tokenizer.batch_decode(outputs)]
|
| 55 |
```
|
| 56 |
|
| 57 |
<p align="center">
|
|
|
|
| 37 |
)
|
| 38 |
device = next(model.model.parameters()).device
|
| 39 |
|
| 40 |
+
# if open think mode, use the following code
|
| 41 |
+
formatted_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt = True, enable_thinking = True)
|
| 42 |
+
# if close think mode, use the following code
|
| 43 |
+
# formatted_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt = True, enable_thinking = False)
|
| 44 |
|
| 45 |
input_ids = tokenizer.encode(formatted_prompt, return_tensors='pt').to(device)
|
| 46 |
outputs = model.generate(
|
|
|
|
| 48 |
max_new_tokens=1000,
|
| 49 |
do_sample=True
|
| 50 |
)
|
| 51 |
+
# if open think mode, use the following code
|
| 52 |
+
ans = [i.split("<|im_start|> assistant\n", 1)[1].strip() for i in tokenizer.batch_decode(outputs)]
|
| 53 |
+
# if close think mode, use the following code
|
| 54 |
+
# ans = [i.split("<|im_start|> assistant\n<think>\n\n</think>", 1)[1].strip() for i in tokenizer.batch_decode(outputs)]
|
| 55 |
```
|
| 56 |
|
| 57 |
<p align="center">
|