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

Pooling question #14

Open
milyenpabo opened this issue Jun 21, 2023 · 1 comment
Open

Pooling question #14

milyenpabo opened this issue Jun 21, 2023 · 1 comment

Comments

@milyenpabo
Copy link

milyenpabo commented Jun 21, 2023

I'm running some tests with StarEncoder, and I'm using your code as a starting point. When returning an embedding, you pool input token embeddings into a single vector in here:

def pooling(x: torch.Tensor, mask: torch.Tensor) -> torch.Tensor:

As I read the code, you simply pick the last valid (non-masked) token's embedding as the pooled embedding vector for the entire sequence. This should be the vector corresponding to the <sep> separator token, if I get it correctly.

Can you explain why you do this? Is this something similar to CLS-pooling from BERT? Do you think this leads to better results than other approaches (e.g., mean-pooling)?

@joaomonteirof
Copy link
Collaborator

Hello! yes, you did get it correctly and we take the output at the [SEP] in the end of the input as an embedding. Besides that, I tried both the output at [CLS] as well as mean pooling without special tokens. The output at [SEP] was the best performing approach by far in a code-to-code search task, so that's why it was kept. However, given a new task, I would try at least those three approaches and compares results.

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

2 participants