Skip to content

Commit b33c312

Browse files
committed
mtmd : fix glm-edge redundant token count
1 parent e291450 commit b33c312

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

examples/llava/mtmd.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,6 @@ int32_t mtmd_tokenize(mtmd_context * ctx,
203203
}
204204

205205
// llava-1.5, llava-1.6, Yi-VL, Yi-34B, granite: don't need to add prefix and suffix
206-
// for glm-edge, we don't need to add because the tokens are already in the returned embeddings
207-
208-
// TODO @ngxson : glm-edge : remove BOI / EOI tokens embeddings, decode them as normal tokens
209206

210207
std::vector<std::string> parts = string_split_str(prompt_modified, ctx->image_marker);
211208
output.clear();
@@ -246,7 +243,7 @@ int32_t mtmd_tokenize(mtmd_context * ctx,
246243
};
247244

248245
for (const auto & part : parts) {
249-
//printf("tokenizing part: %s\n", part.c_str());
246+
// printf("tokenizing part: %s\n", part.c_str());
250247
bool add_bos = &parts.front() == &part;
251248
auto tokens = mtmd_tokenize_text_internal(vocab, part, text.add_special && add_bos, text.parse_special);
252249
if (tokens.empty()) {
@@ -338,11 +335,6 @@ int32_t mtmd_tokenize(mtmd_context * ctx,
338335
LOG_DBG("image_tokens->ny = %d\n", image_tokens->ny);
339336
LOG_DBG("batch_f32 size = %d\n", (int)image_tokens->batch_f32.entries.size());
340337

341-
if (clip_is_glm(ctx->ctx_clip)) {
342-
// glm-edge
343-
image_tokens->nx += 2; // add 2 for the begin_of_image and end_of_image token embeddings
344-
}
345-
346338
mtmd_input_chunk chunk{
347339
MTMD_INPUT_CHUNK_TYPE_IMAGE,
348340
{},

examples/llava/tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ add_test "llama-mtmd-cli" "ggml-org/SmolVLM2-2.2B-Instruct-GGUF:Q4_K_M"
4747
add_test "llama-mtmd-cli" "ggml-org/SmolVLM2-500M-Video-Instruct-GGUF:Q8_0"
4848
add_test "llama-mtmd-cli" "ggml-org/gemma-3-4b-it-GGUF:Q4_K_M"
4949
add_test "llama-mtmd-cli" "guinmoon/MobileVLM-3B-GGUF:Q4_K_M" "deepseek"
50-
add_test "llama-mtmd-cli" "THUDM/glm-edge-v-5b-gguf:Q4_K_M"
50+
add_test "llama-mtmd-cli" "THUDM/glm-edge-v-5b-gguf:Q4_K_M" "chatglm4"
5151
add_test "llama-mtmd-cli" "second-state/Llava-v1.5-7B-GGUF:Q2_K" "vicuna"
5252
add_test "llama-mtmd-cli" "cjpais/llava-1.6-mistral-7b-gguf:Q3_K" "vicuna"
5353
add_test "llama-mtmd-cli" "ibm-research/granite-vision-3.2-2b-GGUF:Q4_K_M"

0 commit comments

Comments
 (0)