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

Changing XLNet default from not using memories to 512 context size following paper #8417

Merged
merged 4 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 1 addition & 14 deletions src/transformers/configuration_xlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# limitations under the License.
""" XLNet configuration """

import warnings

from .configuration_utils import PretrainedConfig
from .utils import logging

Expand Down Expand Up @@ -144,7 +142,7 @@ def __init__(
initializer_range=0.02,
layer_norm_eps=1e-12,
dropout=0.1,
mem_len=None,
mem_len=512,
reuse_len=None,
bi_data=False,
clamp_len=-1,
Expand Down Expand Up @@ -198,17 +196,6 @@ def __init__(
self.pad_token_id = pad_token_id
self.eos_token_id = eos_token_id

if mem_len is None or mem_len == 0:
warnings.warn(
"This config doesn't use attention memories, a core feature of XLNet."
" Consider setting `mem_len` to a non-zero value, for example "
"`xlnet = XLNetLMHeadModel.from_pretrained('xlnet-base-cased'', mem_len=1024)`,"
" for accurate training performance as well as an order of magnitude faster inference."
" Starting from version 3.5.0, the default parameter will be 1024, following"
" the implementation in https://arxiv.org/abs/1906.08237",
FutureWarning,
)

@property
def max_position_embeddings(self):
return -1
Expand Down
3 changes: 1 addition & 2 deletions src/transformers/modeling_xlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
"""
PyTorch XLNet model.
"""


from dataclasses import dataclass
from typing import List, Optional, Tuple

Expand Down Expand Up @@ -1087,6 +1085,7 @@ def forward(
output_hidden_states=None,
return_dict=None,
):

output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
output_hidden_states = (
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
Expand Down