Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Commit f0ae9f3

Browse files
authored
Adding tokenizer_kwargs argument to PretrainedTransformerBackbone constructor. (#4944)
1 parent 501b0ab commit f0ae9f3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12-
- Added `transformer_kwargs` argument to `PretrainedTransformerBackbone`
12+
- Added `tokenizer_kwargs` and `transformer_kwargs` arguments to `PretrainedTransformerBackbone`
1313

1414
## [v2.0.0](https://github.com/allenai/allennlp/releases/tag/v2.0.0) - 2021-01-27
1515

allennlp/modules/backbones/pretrained_transformer_backbone.py

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ class PretrainedTransformerBackbone(Backbone):
4747
When `True` (the default), only the final layer of the pretrained transformer is taken
4848
for the embeddings. But if set to `False`, a scalar mix of all of the layers
4949
is used.
50+
tokenizer_kwargs: `Dict[str, Any]`, optional (default = `None`)
51+
Dictionary with
52+
[additional arguments](https://github.com/huggingface/transformers/blob/155c782a2ccd103cf63ad48a2becd7c76a7d2115/transformers/tokenization_utils.py#L691)
53+
for `AutoTokenizer.from_pretrained`.
5054
transformer_kwargs: `Dict[str, Any]`, optional (default = `None`)
5155
Dictionary with
5256
[additional arguments](https://github.com/huggingface/transformers/blob/155c782a2ccd103cf63ad48a2becd7c76a7d2115/transformers/modeling_utils.py#L253)
@@ -72,6 +76,7 @@ def __init__(
7276
last_layer_only: bool = True,
7377
override_weights_file: Optional[str] = None,
7478
override_weights_strip_prefix: Optional[str] = None,
79+
tokenizer_kwargs: Optional[Dict[str, Any]] = None,
7580
transformer_kwargs: Optional[Dict[str, Any]] = None,
7681
output_token_strings: bool = True,
7782
vocab_namespace: str = "tags",
@@ -87,6 +92,7 @@ def __init__(
8792
last_layer_only=last_layer_only,
8893
override_weights_file=override_weights_file,
8994
override_weights_strip_prefix=override_weights_strip_prefix,
95+
tokenizer_kwargs=tokenizer_kwargs,
9096
transformer_kwargs=transformer_kwargs,
9197
)
9298
self._output_token_strings = output_token_strings

0 commit comments

Comments
 (0)