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

Exported Modules

module  Dnn.Models.Conversation
module  nlohmann.json

Classes

struct  Mila::Dnn::Gemma::detail::Cursor
 A read cursor over an argument body, for the recursive-descent parse.

Typedefs

using Mila::Dnn::Gemma::GemmaToolCall = Conversation::ToolCall
 A tool call parsed out of the model's native <|tool_call> emission.

Functions

std::string Mila::Dnn::Gemma::extractAnswer (std::string_view text)
 Reduce a channel-structured response to just the user-facing answer.
std::string Mila::Dnn::Gemma::formatPrompt (std::span< const Conversation::Turn > history, const std::string &tool_declarations={}, bool continue_open=false)
 Render a conversation into Gemma's native prompt, primed for generation.
std::string Mila::Dnn::Gemma::formatToolCall (std::string_view name, std::string_view arguments_json)
 Render an assistant tool call back into Gemma's native call grammar.
std::string Mila::Dnn::Gemma::formatToolResponse (std::string_view name, std::string_view result_json)
 Render a client-executed tool result into Gemma's <|tool_response> grammar.
std::string Mila::Dnn::Gemma::formatTurn (const Conversation::Turn &message)
 One closed turn: <|turn>{role}
{content}<turn|>
.
std::optional< GemmaToolCall > Mila::Dnn::Gemma::parseToolCall (std::string_view text)
 Parse the most recent native Gemma tool call out of accumulated model output, once generation has stopped right after <tool_call|>.
std::string_view Mila::Dnn::Gemma::roleSpelling (Conversation::Role role)
 How the template spells a role.
std::string Mila::Dnn::Gemma::serializeToolDeclarations (const std::string &tools_json)
 Render tool schemas into Gemma's trained <|tool>declaration:...<tool|> grammar.
std::string Mila::Dnn::Gemma::stripControlTokens (std::string_view text)
 Remove every enumerated control token, then scrub whatever the set missed.

Variables

constexpr std::string_view Mila::Dnn::Gemma::kBos = "<bos>"
constexpr std::string_view Mila::Dnn::Gemma::kChannelClose = "<channel|>"
constexpr std::string_view Mila::Dnn::Gemma::kChannelLabels []
 The labels a reasoning channel is opened with, for answer extraction.
constexpr std::string_view Mila::Dnn::Gemma::kChannelOpen = "<|channel>"
constexpr std::string_view Mila::Dnn::Gemma::kEos = "<eos>"
constexpr std::string_view Mila::Dnn::Gemma::kOutputKeys [] = { "output", "result", "content", "stdout", "text" }
constexpr std::string_view Mila::Dnn::Gemma::kPad = "<pad>"
constexpr std::string_view Mila::Dnn::Gemma::kStringDelimiter = "<|\"|>"
constexpr std::string_view Mila::Dnn::Gemma::kThink = "<|think|>"
constexpr std::string_view Mila::Dnn::Gemma::kThoughtPrime = "<|channel>thought\n<channel|>"
 The empty reasoning channel that opens a fresh model turn.
constexpr std::string_view Mila::Dnn::Gemma::kToolCallClose = "<tool_call|>"
constexpr std::string_view Mila::Dnn::Gemma::kToolCallOpen = "<|tool_call>"
constexpr std::string_view Mila::Dnn::Gemma::kToolClose = "<tool|>"
constexpr std::string_view Mila::Dnn::Gemma::kToolOpen = "<|tool>"
constexpr std::string_view Mila::Dnn::Gemma::kToolResponseClose = "<tool_response|>"
constexpr std::string_view Mila::Dnn::Gemma::kToolResponseOpen = "<|tool_response>"
constexpr std::string_view Mila::Dnn::Gemma::kTurnClose = "<turn|>"
constexpr std::string_view Mila::Dnn::Gemma::kTurnOpen = "<|turn>"

Files

file  Mila/Src/Dnn/Models/Gemma/Gemma.Protocol.ixx
 Canonical Gemma 4 native token grammar: the turn template, the tool-declaration renderer, the tool-call grammar and answer extraction.