allenai / allennlp

An open-source NLP research library, built on PyTorch.
http://www.allennlp.org
Apache License 2.0
11.74k stars 2.24k forks source link

Textual Entailment fails in AllenNLP Demo when using master #3091

Closed schmmd closed 5 years ago

schmmd commented 5 years ago

If you change the allennlp-demo Dockerfile to FROM allennlp/commit:417a75727d4604e1da0eda461b03b29a73f0bf50 (master as of today), build, and run then textual entailment fails with the following exception:

{"message": "loading textual-entailment model", "severity": "INFO"}
100%|██████████| 697657697/697657697 [03:49<00:00, 3041795.36B/s] 
Did not use initialization regex that was passed: .*token_embedder_tokens\._projection.*weight
Traceback (most recent call last):
  File "./app.py", line 432, in <module>
    models=models)
  File "./app.py", line 93, in main
    app = make_app(build_dir=f"{demo_dir}/build", demo_db=demo_db, models=models)
  File "./app.py", line 130, in make_app
    app.attackers[name]["hotflip"].initialize()
  File "/usr/local/lib/python3.6/site-packages/allennlp/interpret/attackers/hotflip.py", line 38, in initialize
    self.token_embedding = self._construct_embedding_matrix()
  File "/usr/local/lib/python3.6/site-packages/allennlp/interpret/attackers/hotflip.py", line 79, in _construct_embedding_matrix
    embedding_matrix = embedder(all_inputs).squeeze()
  File "/usr/local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/allennlp/modules/text_field_embedders/basic_text_field_embedder.py", line 87, in forward
    raise ConfigurationError(message)
allennlp.common.checks.ConfigurationError: "Your text field is generating more keys (['tokens', 'elmo']) than you have token embedders (['elmo']. If you are using a token embedder that requires multiple keys (for example, the OpenAI Transformer embedder or the BERT embedder) you need to add allow_unmatched_keys = True (and likely an embedder_to_indexer_map) to your BasicTextFieldEmbedder configuration. Otherwise, you should check that there is a 1:1 embedding between your token indexers and token embedders."
schmmd commented 5 years ago

I first had this problem inside Docker and later repro'd it with conda.

schmmd commented 5 years ago

This is specific to https://github.com/allenai/allennlp-demo/pull/219. Closing since it's not necessarily an issue on the main repository.