Skip to content

Commit e00e0ff

Browse files
authored
Merge pull request #3608 from flairNLP/add_compability_to_torch_2.6
add compatibility to torch 2.6
2 parents 005ec45 + 087b74e commit e00e0ff

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

flair/embeddings/document.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -691,10 +691,9 @@ def _add_embeddings_internal(self, sentences: list[Sentence]):
691691

692692
lengths: list[int] = [len(sentence.tokens) for sentence in sentences]
693693
padding_length: int = max(max(lengths), self.min_sequence_length)
694-
695694
pre_allocated_zero_tensor = torch.zeros(
696695
self.embeddings.embedding_length * padding_length,
697-
dtype=self.convs[0].weight.dtype,
696+
dtype=cast(torch.nn.Conv1d, self.convs[0]).weight.dtype,
698697
device=flair.device,
699698
)
700699

flair/embeddings/token.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ def _add_embeddings_internal(self, sentences: list[Sentence]) -> list[Sentence]:
14661466
word = token.text if self.field is None else token.get_label(self.field).value
14671467

14681468
if word.strip() == "":
1469-
ids = [self.spm.vocab_size(), self.embedder.spm.vocab_size()]
1469+
ids = [self.spm.vocab_size(), self.spm.vocab_size()]
14701470
else:
14711471
if self.do_preproc:
14721472
word = self._preprocess(word)

flair/file_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,4 +382,4 @@ def load_torch_state(model_file: str) -> dict[str, typing.Any]:
382382
# to load models on some Mac/Windows setups
383383
# see https://github.com/zalandoresearch/flair/issues/351
384384
f = load_big_file(model_file)
385-
return torch.load(f, map_location="cpu")
385+
return torch.load(f, map_location="cpu", weights_only=False)

flair/models/sequence_tagger_model.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,8 @@ def push_to_hub(
862862
self.save(local_model_path)
863863

864864
# Determine if model card already exists
865-
info = model_info(repo_id, use_auth_token=token)
866-
write_readme = all(f.rfilename != "README.md" for f in info.siblings)
865+
info = model_info(repo_id, token=token)
866+
write_readme = info.siblings is None or all(f.rfilename != "README.md" for f in info.siblings)
867867

868868
# Generate and save model card
869869
if write_readme:

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ scikit-learn>=1.0.2
1717
segtok>=1.5.11
1818
sqlitedict>=2.0.0
1919
tabulate>=0.8.10
20-
torch>=1.5.0,!=1.8
20+
torch>=1.13.1
2121
tqdm>=4.63.0
2222
transformer-smaller-training-vocab>=0.2.3
2323
transformers[sentencepiece]>=4.25.0,<5.0.0

0 commit comments

Comments
 (0)