plug sense2vec it into your spaCy pipeline

Open
#141 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
python

Research direction

Start by reproducing the reported setup with spacy.load(), nlp.add_pipe("sense2vec"), and the initialize.components.sense2vec configuration. Compare the duplicate _s2v extension error with the later NoneType get_freq error when accessing doc spans. Done means the documented custom sense2vec pipeline loads and the reported frequency, vector, and similarity calls work.

Written by the indexing model from the issue text.

Description

I want to add my own sense2vec to my own spacy model, as you wrote in documentation,

I add that to my current pipeline

[initialize.components]

[initialize.components.sense2vec]
data_path = "/path/to/s2v"

then

nlp = spacy.load("../data/ModelV05b/model-best")
nlp.add_pipe("sense2vec")
s2v.from_disk("../data/S2VFasttextV04")

it does not work , since it says that

[E090] Extension '_s2v' already exists on Doc. To overwrite the existing extension, set `force=True` on `Doc.set_extension`.

since sense2vec is`in nlp.component_names

['tok2vec',
 'tagger',
 'parser',
 'ner',
 'attribute_ruler',
 'lemmatizer',
 'sense2vec']

then I changed to my model

nlp = spacy.load("../data/ModelV05b/model-best")

still it does not work and it says

doc = nlp2("The testimony of the ages confirms that the motions of the planets are orbicular.")
assert doc[1:2].text == "testimony"
freq = doc[1:2]._.s2v_freq
vector = doc[1:2]._.s2v_vec
most_similar = doc[1:2]._.s2v_most_similar(3)

and it says that

AttributeError: 'NoneType' object has no attribute 'get_freq'

Dominant language
Python
Stars
1.7k
Forks
236
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from explosion/sense2vec

All issues in explosion/sense2vec

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.