FlagOpen / FlagEmbedding

Retrieval and Retrieval-augmented LLMs
MIT License
7.19k stars 522 forks source link

bge-rerank模型的tokenizer, #446

Open NLPJCL opened 8 months ago

NLPJCL commented 8 months ago

请问下,我加载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。

staoxiao commented 8 months ago

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