GLiNERGrounder
- class GLiNERGrounder(matcher: Matcher[R], *, model: str | gliner.GLiNER | None = None, labels: list[str], threshold: float | None = None)[source]
Bases:
Grounder[R],WrappedMatcher[R],Generic[R]An annotator that works via
gliner.Create a grounder based on a pre-defined matcher and a
glinerNER model.- Parameters:
matcher – A pre-defined matcher
model – The name of a
glinermodel. See here for a list of models. If not given, defaults toGLINER_DEFAULT.labels –
The labels for entity types.
Warning
These aren’t specifically defined anywhere in the GLiNER docs, so you’ll have to experiment with them
threshold – The score threshold for predictions. Defaults to 0.5 if not given.
In the following example, a GLiNER grounder is instantiated using an underlying Gilda matcher, which incorporates the disease branch of Medical Subject Headings (MeSH).
import spacy from ssslm import GildaMatcher, GLiNERGrounder matcher = GildaMatcher.default() grounder = GLiNERGrounder( matcher=matcher, model="urchade/gliner_medium-v2.1", labels=["disease", "protein", "gene"], ) annotations = grounder.annotate( "The APOE e4 mutation is correlated with risk for Alzheimer's disease." )
Methods Summary
annotate(text, **kwargs)Annotate the text the GLiNER annotator and the wrapped matcher.
Methods Documentation