palmtreemodel/PalmTree

ModuleNotFoundError: No module named 'bert_pytorch'

Closed this issue · 3 comments

First of all, thanks for the wonderful paper. I've been reading the paper since last night. But i encountered an issue when running

python how2use.py

It gives me the following error:

Loading Vocab ./palmtree/vocab
Traceback (most recent call last):
  File "how2use.py", line 11, in <module>
    palmtree = utils.UsableTransformer(model_path="./palmtree/transformer.ep19", vocab_path="./palmtree/vocab")
  File "/home/bob/PalmTree/eval_utils.py", line 59, in __init__
    self.vocab = vocab.WordVocab.load_vocab(vocab_path)
  File "/home/bob/PalmTree/vocab.py", line 167, in load_vocab
    return pickle.load(f)
ModuleNotFoundError: No module named 'bert_pytorch'

Can you tell me what did i miss? Thx.

That is because this project is based on a bert implementation called bert_pytorch. So when we train the model, the vocabulary was saved as <bert_pytorch.dataset.vocab.WordVocab> object.
The simplest way to fix this is pip install bert-pytorch
But if you wish to collect your own vocabulary and train a palmtree model based on our code. You do not need this library.
Sorry for the inconvenience.

Ah okay. Thanks for the response.

First, thanks for the ingenious model. I have this problem also when i change this model for myself dataset. However, i have an solution that I think will work.

ModuleNotFoundError: No module named 'bert_pytorch'
it is due to sys.path list lack of class modules of bert_pythorch when reading class instances stored in files.
So i add
import sys
sys.path.append('your/palmtree/root/path')
when pickle module is loaded.

First of all, thanks for the wonderful paper. I've been reading the paper since last night. But i encountered an issue when running

python how2use.py

It gives me the following error:

Loading Vocab ./palmtree/vocab
Traceback (most recent call last):
  File "how2use.py", line 11, in <module>
    palmtree = utils.UsableTransformer(model_path="./palmtree/transformer.ep19", vocab_path="./palmtree/vocab")
  File "/home/bob/PalmTree/eval_utils.py", line 59, in __init__
    self.vocab = vocab.WordVocab.load_vocab(vocab_path)
  File "/home/bob/PalmTree/vocab.py", line 167, in load_vocab
    return pickle.load(f)
ModuleNotFoundError: No module named 'bert_pytorch'

Can you tell me what did i miss? Thx.