convert: --chat-template, bake a template a release ships none of

DeepSeek's release carries no chat_template.jinja and its tokenizer_config.json
names none, so an HF-direct container answers /v1/chat/completions with 501
unless the serve passes --override-chat-template. The converter now takes the
template itself and bakes it into the vocab section, overriding whatever the
checkpoint carried or lacked. Trailing newlines are stripped as for a sibling
chat_template.jinja, and an unreadable or empty file is refused rather than
skipped. Both paths are covered: text_test reads the file, convert_test
converts the tiny checkpoint and reads the template back out of the container.

(cherry picked from commit 6381f61794cd61d1f86925fd23ea61e1b1544dfe)
This commit is contained in:
baKon authored and StillDeadcode committed 2026-10-28 13:50:16 +01:00
1 parent 73bee2dcc2
commit b64b0de7de
5 files changed
+90 -1

No files matched your search

+6
View File
@@ -320,6 +320,12 @@ int parse_tokenizer_json(const char* path, VocabBuild& out);
/* Same, from an in-memory buffer, for a tokenizer.json that arrived some other way. */
int parse_tokenizer_json_buf(std::string_view json, const char* origin, VocabBuild& out);
/* Read a standalone chat template file into out.chat_template, trailing newlines stripped.
* A release that ships no template (DeepSeek's does not) needs one from elsewhere; the caller
* passes the file. An unreadable or empty file is an error, never a silent skip. Returns
* RAD_OK, or RAD_E_IO when the file cannot be read. */
int read_chat_template_path(const char* path, VocabBuild& out);
/* Build a VocabBuild from a GGUF's tokenizer.ggml.* metadata.
*
* GGUF has no declared chain, only `tokenizer.ggml.pre`, a name llama.cpp derived by hashing the