Pipeline component for named entity linking and disambiguation
/api/pipe
entity_linker
true
Config and implementation
The default config is defined by the pipeline component factory and describes
how the component should be configured. You can override its settings via the
config argument on nlp.add_pipe or in your
config.cfg for training. See the
model architectures documentation for details on the
architectures and their arguments and hyperparameters.
# Construction via add_pipe with default modelentity_linker=nlp.add_pipe("entity_linker")# Construction via add_pipe with custom modelconfig={"model":{"@architectures":"my_el"}}entity_linker=nlp.add_pipe("entity_linker",config=config)# Construction from classfromspacy.pipelineimportEntityLinkerentity_linker=EntityLinker(nlp.vocab,model)
Create a new pipeline instance. In your application, you would normally use a
shortcut for this and instantiate the component using its string name and
nlp.add_pipe.
String name of the component instance. Used to add entries to the losses during training.
keyword-only
kb
KnowlegeBase
labels_discard
Iterable[str]
incl_prior
bool
incl_context
bool
EntityLinker.__call__
Apply the pipe to one document. The document is modified in place, and returned.
This usually happens under the hood when the nlp object is called on a text
and all pipeline components are applied to the Doc in order. Both
__call__ and pipe
delegate to the predict and
set_annotations methods.
Example
doc=nlp("This is a sentence.")entity_linker=nlp.add_pipe("entity_linker")# This usually happens under the hoodprocessed=entity_linker(doc)
Name
Type
Description
doc
Doc
The document to process.
RETURNS
Doc
The processed document.
EntityLinker.pipe
Apply the pipe to a stream of documents. This usually happens under the hood
when the nlp object is called on a text and all pipeline components are
applied to the Doc in order. Both __call__ and
pipe delegate to the
predict and
set_annotations methods.
Processed documents in the order of the original text.
EntityLinker.begin_training
Initialize the pipe for training, using data examples if available. Returns an
Optimizer object. Before calling this
method, a knowledge base should have been defined with
set_kb.
Apply the pipeline's model to a batch of docs, without modifying them. Returns
the KB IDs for each entity in each doc, including NIL if there is no
prediction.
During serialization, spaCy will export several data fields used to restore
different aspects of the object. If needed, you can exclude them from
serialization by passing in the string names via the exclude argument.