server: use random media marker (#21962)

* server: use random media marker

* nits

* remove legacy <__image__> token

* revert special char in random
This commit is contained in:
Xuan-Son Nguyen 2026-04-15 23:52:22 +02:00 committed by GitHub
parent b3d758750a
commit 408225bb1a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 17 additions and 11 deletions

View file

@ -109,7 +109,7 @@ mtmd_context_params mtmd_context_params_default() {
/* use_gpu */ true,
/* print_timings */ true,
/* n_threads */ 4,
/* image_marker */ MTMD_DEFAULT_IMAGE_MARKER,
/* image_marker */ nullptr,
/* media_marker */ mtmd_default_marker(),
/* flash_attn_type */ LLAMA_FLASH_ATTN_TYPE_AUTO,
/* warmup */ true,
@ -169,7 +169,7 @@ struct mtmd_context {
media_marker (ctx_params.media_marker),
n_embd_text (llama_model_n_embd_inp(text_model))
{
if (std::string(ctx_params.image_marker) != MTMD_DEFAULT_IMAGE_MARKER) {
if (ctx_params.image_marker != nullptr) {
throw std::runtime_error("custom image_marker is not supported anymore, use media_marker instead");
}
@ -584,9 +584,6 @@ struct mtmd_tokenizer {
parse_special = text->parse_special;
input_text = text->text;
vocab = llama_model_get_vocab(ctx->text_model);
// for compatibility, we convert image marker to media marker
string_replace_all(input_text, MTMD_DEFAULT_IMAGE_MARKER, ctx->media_marker);
}
int32_t tokenize(mtmd_input_chunks * output) {