Skip to main content

Crate deepseek_recipe_encoding

Crate deepseek_recipe_encoding 

Source
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§

pub use v4::dsv4;
pub use v4::dsv41;

Modules§

v4
Prompt rendering for DeepSeek V4 and V4.1.

Structs§

PromptTokenizer
A tokenizer prepared for prompt encoding.
RenderedPrompt
A rendered prompt and the images its placeholders refer to.

Enums§

EncodingError
Failure to encode a conversation.

Traits§

PromptEncoding
Render model prompts and encode conversations into token IDs.
TokenizerEncoder
An encoder that maps prompt text to model token IDs.