Expand description
Model-specific conversation rendering and token encoding.
The V4 and V4.1 prompt encodings, DeepseekV4Encoding and
DeepseekV41Encoding, render conversations into prompts. A prompt
encoding with an attached tokenizer also encodes conversations into token
IDs.
A rendered prompt consists of explicit special tokens and plain text. Rendering inserts the template’s control tokens, the placeholders of a message’s image sources, and each grounding-token spelling found in assistant content or reasoning content as explicit special tokens. All other text is plain text, including template text, message content, reasoning content outside grounding tokens, tool definitions, tool call names and arguments, and the response format schema. Encoding encodes a special-token spelling in plain text as the token IDs of its characters.
Re-exports§
Modules§
- v4
- Prompt rendering for DeepSeek V4 and V4.1.
Structs§
- Prompt
Tokenizer - A tokenizer prepared for prompt encoding.
- Rendered
Prompt - A rendered prompt and the images its placeholders refer to.
Enums§
- Encoding
Error - Failure to encode a conversation.
Traits§
- Prompt
Encoding - Render model prompts and encode conversations into token IDs.
- Tokenizer
Encoder - An encoder that maps prompt text to model token IDs.