From 77a2f2d5e7a296f1a800d3d761ad64705c4fa7ea Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 12 Aug 2019 11:19:26 +0000 Subject: [PATCH] Fix #32: Cannot save XLNet model --- examples/tasks/__init__.py | 0 spacy_pytorch_transformers/_tokenizers.py | 7 ++++--- 2 files changed, 4 insertions(+), 3 deletions(-) delete mode 100644 examples/tasks/__init__.py diff --git a/examples/tasks/__init__.py b/examples/tasks/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/spacy_pytorch_transformers/_tokenizers.py b/spacy_pytorch_transformers/_tokenizers.py index db30583c..087a7693 100644 --- a/spacy_pytorch_transformers/_tokenizers.py +++ b/spacy_pytorch_transformers/_tokenizers.py @@ -310,9 +310,10 @@ def blank(cls): return self def prepare_for_serialization(self): - vocab_path = Path(self.vocab_file) - with vocab_path.open("rb") as f: - self.vocab_bytes = f.read() + if hasattr(self, "vocab_file"): + vocab_path = Path(self.vocab_file) + with vocab_path.open("rb") as f: + self.vocab_bytes = f.read() def finish_deserializing(self): self.sp_model = sentencepiece.SentencePieceProcessor()