Skip to content

Commit

Permalink
[Fix] Fix num_beams for MiniCPM-o-2_6 (#745)
Browse files Browse the repository at this point in the history
Co-authored-by: Poppy Xu <[email protected]>
  • Loading branch information
lihytotoro and Poppy Xu authored Jan 23, 2025
1 parent f8279c8 commit 060e8fd
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions vlmeval/vlm/minicpm_v.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, model_path='openbmb/MiniCPM-V', **kwargs):
self.kwargs = kwargs
self.tokenizer = AutoTokenizer.from_pretrained(self.model_path, trust_remote_code=True)
torch.cuda.empty_cache()
self.num_beams = 1 if self.model_path == 'openbmb/MiniCPM-V' else 3
self.num_beams = 3

def use_custom_prompt(self, dataset):
assert dataset is not None
Expand Down Expand Up @@ -106,7 +106,7 @@ def __init__(self, model_path='openbmb/MiniCPM-Llama3-V-2_5', **kwargs):
self.kwargs = kwargs
self.tokenizer = AutoTokenizer.from_pretrained(self.model_path, trust_remote_code=True)
torch.cuda.empty_cache()
self.num_beams = 1 if self.model_path == 'openbmb/MiniCPM-V' else 3
self.num_beams = 3
self.options_system_prompt = ('Carefully read the following question and select the letter corresponding '
'to the correct answer. Highlight the applicable choices without giving '
'explanations.')
Expand Down Expand Up @@ -277,7 +277,7 @@ def __init__(self, model_path='openbmb/MiniCPM-V-2_6', **kwargs):
self.kwargs = kwargs
self.tokenizer = AutoTokenizer.from_pretrained(self.model_path, trust_remote_code=True)
torch.cuda.empty_cache()
self.num_beams = 1 if self.model_path == 'openbmb/MiniCPM-V-2_6' else 3
self.num_beams = 3

self.options_suffix_prompt = '''\nAnswer with the option's letter from the given choices directly.'''
self.wo_options_system_prompt = 'Carefully read the following question Answer the question directly.'
Expand Down Expand Up @@ -502,8 +502,7 @@ def __init__(self, model_path='openbmb/MiniCPM-o-2_6', **kwargs):
self.tokenizer = AutoTokenizer.from_pretrained(self.model_path, trust_remote_code=True)
torch.cuda.empty_cache()

num_beams = int(os.getenv("NUM_BEAMS", "3"))
self.num_beams = 1 if self.model_path == 'openbmb/MiniCPM-o-2_6' else num_beams
self.num_beams = int(os.getenv("NUM_BEAMS", "3"))

repetition_penalty = float(os.getenv("PENALTY", "1.2"))
self.repetition_penalty = repetition_penalty
Expand Down

0 comments on commit 060e8fd

Please sign in to comment.