Skip to content

Commit ea2fbb8

Browse files
committed
output text but gibberish
1 parent ddfaca7 commit ea2fbb8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

tools/mtmd/clip.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ struct clip_graph {
11711171
{
11721172
// SiglipMultiheadAttentionPoolingHead
11731173
int64_t n_pos = cur->ne[1];
1174-
ggml_tensor * Qcur = model.mm_model_query;
1174+
ggml_tensor * Qcur = ggml_repeat(ctx0, model.mm_model_query, cur);
11751175
ggml_tensor * Kcur = cur;
11761176
ggml_tensor * Vcur = cur;
11771177

@@ -3731,7 +3731,9 @@ bool clip_image_preprocess(struct clip_ctx * ctx, const clip_image_u8 * img, str
37313731
res_imgs->entries.push_back(std::move(img_f32));
37323732
return true;
37333733

3734-
} else if (ctx->proj_type() == PROJECTOR_TYPE_PIXTRAL) {
3734+
} else if (ctx->proj_type() == PROJECTOR_TYPE_PIXTRAL
3735+
|| ctx->proj_type() == PROJECTOR_TYPE_PADDLEOCR
3736+
) {
37353737
clip_image_u8 resized_image;
37363738
auto new_size = image_manipulation::calc_size_preserved_ratio(original_size, params.patch_size, params.image_size);
37373739
image_manipulation::bilinear_resize(*img, resized_image, new_size.width, new_size.height);

tools/mtmd/mtmd-cli.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ struct mtmd_cli_context {
8585

8686
int n_threads = 1;
8787
llama_pos n_past = 0;
88+
bool use_jinja = false;
8889

8990
mtmd_cli_context(common_params & params) : llama_init(common_init_from_params(params)) {
9091
model = llama_init.model.get();
@@ -108,6 +109,7 @@ struct mtmd_cli_context {
108109
}
109110

110111
tmpls = common_chat_templates_init(model, params.chat_template);
112+
use_jinja = params.use_jinja;
111113
LOG_INF("%s: chat template example:\n%s\n", __func__, common_chat_format_example(tmpls.get(), params.use_jinja, params.default_template_kwargs).c_str());
112114

113115
init_vision_context(params);
@@ -200,7 +202,7 @@ static int eval_message(mtmd_cli_context & ctx, common_chat_msg & msg, bool add_
200202
common_chat_templates_inputs tmpl_inputs;
201203
tmpl_inputs.messages = {msg};
202204
tmpl_inputs.add_generation_prompt = true;
203-
tmpl_inputs.use_jinja = false; // jinja is buggy here
205+
tmpl_inputs.use_jinja = ctx.use_jinja;
204206
auto formatted_chat = common_chat_templates_apply(ctx.tmpls.get(), tmpl_inputs);
205207
LOG_DBG("formatted_chat.prompt: %s\n", formatted_chat.prompt.c_str());
206208

0 commit comments

Comments
 (0)