Views
No views yet
1from transformers import AutoTokenizer
2
3tokenizer = AutoTokenizer.from_pretrained("SmallDoge/Doge2-tokenizer")
4
5conversation = [
6 {"role": "system", "content": "You are a helpful assistant."},
7 {"role": "user", "content": "What's wrong with Cheems? What treatment does he need?"},
8 {"role": "assistant", "content": "Based on Cheems' symptoms, I recommend the following treatment: For Cheems with severe kidney deficiency, it is recommended to eat more leeks and oysters."},
9]
10
11inputs = tokenizer.apply_chat_template(
12 conversation=conversation,
13 tokenize=False,
14)
15print(inputs)1<|im_start|>system
2You are a helpful assistant.<|im_end|>
3<|im_start|>user
4What's wrong with Cheems? What treatment does he need?<|im_end|>
5<|im_start|>assistant
6<think>
7
8</think>
9
10Based on Cheems' symptoms, I recommend the following treatment: For Cheems with severe kidney deficiency, it is recommended to eat more leeks and oysters.<|im_end|>
111from transformers import AutoTokenizer
2
3tokenizer = AutoTokenizer.from_pretrained("SmallDoge/Doge2-tokenizer")
4
5documents = [
6 {
7 "title": "Cheems's case",
8 "text": "Cheems is a 233-year-old alchemist, but he is very kidney deficient."
9 },
10]
11
12conversation = [
13 {"role": "system", "content": "You are a helpful assistant."},
14 {"role": "user", "content": "What's wrong with Cheems? What treatment does he need?"},
15 {"role": "assistant", "content": "Based on Cheems' symptoms, I recommend the following treatment: For Cheems with severe kidney deficiency, it is recommended to eat more leeks and oysters."},
16]
17
18inputs = tokenizer.apply_chat_template(
19 documents=documents,
20 conversation=conversation,
21 tokenize=False,
22)
23print(inputs)1<|im_start|>system
2You are a helpful assistant.
3
4You have access to the following documents. Please use them to answer the user's question.
5
6Title: Cheems's case
7Content: Cheems is a 233-year-old alchemist, but he is very kidney deficient.
8
9If the documents don't contain relevant information, rely on your general knowledge but acknowledge when you're doing so.<|im_end|>
10<|im_start|>user
11What's wrong with Cheems? What treatment does he need?<|im_end|>
12<|im_start|>assistant
13<think>
14
15</think>
16
17Based on Cheems' symptoms, I recommend the following treatment: For Cheems with severe kidney deficiency, it is recommended to eat more leeks and oysters.<|im_end|>1from transformers import AutoTokenizer
2
3tokenizer = AutoTokenizer.from_pretrained("SmallDoge/Doge2-tokenizer")
4
5tools = [
6 {
7 "name": "recommend_treatment",
8 "description": "Treatment is recommended based on patient symptoms and diagnosis.",
9 "arguments": {
10 "type": "object",
11 "properties": {
12 "diagnosis": {
13 "type": "string",
14 "description": "Patient diagnostic results"
15 },
16 "severity": {
17 "type": "string",
18 "enum": ["mild", "moderate", "severe"],
19 "description": "Severity of the condition, can be mild, moderate, or severe."
20 }
21 },
22 "required": ["diagnosis", "severity"]
23 }
24 }
25]
26
27conversation = [
28 {"role": "system", "content": "You are a helpful assistant."},
29 {"role": "user", "content": "What's wrong with Cheems? What treatment does he need?"},
30 {"role": "assistant", "content": "<tool_call>\n{\"name\": \"recommend_treatment\", \"arguments\": {\"diagnosis\": \"Deficiency of kidney\", \"severity\": \"severe\"}}\n</tool_call>"},
31 {"role": "tool", "content": "For Cheems with severe kidney deficiency, it is recommended to eat more leeks and oysters."},
32 {"role": "assistant", "content": "Based on Cheems' symptoms, I recommend the following treatment: For Cheems with severe kidney deficiency, it is recommended to eat more leeks and oysters."},
33]
34
35inputs = tokenizer.apply_chat_template(
36 tools=tools,
37 conversation=conversation,
38 tokenize=False,
39)
40print(inputs)1<|im_start|>system
2You are a helpful assistant.
3
4You may call one or more functions to assist with the user query. You are provided with function signatures within <tools></tools> XML tags:
5
6<tools>
7{"name": "recommend_treatment", "description": "Treatment is recommended based on patient symptoms and diagnosis.", "arguments": {"type": "object", "properties": {"diagnosis": {"type": "string", "description": "Patient diagnostic results"}, "severity": {"type": "string", "enum": ["mild", "moderate", "severe"], "description": "Severity of the condition, can be mild, moderate, or severe."}}, "required": ["diagnosis", "severity"]}}
8</tools>
9
10For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
11
12<tool_call>
13{"name": <function-name>, "arguments": <args-json-object>}
14</tool_call><|im_end|>
15<|im_start|>user
16What's wrong with Cheems? What treatment does he need?<|im_end|>
17<|im_start|>assistant
18<tool_call>
19{"name": "recommend_treatment", "arguments": {"diagnosis": "Deficiency of kidney", "severity": "severe"}}
20</tool_call><|im_end|>
21<|im_start|>user
22<tool_response>
23For Cheems with severe kidney deficiency, it is recommended to eat more leeks and oysters.
24</tool_response><|im_end|>
25<|im_start|>assistant
26<think>
27
28</think>
29
30Based on Cheems' symptoms, I recommend the following treatment: For Cheems with severe kidney deficiency, it is recommended to eat more leeks and oysters.<|im_end|>1from transformers import AutoTokenizer
2
3tokenizer = AutoTokenizer.from_pretrained("SmallDoge/Doge2-tokenizer")
4
5conversation = [
6 {"role": "system", "content": "You are a helpful assistant."},
7 {"role": "user", "content": "What's wrong with Cheems? What treatment does he need?"},
8 {"role": "assistant", "reasoning_content": "Cheems is a dog, a old dog. He is been around for a long time, so his innards are not as good as before. If he is not careful, he will get kidney deficiency. He needs to eat more leeks and oysters.", "content": "Based on Cheems' symptoms, I recommend the following treatment: For Cheems with severe kidney deficiency, it is recommended to eat more leeks and oysters."},
9]
10
11inputs = tokenizer.apply_chat_template(
12 conversation=conversation,
13 tokenize=False,
14)
15print(inputs)1<|im_start|>system
2You are a helpful assistant.<|im_end|>
3<|im_start|>user
4What's wrong with Cheems? What treatment does he need?<|im_end|>
5<|im_start|>assistant
6<think>
7Cheems is a dog, a old dog. He is been around for a long time, so his innards are not as good as before. If he is not careful, he will get kidney deficiency. He needs to eat more leeks and oysters.
8</think>
9
10Based on Cheems' symptoms, I recommend the following treatment: For Cheems with severe kidney deficiency, it is recommended to eat more leeks and oysters.<|im_end|>1from transformers import AutoTokenizer
2
3tokenizer = AutoTokenizer.from_pretrained("SmallDoge/Doge2-tokenizer")
4
5documents = [
6 {
7 "title": "Cheems's case",
8 "text": "Cheems is a 233-year-old alchemist, but he is very kidney deficient."
9 },
10]
11
12tools = [
13 {
14 "name": "recommend_treatment",
15 "description": "Treatment is recommended based on patient symptoms and diagnosis.",
16 "arguments": {
17 "type": "object",
18 "properties": {
19 "diagnosis": {
20 "type": "string",
21 "description": "Patient diagnostic results"
22 },
23 "severity": {
24 "type": "string",
25 "enum": ["mild", "moderate", "severe"],
26 "description": "Severity of the condition, can be mild, moderate, or severe."
27 }
28 },
29 "required": ["diagnosis", "severity"]
30 }
31 }
32]
33
34conversation = [
35 {"role": "system", "content": "You are a helpful assistant."},
36 {"role": "user", "content": "What's wrong with Cheems? What treatment does he need?"},
37 {"role": "assistant", "content": "<tool_call>\n{\"name\": \"recommend_treatment\", \"arguments\": {\"diagnosis\": \"Deficiency of kidney\", \"severity\": \"severe\"}}\n</tool_call>"},
38 {"role": "tool", "content": "For Cheems with severe kidney deficiency, it is recommended to eat more leeks and oysters."},
39 {"role": "assistant", "reasoning_content": "Cheems is a dog, a old dog. He is been around for a long time, so his innards are not as good as before. If he is not careful, he will get kidney deficiency. He needs to eat more leeks and oysters.", "content": "Based on Cheems' symptoms, I recommend the following treatment: For Cheems with severe kidney deficiency, it is recommended to eat more leeks and oysters."},
40]
41
42inputs = tokenizer.apply_chat_template(
43 documents=documents,
44 tools=tools,
45 conversation=conversation,
46 tokenize=False,
47)
48print(inputs)1<|im_start|>system
2You are a helpful assistant.
3
4You have access to the following documents. Please use them to answer the user's question.
5
6Title: Cheems's case
7Content: Cheems is a 233-year-old alchemist, but he is very kidney deficient.
8
9If the documents don't contain relevant information, rely on your general knowledge but acknowledge when you're doing so.
10
11You may call one or more functions to assist with the user query. You are provided with function signatures within <tools></tools> XML tags:
12
13<tools>
14{"name": "recommend_treatment", "description": "Treatment is recommended based on patient symptoms and diagnosis.", "arguments": {"type": "object", "properties": {"diagnosis": {"type": "string", "description": "Patient diagnostic results"}, "severity": {"type": "string", "enum": ["mild", "moderate", "severe"], "description": "Severity of the condition, can be mild, moderate, or severe."}}, "required": ["diagnosis", "severity"]}}
15</tools>
16
17For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
18
19<tool_call>
20{"name": <function-name>, "arguments": <args-json-object>}
21</tool_call><|im_end|>
22<|im_start|>user
23What's wrong with Cheems? What treatment does he need?<|im_end|>
24<|im_start|>assistant
25<tool_call>
26{"name": "recommend_treatment", "arguments": {"diagnosis": "Deficiency of kidney", "severity": "severe"}}
27</tool_call><|im_end|>
28<|im_start|>user
29<tool_response>
30For Cheems with severe kidney deficiency, it is recommended to eat more leeks and oysters.
31</tool_response><|im_end|>
32<|im_start|>assistant
33<think>
34Cheems is a dog, a old dog. He is been around for a long time, so his innards are not as good as before. If he is not careful, he will get kidney deficiency. He needs to eat more leeks and oysters.
35</think>
36
37Based on Cheems' symptoms, I recommend the following treatment: For Cheems with severe kidney deficiency, it is recommended to eat more leeks and oysters.<|im_end|>