spaCy icon indicating copy to clipboard operation
spaCy copied to clipboard

Doc.tensor into user_hooks

Open tamuhey opened this issue 5 years ago • 2 comments

I want to customize Doc.tensor property by user_hooks like Doc.vector, because sometimes calculation of the tensor is expensive (e.g. tok2vec pipe in spacy-transformers)

tamuhey avatar Oct 14 '19 14:10 tamuhey

Hi @tamuhey, sorry for the late follow-up! Looks like we lost track of this one. I think it should be doable to extend the user hooks to include a value for tensor. As far as I understand, we'd need to refactor tensor into a property instead of calling the value doc.tensor directly, and then you could consult user_hooks first, in a similar fashion as how it's done for doc.vector.

Is this still something you'd need? Do you feel like contributing a PR?

svlandeg avatar Apr 15 '20 22:04 svlandeg

I'll try to create PR for this issue

tamuhey avatar Apr 16 '20 11:04 tamuhey