Code Monkey home page Code Monkey logo

Comments (3)

adrianeboyd avatar adrianeboyd commented on May 9, 2024 1

This sample code that only sources the single coref component wouldn't work correctly for spacy v3.6, either. It wouldn't raise an error, but the coref output would be gibberish because it doesn't have its own separate transformer component in the pipeline.

This particular error message can definitely be improved, though.

If you want to combine them, see this thread for how to either replace the listeners or run the two pipelines separately on the same doc: #12302 (comment)

from spacy.

shadeMe avatar shadeMe commented on May 9, 2024

Thanks for reporting this issue! We'll look into it.

In the meantime, you should be able to reinstall the latest version of spaCy after installing the experimental co-ref component: python -m pip install spacy -U. The dependency resolver error can be ignored in this case. Alternatively, you can manually edit the wheel to update the version pin.

from spacy.

Fohlen avatar Fohlen commented on May 9, 2024

Hi, I updated the version pin of the package and created a new wheel. When I run the following:

import spacy

nlp = spacy.load("en_core_web_trf")
nlp_coref = spacy.load("en_coreference_web_trf")
nlp.add_pipe("coref", source=nlp_coref)
sentences = nlp("my name is theodor and my wife's name is sandra")

I get:

/redacted/venv/lib/python3.10/site-packages/spacy_transformers/layers/hf_shim.py:137: UserWarning: Error loading saved torch state_dict with strict=True, likely due to differences between 'transformers' versions. Attempting to load with strict=False as a fallback...

If you see errors or degraded performance, download a newer compatible model or retrain your custom model with the current 'transformers' and 'spacy-transformers' versions. For more details and available updates, run: python -m spacy validate
  warnings.warn(warn_msg)
Traceback (most recent call last):
  File "/redacted/run.py", line 6, in <module>
    sentences = nlp("my name is theodor and my wife's name is sandra")
  File "/redacted/venv/lib/python3.10/site-packages/spacy/language.py", line 1054, in __call__
    error_handler(name, proc, [doc], e)
  File "/redacted/venv/lib/python3.10/site-packages/spacy/util.py", line 1704, in raise_error
    raise e
  File "/redacted/venv/lib/python3.10/site-packages/spacy/language.py", line 1049, in __call__
    doc = proc(doc, **component_cfg.get(name, {}))  # type: ignore[call-arg]
  File "spacy/pipeline/trainable_pipe.pyx", line 56, in spacy.pipeline.trainable_pipe.TrainablePipe.__call__
  File "/redacted/venv/lib/python3.10/site-packages/spacy/util.py", line 1704, in raise_error
    raise e
  File "spacy/pipeline/trainable_pipe.pyx", line 52, in spacy.pipeline.trainable_pipe.TrainablePipe.__call__
  File "/redacted/venv/lib/python3.10/site-packages/spacy_experimental/coref/coref_component.py", line 153, in predict
    scores, idxs = self.model.predict([doc])
  File "/redacted/venv/lib/python3.10/site-packages/thinc/model.py", line 334, in predict
    return self._func(self, X, is_train=False)[0]
  File "/redacted/venv/lib/python3.10/site-packages/thinc/layers/chain.py", line 54, in forward
    Y, inc_layer_grad = layer(X, is_train=is_train)
  File "/redacted/venv/lib/python3.10/site-packages/thinc/model.py", line 310, in __call__
    return self._func(self, X, is_train=is_train)
  File "/redacted/venv/lib/python3.10/site-packages/thinc/layers/chain.py", line 54, in forward
    Y, inc_layer_grad = layer(X, is_train=is_train)
  File "/redacted/venv/lib/python3.10/site-packages/thinc/model.py", line 310, in __call__
    return self._func(self, X, is_train=is_train)
  File "/redacted/venv/lib/python3.10/site-packages/spacy_transformers/layers/trfs2arrays.py", line 40, in forward
    if "last_hidden_state" in trf_data.model_output:
AttributeError: 'DocTransformerOutput' object has no attribute 'model_output'

This suggests that there are incompatibilities between the packages. However, simply running text through the nlp_coref object works, so this is likely an issue with the extensions rather than the model.

from spacy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.