Archived
arch: Gemma 4's reply format into arch/common, for both Gemma 4 plugins
Two plugins are about to serve Gemma 4 -- gemma4_bf16 the CT-INT4 dense release and arch/gemma4 the bf16 / fp8-expert containers -- and the reply format is the model's, not the weights': the thought channel, and calls written as a name and one object in Gemma's dialect of JSON. One declaration in the shared header library (installed as <arch/rad_gemma4_chat.h>), so the two cannot drift apart and the reply-format tests read what both export. The declaration moves unchanged, from gemma4_bf16::chat_format_decl() to rad::arch::gemma4_chat_format(); chatparse_gemma4_test follows it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
846e52148a
commit
368d0363eb
3 files changed
+23
-20
No files matched your search
@@ -1,4 +1,4 @@
|
||||
/* gemma4_chat_format.h -- how Gemma 4 spells a turn: its reasoning and its tool calls, as data.
|
||||
/* rad_gemma4_chat.h -- how Gemma 4 spells a turn: its reasoning and its tool calls, as data.
|
||||
*
|
||||
* The chat template is one llama.cpp reads with a hand-written handler, so the template analysis
|
||||
* finds nothing in it, and the engine would serve the model with no reasoning split and refuse
|
||||
@@ -16,14 +16,17 @@
|
||||
* the answer, and a lone <channel|>. `reasoning_anywhere` reads the first as reasoning and drops
|
||||
* the second, so neither reaches the content.
|
||||
*
|
||||
* Kept in a header of its own so the reply-format tests read the declaration the plugin exports
|
||||
* rather than a copy of it. */
|
||||
* Here rather than in one plugin because two plugins serve Gemma 4 -- arch/gemma4 (bf16 and fp8
|
||||
* experts) and arch/gemma4_bf16 (the CT-INT4 dense release) -- and the format is the model's, not
|
||||
* the weights'. One declaration, so the two cannot drift apart, and so the reply-format tests read
|
||||
* the declaration the plugins export rather than a copy of it. */
|
||||
#pragma once
|
||||
#include "rad_builder.h"
|
||||
|
||||
namespace gemma4_bf16 {
|
||||
namespace rad {
|
||||
namespace arch {
|
||||
|
||||
inline const RadChatFormat* chat_format_decl() {
|
||||
inline const RadChatFormat* gemma4_chat_format() {
|
||||
static const char* const kBreaks[] = { "<|tool_call>" };
|
||||
static const char* const kTriggers[] = { "<|tool_call>" };
|
||||
static const RadChatFormat f = [] {
|
||||
@@ -57,4 +60,5 @@ inline const RadChatFormat* chat_format_decl() {
|
||||
return &f;
|
||||
}
|
||||
|
||||
} /* namespace gemma4_bf16 */
|
||||
} /* namespace arch */
|
||||
} /* namespace rad */
|
||||
@@ -9,8 +9,7 @@
|
||||
* cap * tanh(x / cap).
|
||||
*/
|
||||
#include <arch/rad_arch.h>
|
||||
|
||||
#include "gemma4_chat_format.h"
|
||||
#include <arch/rad_gemma4_chat.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -881,8 +880,8 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
}
|
||||
}
|
||||
|
||||
/* The reply format: gemma4_chat_format.h. */
|
||||
const RadChatFormat* chat_format(const RadModelMeta*) { return chat_format_decl(); }
|
||||
/* The reply format: the model's, shared with arch/gemma4 (arch/rad_gemma4_chat.h). */
|
||||
const RadChatFormat* chat_format(const RadModelMeta*) { return gemma4_chat_format(); }
|
||||
|
||||
#ifndef RAD_ARCH_NO_EXPORTS
|
||||
RAD_ARCH_PLUGIN(gemma4_bf16, "gemma4", "compressed-tensors", "0.1.0",
|
||||
|
||||
Reference in new issue
Block a user