Skip to content

Commit e8bf564

Browse files
author
sangchengmeng
committed
fix tokens
1 parent c483b1e commit e8bf564

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lightllm/models/internvl/model.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ def get_image_token_length(self, img: ImageItem):
4747
def encode(self, prompt, multimodal_params: MultimodalParams = None, **kwargs):
4848
# TEXT<image>TEXT<image>TEXT --> TEXT<img></img>TEXT<img></img>TEXT
4949
image_tokens = IMG_START_TOKEN + IMG_END_TOKEN
50+
if multimodal_params is None:
51+
return self.tokenizer.encode(prompt, add_special_tokens=True)
5052
image_count = len(multimodal_params.images)
5153
prompt = prompt.replace(IMG_TOKEN, image_tokens, image_count)
5254

@@ -55,7 +57,7 @@ def encode(self, prompt, multimodal_params: MultimodalParams = None, **kwargs):
5557
input_ids = []
5658
image_id = 0
5759
start_idx = 0
58-
while True:
60+
while(multimodal_params):
5961
try:
6062
start_idx = origin_ids.index(self.image_start_id, start_idx)
6163
if start_idx + 1 >= len(origin_ids):

0 commit comments

Comments
 (0)