FlagEmbedding icon indicating copy to clipboard operation
FlagEmbedding copied to clipboard

bge-rerank模型的tokenizer,

Open NLPJCL opened this issue 1 year ago • 1 comments

请问下,我加载bge-rerank模型的tokenizer,下面的代码解析出来的如下:

    query='中国人你好'
    title='你好中国人'
    res=tokenizer.encode_plus(
            query, 
            title,
            add_special_tokens=True,
            max_length=512,
            # padding='max_length',
            truncation=True,
            # return_token_type_ids=True,
            return_tensors='pt'
        )

{'input_ids': tensor([[ 0, 6, 75224, 124084, 2, 2, 6, 124084, 75224, 2]]), 'attention_mask': tensor([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]])} 没有返回token_type_ids。而我用bgev1.05的tokenizer,上面的代码解析出来的如下: {'input_ids': tensor([[ 101, 704, 1744, 782, 872, 1962, 102, 872, 1962, 704, 1744, 782, 102]]), 'token_type_ids': tensor([[0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]]), 'attention_mask': tensor([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]])}

请问下是否符合预期?bge-rerank模型forward的时候,没有传递token_type_ids。

NLPJCL avatar Feb 04 '24 07:02 NLPJCL

是正常的,xlm-roberta模型就只有一个type_ids:https://huggingface.co/FacebookAI/xlm-roberta-large/blob/main/config.json

staoxiao avatar Feb 04 '24 11:02 staoxiao