( input_ids: typing.Optional[torch.Tensor] = None,
attention_mask: typing.Optional[torch.Tensor] = None,
token_type_ids: typing.Optional[torch.Tensor] = None,
position_ids: typing.Optional[torch.Tensor] = None,
head_mask: typing.Optional[torch.Tensor] = None,
inputs_embeds: typing.Optional[torch.Tensor] = None,
labels: typing.Optional[torch.Tensor] = None,
next_sentence_label: typing.Optional[torch.Tensor] = None,
output_attentions: typing.Optional[bool] = None,
output_hidden_states: typing.Optional[bool] = None,
return_dict: typing.Optional[bool] = None )
bert模型的输入参数,具体的参数信息可以从官网中查询到
这里重点关注一下position_ids这个参数,这个参数是个可选参数,可以自定义位置参数也可以不输入,但是值得注意的是,如果没有位置ID传递给模型,则ID将自动创建为绝对位置嵌入。即 0,1,2……SentenceLength。