import json
from transformers import LlamaTokenizer
class MiniCPMVTokenizer(LlamaTokenizer):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.im_start = ""
self.im_end = ""
self.ref_start = "["
self.ref_end = "]"
self.box_start = ""
self.box_end = ""
self.quad_start = ""
self.quad_end = ""
self.point_start = ""
self.point_end = ""
self.slice_start = ""
self.slice_end = ""
@property
def eos_id(self):
return self.sp_model.eos_id()
@property
def bos_id(self):
return self.sp_model.bos_id()
@property
def unk_id(self):
return self.sp_model.unk_id()
@property
def im_start_id(self):
return self._convert_token_to_id(self.im_start)
@property
def im_end_id(self):
return self._convert_token_to_id(self.im_end)