Skip to content

Commit bf82af9

Browse files
committed
Fix token length
1 parent da0605f commit bf82af9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

conditioner.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1728,6 +1728,8 @@ struct LLMEmbedder : public Conditioner {
17281728
std::vector<std::pair<int, ggml_tensor*>> image_embeds;
17291729
std::pair<int, int> prompt_attn_range;
17301730
int prompt_template_encode_start_idx = 34;
1731+
int max_length = 0;
1732+
bool pad = false;
17311733
std::set<int> out_layers;
17321734
if (llm->enable_vision && conditioner_params.ref_images.size() > 0) {
17331735
LOG_INFO("QwenImageEditPlusPipeline");
@@ -1828,6 +1830,8 @@ struct LLMEmbedder : public Conditioner {
18281830
} else if (sd_version_is_longcat(version)) {
18291831
prompt_template_encode_start_idx = 36;
18301832
// prompt_template_encode_end_idx = 5;
1833+
max_length = 512;
1834+
pad = true;
18311835

18321836
prompt = "<|im_start|>system\nAs an image captioning expert, generate a descriptive text prompt based on an image content, suitable for input to a text-to-image model.<|im_end|>\n<|im_start|>user\n";
18331837

@@ -1848,7 +1852,7 @@ struct LLMEmbedder : public Conditioner {
18481852
prompt += "<|im_end|>\n<|im_start|>assistant\n";
18491853
}
18501854

1851-
auto tokens_and_weights = tokenize(prompt, prompt_attn_range, 0, false);
1855+
auto tokens_and_weights = tokenize(prompt, prompt_attn_range, max_length, pad);
18521856
auto& tokens = std::get<0>(tokens_and_weights);
18531857
auto& weights = std::get<1>(tokens_and_weights);
18541858

0 commit comments

Comments
 (0)