Skip to content

Commit 77a2f2d

Browse files
committed
Fix #32: Cannot save XLNet model
1 parent 2675ef2 commit 77a2f2d

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

examples/tasks/__init__.py

Whitespace-only changes.

spacy_pytorch_transformers/_tokenizers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,10 @@ def blank(cls):
310310
return self
311311

312312
def prepare_for_serialization(self):
313-
vocab_path = Path(self.vocab_file)
314-
with vocab_path.open("rb") as f:
315-
self.vocab_bytes = f.read()
313+
if hasattr(self, "vocab_file"):
314+
vocab_path = Path(self.vocab_file)
315+
with vocab_path.open("rb") as f:
316+
self.vocab_bytes = f.read()
316317

317318
def finish_deserializing(self):
318319
self.sp_model = sentencepiece.SentencePieceProcessor()

0 commit comments

Comments
 (0)