Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mean vs identity pooling? #15

Open
vr25 opened this issue Nov 2, 2020 · 4 comments
Open

mean vs identity pooling? #15

vr25 opened this issue Nov 2, 2020 · 4 comments

Comments

@vr25
Copy link

vr25 commented Nov 2, 2020

Hi,

The paper describes four pooling functions: 1. Mean, 2. Identity, 3. Transformer, and 4. LSTM.

I am confused between mean and identity. I follow that mean means simply average all the [CLS] embeddings for all the chunks which would result in a final [768] -dimensional vector. In this way, how would identity function work? Does it mean concatenating all [CLS] vectors and if so, wouldn't it turn into a very long vector like: number of chunks x 768 ?

Any help in understanding this concept would be appreciated!

Thanks!

@AndriyMulyar
Copy link
Owner

AndriyMulyar commented Nov 2, 2020 via email

@vr25
Copy link
Author

vr25 commented Nov 2, 2020

So in your case, it would be 20 x 768? (since max # chunks = 20)?

@n8henrie
Copy link

n8henrie commented Apr 29, 2021

I'm also confused.

This paper references this repo as its source code and refers to the four models noted above: 1. Mean, 2. Identity, 3. Transformer, and 4. LSTM.

However, in the code, I see LSTM and Transformer, but instead of Mean and Identity, I see Linear and MaxPool: https://github.com/AndriyMulyar/bert_document_classification/blob/572883204cb1aca50d346979319905f698ad7049/bert_document_classification/document_bert_architectures.py

It looks like the Linear model matches the description of the Identity (reshaping output into a concatenation of CLS via bert_output.view(bert_output.shape[0], -1)).

But MaxPool looks to be doing something totally different than what is described: bert_output.max(dim=1)[0] vs A dimension-wise mean over all CLS embeddings.

@AndriyMulyar thank you very much for providing your code. I'm a novice here -- is there something I'm missing?

EDIT: I think it's also worth noting that the Mean model was the top performer in the paper, so it seems odd to have a different implementation here than what is described.

@AndriyMulyar
Copy link
Owner

Hi, the public codebase just hasn't been updated. You can change the pooling from max to mean in the implementation to replicate the stated results in the paper.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants