Mila
Deep Neural Network Library
Loading...
Searching...
No Matches
Dnn.Models.QwenProtocol Module Reference

Exported Modules

module  Dnn.Models.Conversation
module  nlohmann.json

Enumerations

enum class  Mila::Dnn::Qwen::ReasoningEffort { Low , Medium , Xhigh }
 How much reasoning to spend, as the checkpoint's template defines it. More...

Functions

std::string Mila::Dnn::Qwen::formatPrompt (std::span< const Conversation::Turn > history, bool enable_thinking, ReasoningEffort effort=ReasoningEffort::Medium, const std::string &tool_signatures={})
 Render a history into Qwen's ChatML prompt, primed for generation.
std::string Mila::Dnn::Qwen::formatToolCall (const std::string &name, const std::string &arguments)
 One tool call rendered in the grammar the model emits it in.
std::string Mila::Dnn::Qwen::formatTurn (const Conversation::Turn &message)
 Render one completed turn, delimiters included.
std::optional< Conversation::ToolCall > Mila::Dnn::Qwen::parseToolCall (const std::string &response)
 The first tool call in a response, or nothing when it holds none.
ReasoningEffort Mila::Dnn::Qwen::reasoningEffortFromScale (int level)
 Map a 1..5 effort scale onto the three levels the model knows.
std::string_view Mila::Dnn::Qwen::reasoningInstruction (ReasoningEffort effort)
 The instruction the template prepends to the system turn, verbatim. Empty for Medium.
std::string Mila::Dnn::Qwen::serializeToolSignatures (const std::string &tools_json)
 The tool signatures as the template renders them: one JSON object per line.
std::string Mila::Dnn::Qwen::toolsSection (const std::string &signatures)
 The tools section of the system turn, verbatim from the template.
nlohmann::json Mila::Dnn::Qwen::typedParameterValue (const std::string &text)
 The value of one <parameter=...> block, typed the way the schema-free text allows.

Variables

constexpr std::string_view Mila::Dnn::Qwen::kThinkClose = "</think>"
constexpr std::string_view Mila::Dnn::Qwen::kThinkOpen = "<think>"
constexpr std::string_view Mila::Dnn::Qwen::kToolCallClose = "</tool_call>"
constexpr std::string_view Mila::Dnn::Qwen::kToolCallOpen = "<tool_call>"
constexpr std::string_view Mila::Dnn::Qwen::kToolResponseClose = "</tool_response>"
constexpr std::string_view Mila::Dnn::Qwen::kToolResponseOpen = "<tool_response>"
constexpr std::string_view Mila::Dnn::Qwen::kTurnClose = "<|im_end|>"
constexpr std::string_view Mila::Dnn::Qwen::kTurnOpen = "<|im_start|>"
 The turn delimiters.

Files

file  Mila/Src/Dnn/Models/Qwen/Qwen.Protocol.ixx
 Canonical Qwen 3.8 chat protocol: the ChatML turn structure, the reasoning gate and the tool-call grammar.