Back off to ORTH without Vectors.attr

This commit is contained in:
Adriane Boyd 2023-05-12 19:51:21 +02:00
parent b44f94dafa
commit 79bd698b73

View File

@ -6,6 +6,7 @@ from thinc.util import partial
from thinc.types import Ragged, Floats2d, Floats1d, Ints1d
from thinc.api import Model, Ops, registry
from ..attrs import ORTH
from ..tokens import Doc
from ..errors import Errors, Warnings
from ..vectors import Mode
@ -44,7 +45,9 @@ def forward(
if not token_count:
return _handle_empty(model.ops, model.get_dim("nO"))
vocab: Vocab = docs[0].vocab
key_attr: int = vocab.vectors.attr
key_attr: int = ORTH
if hasattr(vocab.vectors, "attr"):
key_attr = vocab.vectors.attr
keys = model.ops.flatten([cast(Ints1d, doc.to_array(key_attr)) for doc in docs])
W = cast(Floats2d, model.ops.as_contig(model.get_param("W")))
if vocab.vectors.mode == Mode.default: