Views
No views yet

assets/olympiad_cases.encoding folder, which contains Python scripts and test cases demonstrating how to encode messages in OpenAI-compatible format into input strings for the model and how to parse the model's text output.1import transformers
2# encoding/encoding_dsv32.py
3from encoding_dsv32 import encode_messages, parse_message_from_completion_text
4
5tokenizer = transformers.AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-V3.2")
6
7messages = [
8 {"role": "user", "content": "hello"},
9 {"role": "assistant", "content": "Hello! I am DeepSeek.", "reasoning_content": "thinking..."},
10 {"role": "user", "content": "1+1=?"}
11]
12encode_config = dict(thinking_mode="thinking", drop_thinking=True, add_default_bos_token=True)
13
14# messages -> string
15prompt = encode_messages(messages, **encode_config)
16# Output: "<|begin▁of▁sentence|><|User|>hello<|Assistant|></think>Hello! I am DeepSeek.<|end▁of▁sentence|><|User|>1+1=?<|Assistant|><think>"
17
18# string -> tokens
19tokens = tokenizer.encode(prompt)
20# Output: [0, 128803, 33310, 128804, 128799, 19923, 3, 342, 1030, 22651, 4374, 1465, 16, 1, 128803, 19, 13, 19, 127252, 128804, 128798]developer has been introduced in the chat template. This role is dedicated exclusively to search agent scenarios and is designated for no other tasks. The official API does not accept messages assigned to developer.temperature = 1.0, top_p = 0.95.@misc{deepseekai2025deepseekv32,
title={DeepSeek-V3.2: Pushing the Frontier of Open Large Language Models},
author={DeepSeek-AI},
year={2025},
}