facebookresearch / GENRE

Autoregressive Entity Retrieval
Other
765 stars 103 forks source link

Question about encoder the sentences or entities when using Genre. #61

Closed Yuanhy1997 closed 2 years ago

Yuanhy1997 commented 3 years ago

To build my own trie, I first encode all the entities in my KB. When encoding, I used the following code like the code in the rebuilding trie issue:

Trie([2]+model.encode(entity.lower())[1:])

In my opinion, 2 stands for the 'eos' token, while in another issue, you said 2 stands for 'bos' token which is confusing. And another problem is, I do not understand why there is [1:], because in my application, the output of model.encode() is not prepended with any 'bos' or 'eos' token, its beginning is the bpe token of my input entity and the final token is '2'. Here is an example of the model.encode() output:

[ 4469, 29048, 19961, 29382, 13736, 36, 7779, 10337, 43, 2]

Can you please explain that?

nicola-decao commented 3 years ago

Can you please show me an example where this fails?

Yuanhy1997 commented 3 years ago

This does not fail, your code works fine, but I am confusing that how exactly your code works. In my opinion, when training the decoder inputs and labels are:

inputs: eos, bos, y1, y2,... labels: bos, y1, y2,..., eos

while in GENRE, I think it becomes

inputs: eos, y1, y2,... labels: y1, y2,..., eos

I dont know if I'm right. If so, can you please explain why this difference happens.

nicola-decao commented 3 years ago

I do not understand. If you are not sure if you are right what do you want me to answer? We used a pre-trained BART model, the encode and decode are the same as the original BART model.