After creating an Arabic MultiFiT model (based on work by @pierreguillou ) , I tried to use it for inference. I can load the learner from the export.pkl file but when I try to predict, sentencepiece is called to encode the entry from a hardcoded path as “/root/.fastai/data/[wiki-path}/tmp/spm.model”. I can, of course, create this path locally and copy spm.model but not easy to deploy. I tried to pass the text as encoded by sp but did not work
How can I get around this? Here’s the error:
/usr/local/lib/python3.6/dist-packages/sentencepiece.py in Load(self, filename)
116
117 def Load(self, filename):
--> 118 return _sentencepiece.SentencePieceProcessor_Load(self, filename)
119
120 def LoadOrDie(self, filename):
OSError: Not found: "/root/.fastai/data/.../tmp/spm.model": No such file or directory Error #2
The SentencePiece training model is saved in cache_dir (an argument of SentencePieceTokenizer you can set to whatever you like). It’s very likely to save the absolute path when exporting the learner, I can check if we can save it as a relative path, which would probably be easier for deployment.
Thanks Sylvain. That would be great. I recall switching Fastai versions (to 1.0.57) when working on the databunch b/c of sp. For now, I got it to work through docker on Heroku and it seems to work fine. Not a great coder, but here’s what I did:
I am having the same problem but I want to use several inference learners at the same time. Moving different spm.model files around for each predict call seems not optimal.
Is there a way to set this path in the inference learner instance?
or
Is there a way to set this path before I export my model after training, that does not affect the export?