Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not having any "vocab.txt" doesn't work when loading #9

Closed
Gyuyeong opened this issue May 3, 2023 · 1 comment
Closed

Not having any "vocab.txt" doesn't work when loading #9

Gyuyeong opened this issue May 3, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Gyuyeong
Copy link

Gyuyeong commented May 3, 2023

In the README file, it says the following:

One can also provide a vocab.txt/vocab.txt.gz file in the same directory: a one-word-per-line vocabulary of words to be cached (as character id representations) before inference. Even if it is not present at all, ELMo will still process all words normally. However, providing the vocabulary file can slightly increase inference speed when working with very large corpora (by reducing the amount of word to char ids conversions).

However, when I tried to load the model with the zip file it shows the following error:

KeyError Traceback (most recent call last)
Cell In[57], line 1
----> 1 model.load('./elmo-english.zip')

File ~\anaconda3\envs\python_old\lib\site-packages\simple_elmo\elmo_helpers.py:84, in ElmoModel.load(self, directory, max_batch_size, limit, full)
80 raise SystemExit(
81 "Error: loading models from ZIP archives requires Python >= 3.7."
82 )
83 zf = zipfile.ZipFile(directory)
---> 84 vocab_file = zf.read("vocab.txt").decode("utf-8")
85 options_file = zf.read("options.json").decode("utf-8")
86 weight_file = zf.open("model.hdf5")

File ~\anaconda3\envs\python_old\lib\zipfile.py:1475, in ZipFile.read(self, name, pwd)
1473 def read(self, name, pwd=None):
1474 """Return file bytes for name."""
-> 1475 with self.open(name, "r", pwd) as fp:
1476 return fp.read()

File ~\anaconda3\envs\python_old\lib\zipfile.py:1514, in ZipFile.open(self, name, mode, pwd, force_zip64)
1511 zinfo._compresslevel = self.compresslevel
1512 else:
1513 # Get info object for name
-> 1514 zinfo = self.getinfo(name)
1516 if mode == 'w':
1517 return self._open_to_write(zinfo, force_zip64=force_zip64)

File ~\anaconda3\envs\python_old\lib\zipfile.py:1441, in ZipFile.getinfo(self, name)
1439 info = self.NameToInfo.get(name)
1440 if info is None:
-> 1441 raise KeyError(
1442 'There is no item named %r in the archive' % name)
1444 return info

KeyError: "There is no item named 'vocab.txt' in the archive"

I used python version 3.8.16 in jupyter notebook. The function model.load() doesn't work when there is no 'vocab.txt' in the archive.

@akutuzov
Copy link
Member

akutuzov commented May 9, 2023

Fixed in the 0.9.2 release.
Thanks for the notification!

@akutuzov akutuzov self-assigned this May 9, 2023
@akutuzov akutuzov added the bug Something isn't working label May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants