OpenCompass/opencompass/multimodal/models/qwen/post_processor.py
Yike Yuan b885ec84df
[Feat] Support Qwen-VL-Chat on MMBench. (#312)
* [Feat] Support Qwen-VL base.

* [Feat] Support Qwen-VL-Chat on MMBench.

* [Fix] Add postprocessor and fix format.

* [Fix] Add type hint and remove redundant codes.

* [Fix] fix bugs in postprocessor.

* [Fix] Use given commit id.
2023-09-06 18:42:19 +08:00

17 lines
408 B
Python

from typing import Any
import torch
class QwenVLBasePostProcessor:
"""Post processor for Qwen-VL-Base."""
def __init__(self) -> None:
pass
def __call__(self, pred: torch.tensor, tokenizer: Any,
input_len: int) -> str:
response = self.tokenizer.decode(pred)[input_len:]
response = response.replace('<|endoftext|>', '').strip()
return response