pythonnlpembeddingword-embeddingelmo

`Highway.forward: input must be present` in ELMo embedding?


I use Elmo Embeddings for my NLP task. The pretrain was in the Indonesian language from this git. Importing the library by using the syntax

from elmoformanylangs import Embedder

causing the following error:

TypeError: Highway.forward: input must be present

Please help me to understand what the error message means.


Solution

  • Not sure if this helps, but this refers to the unimplemented superclass method (forward) in torch.nn.Module. This class has the following definiton.

    forward: Callable[..., Any] = _forward_unimplemented

    If you scroll down a bit you will see the definiton of _forward_unimplemented:

    def _forward_unimplemented(self, *input: Any) -> None:
    

    The Highway forward definiton has to match this signature too, therefore you will need a *input argument too. I got my Hungarian version working with the following signature and first line, probably this could help you too.

        def forward(self, *input: torch.Tensor) -> type(None): #pylint: disable=arguments-differ
        current_input = input[0]
    

    I just edited my \elmoformanylangs\modules\highway.py file under the site-packages of my python environment, and got it working.