Support Spark reasoning and tagged tool calls

This commit is contained in:
Constantin authored and StillDeadcode committed 2026-11-03 19:08:58 +01:00
1 parent e56d948889
commit 1483a1ae17
4 files changed
+193

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
/* Spark's reply format: the checkpoint's template writes these tags around each call. */
#pragma once
#include "rad_builder.h"
namespace spark25_bf16 {
inline const RadChatFormat* spark_chat_format() {
static const char* const breaks[] = {"<tool_call>"};
static const char* const triggers[] = {"<tool_call>"};
static const RadChatFormat f = [] {
RadChatFormat x{};
x.struct_size = sizeof(x);
x.name = "plugin:spark25";
x.reasoning_open = "<think>";
x.reasoning_close = "</think>";
x.reasoning_breaks = breaks;
x.n_reasoning_breaks = 1;
x.reasoning_in_prompt = RAD_CHAT_THINK_FROM_PROMPT;
/* There is no delimiter between the call opener and the function name. */
x.name_prefix = "<tool_call>";
x.call_end = "</tool_call>";
x.arg_prefix = "<arg_key>";
x.arg_name_suffix = "</arg_key>";
x.arg_value_prefix = "<arg_value>";
x.arg_value_suffix = "</arg_value>";
x.string_value = RAD_CHAT_VALUE_RAW;
x.other_value = RAD_CHAT_VALUE_JSON;
x.triggers = triggers;
x.n_triggers = 1;
return x;
}();
return &f;
}
} /* namespace spark25_bf16 */
+3
View File
@@ -10,6 +10,7 @@
* accumulate in f32; rmsnorm reads that stream and writes bf16 for the linear projections.
*/
#include <arch/rad_arch.h>
#include "chat.h"
#include <cmath>
#include <sstream>
@@ -315,7 +316,9 @@ static void step(RadCtx* c, const RadBatch* batch) {
}
}
static const RadChatFormat* chat_format(const RadModelMeta*) { return spark_chat_format(); }
}
#ifndef RAD_ARCH_NO_EXPORTS
RAD_ARCH_PLUGIN(spark25_bf16, "spark25", "", "0.1.0", "Spark X2.6 BF16")
RAD_ARCH_CHAT_FORMAT(spark25_bf16)
#endif