Skip to content

Experimental CoreferenceResolver fails (KeyError: "Parameter 'E' for model 'hashembed' has not been allocated yet.") #11796

Description

@Jonathan-Buck

Hi, I was interested in seeing if the experimental CoreferenceResolver would work for a problem I'm trying to solve in one of my projects. I decided to start by copying the examples from the documentation page and encountered this error. Any insight is appriciated.

How to reproduce the behaviour

import spacy
nlp = spacy.load("en_core_web_sm")

doc = nlp("I eat chicken with rice.")
coref = nlp.add_pipe("experimental_coref")

# This usually happens under the hood
processed = coref(doc)

This snippet was found on the coref documentation page

Stacktrace:

Traceback (most recent call last):
  File "/Users/jon/Documents/Projects/mitre-parsing/coref.py", line 8, in <module>
    processed = coref(doc)
  File "spacy/pipeline/trainable_pipe.pyx", line 56, in spacy.pipeline.trainable_pipe.TrainablePipe.__call__
  File "/opt/homebrew/lib/python3.10/site-packages/spacy/util.py", line 1630, in raise_error
    raise e
  File "spacy/pipeline/trainable_pipe.pyx", line 52, in spacy.pipeline.trainable_pipe.TrainablePipe.__call__
  File "/opt/homebrew/lib/python3.10/site-packages/spacy_experimental/coref/coref_component.py", line 153, in predict
    scores, idxs = self.model.predict([doc])
  File "/opt/homebrew/lib/python3.10/site-packages/thinc/model.py", line 315, in predict
    return self._func(self, X, is_train=False)[0]
  File "/opt/homebrew/lib/python3.10/site-packages/thinc/layers/chain.py", line 54, in forward
    Y, inc_layer_grad = layer(X, is_train=is_train)
  File "/opt/homebrew/lib/python3.10/site-packages/thinc/model.py", line 291, in __call__
    return self._func(self, X, is_train=is_train)
  File "/opt/homebrew/lib/python3.10/site-packages/thinc/layers/chain.py", line 54, in forward
    Y, inc_layer_grad = layer(X, is_train=is_train)
  File "/opt/homebrew/lib/python3.10/site-packages/thinc/model.py", line 291, in __call__
    return self._func(self, X, is_train=is_train)
  File "/opt/homebrew/lib/python3.10/site-packages/thinc/layers/chain.py", line 54, in forward
    Y, inc_layer_grad = layer(X, is_train=is_train)
  File "/opt/homebrew/lib/python3.10/site-packages/thinc/model.py", line 291, in __call__
    return self._func(self, X, is_train=is_train)
  File "/opt/homebrew/lib/python3.10/site-packages/thinc/layers/with_array.py", line 30, in forward
    return _ragged_forward(
  File "/opt/homebrew/lib/python3.10/site-packages/thinc/layers/with_array.py", line 89, in _ragged_forward
    Y, get_dX = layer(Xr.dataXd, is_train)
  File "/opt/homebrew/lib/python3.10/site-packages/thinc/model.py", line 291, in __call__
    return self._func(self, X, is_train=is_train)
  File "/opt/homebrew/lib/python3.10/site-packages/thinc/layers/concatenate.py", line 44, in forward
    Ys, callbacks = zip(*[layer(X, is_train=is_train) for layer in model.layers])
  File "/opt/homebrew/lib/python3.10/site-packages/thinc/layers/concatenate.py", line 44, in <listcomp>
    Ys, callbacks = zip(*[layer(X, is_train=is_train) for layer in model.layers])
  File "/opt/homebrew/lib/python3.10/site-packages/thinc/model.py", line 291, in __call__
    return self._func(self, X, is_train=is_train)
  File "/opt/homebrew/lib/python3.10/site-packages/thinc/layers/chain.py", line 54, in forward
    Y, inc_layer_grad = layer(X, is_train=is_train)
  File "/opt/homebrew/lib/python3.10/site-packages/thinc/model.py", line 291, in __call__
    return self._func(self, X, is_train=is_train)
  File "/opt/homebrew/lib/python3.10/site-packages/thinc/layers/hashembed.py", line 61, in forward
    vectors = cast(Floats2d, model.get_param("E"))
  File "/opt/homebrew/lib/python3.10/site-packages/thinc/model.py", line 216, in get_param
    raise KeyError(
KeyError: "Parameter 'E' for model 'hashembed' has not been allocated yet."

Similar issues I found:
ner
morphologizer

Your Environment

Info about spaCy

  • spaCy version: 3.3.1
  • Platform: macOS-12.6-arm64-arm-64bit
  • Python version: 3.10.8
  • Pipelines: en_core_web_lg (3.3.0), en_core_web_sm (3.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation and website

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions