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

Question: mean aggregation in Encoder #9

Open
yichengchen24 opened this issue Jan 3, 2025 · 0 comments
Open

Question: mean aggregation in Encoder #9

yichengchen24 opened this issue Jan 3, 2025 · 0 comments

Comments

@yichengchen24
Copy link

Thanks for the excellent work!

However, I have a question about the mean aggregation operation in Encoder: why divide by the length of the chunked sentence len(chunked_instances[index]) instead of the number that the sentence is chunked to?

The corresponding code is

# aggregate the embeddings
embeddings = np.zeros((len(sentences), self.hidden_size))
for i, index in enumerate(chunked_indices):
    if aggregate_method == 'mean':
        embeddings[index] += chunked_embeddings[i] / len(chunked_instances[index])
    elif aggregate_method == 'sum':
        embeddings[index] += chunked_embeddings[i]
    elif aggregate_method == 'max':
        embeddings[index] = np.maximum(embeddings[index], chunked_embeddings[i])
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

1 participant