Skip to content

Commit

Permalink
fix llama_vision chat_template and decode (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
coding-famer authored Jan 15, 2025
1 parent 50ed3ce commit f8fc141
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lmms_eval/models/llama_vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def generate_until(self, requests: List[Instance]) -> List[str]:
messages[-1]["content"].append({"type": "image"})
messages[-1]["content"].append({"type": "text", "text": contexts})
prompt = self.processor.apply_chat_template(messages, add_generation_prompt=True)
inputs = self.processor(images, prompt, return_tensors="pt").to(self.model.device)
inputs = self.processor(images, prompt, add_special_tokens=False, return_tensors="pt").to(self.model.device)

if "max_new_tokens" not in gen_kwargs:
gen_kwargs["max_new_tokens"] = 1024
Expand All @@ -208,7 +208,7 @@ def generate_until(self, requests: List[Instance]) -> List[str]:
do_sample=gen_kwargs["do_sample"],
)
output = output[:, inputs["input_ids"].shape[-1] :]
res.append(self.processor.decode(output[0]))
res.append(self.processor.decode(output[0], skip_special_tokens=True))

pbar.update(1)
pbar.close()
Expand Down

0 comments on commit f8fc141

Please sign in to comment.