Archived
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:
1 parent
73bee2dcc2
commit
b64b0de7de
5 files changed
+90
-1
No files matched your search
+12
-1
@@ -132,6 +132,10 @@ void usage() {
|
||||
" --imatrix F llama.cpp imatrix: the expert-popularity profile, the column\n"
|
||||
" importances handed to each quantiser, and the weighting of the\n"
|
||||
" error report\n"
|
||||
" --chat-template F a jinja template baked as the container's chat template,\n"
|
||||
" overriding the checkpoint's own (or its absence). A release that\n"
|
||||
" ships none (DeepSeek's) needs one, or /v1/chat/completions answers\n"
|
||||
" 501. Trailing newlines are stripped\n"
|
||||
" --set K=V a metadata key, seen by declare AND written into the container,\n"
|
||||
" so a convert-time choice that must also hold at serve time is\n"
|
||||
" stated once. Repeatable\n"
|
||||
@@ -201,7 +205,7 @@ int for_row_pieces(int64_t n, bool parallel, std::string* why, F fn) {
|
||||
} /* namespace */
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
std::string in, out, arch_override, home = rad_home(), tokjson, imat_path, draft_dir;
|
||||
std::string in, out, arch_override, home = rad_home(), tokjson, imat_path, draft_dir, chat_tmpl;
|
||||
std::string tokjson2, config_dir;
|
||||
std::vector<std::string> add_files;
|
||||
std::vector<std::string> hierarchy = rad_hierarchy_from_env();
|
||||
@@ -245,6 +249,7 @@ int main(int argc, char** argv) {
|
||||
else if (a == "--add") add_files.push_back(next("--add"));
|
||||
else if (a == "--config") config_dir = next("--config");
|
||||
else if (a == "--imatrix") imat_path = next("--imatrix");
|
||||
else if (a == "--chat-template") chat_tmpl = next("--chat-template");
|
||||
else if (a == "--set") {
|
||||
const std::string kv = next("--set");
|
||||
const size_t eq = kv.find('=');
|
||||
@@ -967,6 +972,12 @@ int main(int argc, char** argv) {
|
||||
w.abort();
|
||||
return 1;
|
||||
}
|
||||
/* The operator's template replaces whatever the checkpoint carried (or lacked), so a release
|
||||
* that ships none still bakes a container that serves /v1/chat/completions. */
|
||||
if (!chat_tmpl.empty() && read_chat_template_path(chat_tmpl.c_str(), vb) < 0) {
|
||||
w.abort();
|
||||
return 1;
|
||||
}
|
||||
/* Serialised at section offset 0; finish() rebases once the string blob is sized. */
|
||||
std::vector<uint8_t> vocab_blob;
|
||||
if (vocab_serialize(vb, sink, 0, vocab_blob) < 0) { w.abort(); return 1; }
|
||||
|
||||
Reference in new issue
Block a user