Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix internvl2.5 error after eviction #3122

Merged
merged 2 commits into from
Feb 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lmdeploy/vl/model/internvl.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,18 @@ def proc_messages(messages, chat_template, sequence_start):
prompt = chat_template.messages2prompt(prompt_messages, sequence_start)
return prompt, IMAGE_TOKEN

@staticmethod
def _update_image_token_id(messages, tokenizer):
"""update image_token_id."""
pad_token_id = getattr(tokenizer.model.model, 'pad_token_id', 0)
preps = [x['content'] for x in messages if x['role'] == 'preprocess']
for prep in preps:
for pp in prep:
pp['image_token_id'] = pad_token_id

def to_pytorch(self, messages, chat_template, tokenizer, sequence_start):
prompt, IMAGE_TOKEN = self.proc_messages(messages, chat_template, sequence_start)
self._update_image_token_id(messages, tokenizer)
return self.to_pytorch_aux(messages, prompt, IMAGE_TOKEN, tokenizer, sequence_start)

def to_turbomind(self, messages, chat_template, tokenizer, sequence_start):
Expand Down