Skip to content

Commit

Permalink
Merge pull request #3502 from adrianeboyd/use-packaging-version
Browse files Browse the repository at this point in the history
Use built-in version parsing from packaging
  • Loading branch information
alanakbik authored Aug 9, 2024
2 parents e17ab12 + bc917ec commit 66cd3bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
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

0 comments on commit 66cd3bd

Please sign in to comment.