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

How could I use word-level ELMO easily? #212

Open
ricky9123 opened this issue Jul 15, 2019 · 3 comments
Open

How could I use word-level ELMO easily? #212

ricky9123 opened this issue Jul 15, 2019 · 3 comments

Comments

@ricky9123
Copy link

ricky9123 commented Jul 15, 2019

It's easy to train a word-level ELMO by this repo, and I could remove char_cnn parameter to achieve this.

However, when I used this ELMO in allennlp, I found that it doesn't support word-level ELMO because it will always find the char_cnn parameter.

Did I have something wrong?

@ricky9123
Copy link
Author

Some key logs are following:

  File "/users4/bcwang/miniconda2/envs/py3/lib/python3.6/site-packages/allennlp/modules/token_embedders/elmo_token_embedder.py", line 128, in from_params
    scalar_mix_parameters=scalar_mix_parameters)
  File "/users4/bcwang/miniconda2/envs/py3/lib/python3.6/site-packages/allennlp/modules/token_embedders/elmo_token_embedder.py", line 65, in __init__
    scalar_mix_parameters=scalar_mix_parameters)
  File "/users4/bcwang/miniconda2/envs/py3/lib/python3.6/site-packages/allennlp/modules/elmo.py", line 110, in __init__
    vocab_to_cache=vocab_to_cache)
  File "/users4/bcwang/miniconda2/envs/py3/lib/python3.6/site-packages/allennlp/modules/elmo.py", line 524, in __init__
    self._token_embedder = _ElmoCharacterEncoder(options_file, weight_file, requires_grad=requires_grad)
  File "/users4/bcwang/miniconda2/envs/py3/lib/python3.6/site-packages/allennlp/modules/elmo.py", line 310, in __init__
    self._load_weights()
  File "/users4/bcwang/miniconda2/envs/py3/lib/python3.6/site-packages/allennlp/modules/elmo.py", line 398, in _load_weights
    self._load_char_embedding()
  File "/users4/bcwang/miniconda2/envs/py3/lib/python3.6/site-packages/allennlp/modules/elmo.py", line 405, in _load_char_embedding
    char_embed_weights = fin['char_embed'][...]
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "/users4/bcwang/miniconda2/envs/py3/lib/python3.6/site-packages/h5py/_hl/group.py", line 262, in __getitem__
    oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5o.pyx", line 190, in h5py.h5o.open
KeyError: "Unable to open object (object 'char_embed' doesn't exist)"

@ricky9123
Copy link
Author

ricky9123 commented Jul 15, 2019

And my ELMO config is:

{"bidirectional": true, "dropout": 0.1, "lstm": {"cell_clip": 3, "dim": 4096, "n_layers": 2, "proj_clip": 3, "projection_dim": 512, "use_skip_connections": true}, "all_clip_norm_val": 10.0, "n_epochs": 10, "n_train_tokens": 21150, "batch_size": 128, "n_tokens_vocab": 21150, "unroll_steps": 20, "n_negative_samples_batch": 8192}

@Pydataman
Copy link

allennlp use both word and char embedding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants