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
@@ -21,6 +21,8 @@
|
||||
*/
|
||||
#include "rad_test.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "text/gguf.h"
|
||||
#include "text/tokenizer.h"
|
||||
#include "text/tokenizer_nfc.h"
|
||||
@@ -2240,4 +2242,29 @@ TEST(the_normal_forms_agree_with_an_independent_implementation) {
|
||||
CHECK(rows > 2500);
|
||||
}
|
||||
|
||||
/* A release that ships no chat template (DeepSeek's) is why --chat-template exists: the file is
|
||||
* read, trailing newlines stripped exactly as the checkpoint's own file is, and an unreadable or
|
||||
* empty file is refused rather than skipped. */
|
||||
TEST(read_chat_template_path_strips_newlines_and_refuses_empty) {
|
||||
VocabBuild vb;
|
||||
const std::string p = radtest::tmp_path("chat_template.jinja");
|
||||
{
|
||||
std::ofstream f(p);
|
||||
f << "{%- raw %}{{ messages }}{%- endraw %}\n\n";
|
||||
}
|
||||
CHECK_OK(read_chat_template_path(p.c_str(), vb));
|
||||
CHECK_EQ(vb.chat_template, std::string("{%- raw %}{{ messages }}{%- endraw %}"));
|
||||
|
||||
vb.chat_template.clear();
|
||||
{
|
||||
std::ofstream f(p);
|
||||
f << "\n\r\n";
|
||||
}
|
||||
CHECK_EQ(read_chat_template_path(p.c_str(), vb), (int)RAD_E_IO);
|
||||
CHECK(vb.chat_template.empty());
|
||||
|
||||
CHECK_EQ(read_chat_template_path(radtest::tmp_path("absent.jinja").c_str(), vb), (int)RAD_E_IO);
|
||||
std::remove(p.c_str());
|
||||
}
|
||||
|
||||
RAD_TEST_MAIN()
|
||||
Reference in new issue
Block a user