Skip to content

Commit f067de7

Browse files
committed
Extend to transformers v4.25 (#360)
* Extend to transformers v4.25 * Update serialization test for transformers v4.25
1 parent 7e8efc9 commit f067de7

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
spacy>=3.4.0,<4.0.0
2-
transformers>=3.4.0,<4.25.0
2+
transformers>=3.4.0,<4.26.0
33
torch>=1.6.0
44
srsly>=2.4.0,<3.0.0
55
dataclasses>=0.6,<1.0; python_version < "3.7"

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ include_package_data = true
3232
python_requires = >=3.6
3333
install_requires =
3434
spacy>=3.4.0,<4.0.0
35-
transformers>=3.4.0,<4.25.0
35+
transformers>=3.4.0,<4.26.0
3636
torch>=1.6.0
3737
srsly>=2.4.0,<3.0.0
3838
dataclasses>=0.6,<1.0; python_version < "3.7"

spacy_transformers/tests/test_serialize.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,12 @@ def test_transformer_pipeline_todisk_settings():
116116
assert trf.model.transformer.config.output_attentions is False
117117
assert "attentions" not in nlp("test")._.trf_data.model_output
118118
# modify model_max_length (note that modifications to
119-
# tokenizer.model_max_length are not serialized by save_pretrained
120-
# see: https://github.com/explosion/spaCy/discussions/7393)
119+
# tokenizer.model_max_length for transformers<4.25 are not serialized by
120+
# save_pretrained, see: https://github.com/explosion/spaCy/discussions/7393)
121121
trf.model.tokenizer.init_kwargs["model_max_length"] = 499
122+
# transformer>=4.25, model_max_length is saved and init_kwargs changes are
123+
# clobbered, so do both for this test
124+
trf.model.tokenizer.model_max_length = 499
122125
# add attentions on-the-fly
123126
trf.model.transformer.config.output_attentions = True
124127
assert nlp("test")._.trf_data.model_output.attentions is not None

0 commit comments

Comments
 (0)