Skip to content

Confusion about the relative position embedding with attn_type='bi' but bsz=1 #12

@NotANumber124

Description

@NotANumber124

The default setting is to use the bidirectional data, attn_type='bi', but bsz=1.
But in this function,

def relative_positional_encoding(self, qlen, klen, d_model, clamp_len, attn_type,

It shows the bidirectional data only works when bsz%2 ==0. However in default, bsz = 1.
I am confused, if bsz=1, the setting for the beg, and end in the following code, is it right?

xlnet-Pytorch/xlnet.py

Lines 380 to 387 in cb793a1

if attn_type == 'bi':
# beg, end = klen - 1, -qlen
beg, end = klen, -qlen
elif attn_type == 'uni':
# beg, end = klen - 1, -1
beg, end = klen, -1
else:
raise ValueError('Unknown `attn_type` {}.'.format(attn_type))

Could anyone help me with this confusion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions