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

ELECTRA: use gelu for pooled output of ELECTRA model #364

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions farm/modeling/language_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1234,10 +1234,11 @@ def load(cls, pretrained_model_name_or_path, language=None, **kwargs):
# ELECTRA does not provide a pooled_output by default. Therefore, we need to initialize an extra pooler.
# The pooler takes the first hidden representation & feeds it to a dense layer of (hidden_dim x hidden_dim).
# We don't want a dropout in the end of the pooler, since we do that already in the adaptive model before we
# feed everything to the prediction head
# feed everything to the prediction head.
# Note: ELECTRA uses gelu as activation (BERT uses tanh instead)
config.summary_last_dropout = 0
config.summary_type = 'first'
config.summary_activation = 'tanh'
config.summary_activation = 'gelu'
electra.pooler = SequenceSummary(config)
electra.pooler.apply(electra.model._init_weights)
return electra
Expand Down