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

Use built-in version parsing from packaging #3502

Merged
merged 1 commit into from
Aug 9, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions flair/embeddings/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import torch
import transformers
from semver import Version
from packaging.version import Version
from torch.jit import ScriptModule
from transformers import (
CONFIG_MAPPING,
Expand Down Expand Up @@ -1222,7 +1222,7 @@ def embedding_length(self) -> int:
def _load_from_state_dict(
self, state_dict, prefix, local_metadata, strict, missing_keys, unexpected_keys, error_msgs
):
if transformers.__version__ >= Version(4, 31, 0):
if Version(transformers.__version__) >= Version("4.31.0"):
assert isinstance(state_dict, dict)
state_dict.pop(f"{prefix}model.embeddings.position_ids", None)
super()._load_from_state_dict(
Expand Down Expand Up @@ -1307,7 +1307,7 @@ def __setstate__(self, state):
self.__dict__[key] = embedding.__dict__[key]

if model_state_dict:
if transformers.__version__ >= Version(4, 31, 0):
if Version(transformers.__version__) >= Version("4.31.0"):
model_state_dict.pop("embeddings.position_ids", None)
self.model.load_state_dict(model_state_dict)

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ tqdm>=4.63.0
transformer-smaller-training-vocab>=0.2.3
transformers[sentencepiece]>=4.18.0,<5.0.0
wikipedia-api>=0.5.7
semver<4.0.0,>=3.0.0
bioc<3.0.0,>=2.0.0
Loading