Skip to main content
Span tagging: the interface a concept extractor can be built on, apart from the LLM.

ner.base

The span-tagger interface. Nothing here imports a model or an SDK.

NerError

The call cannot be answered: too many labels for the model, a model error, a bad input.

Span

SpanTagger

Finds labelled spans in text, with no generation. Construct with SpanTagger(*args, **kwargs).

ner.candidates

Spans as candidates: the join between a tagger and the extractor’s grounding.

spans_to_candidates

Candidate dicts (word, type, description, quote) with the shape of the extraction schema’s candidate.

ner.fake

A scripted tagger for tests: it finds the phrases it was given, under the labels it was given.

FakeSpanTagger

rules: label -> phrases to find (case-sensitive, every occurrence). Construct with FakeSpanTagger(rules: Mapping[str, Sequence[str]], *, labels_per_call: int \| None = None, max_chars: int \| None = None, score: float = 0.9).

ner.labels

Working with a tagger that carries few labels per call: split the labels, run each group, merge the spans.

arecognize_all

clashes

Whether two spans (end exclusive, in any unit: characters or words) cannot both be kept.

merge_spans

One list of spans that do not clash, from several lists (for example, one per group of labels).

recognize_all

tagger.recognize for any number of labels.

ner.litert_gliner

GLiNER as a LiteRT model on this machine: zero-shot NER (any labels you name, no training) from a .tflite, as a SpanTagger.

Encoded

LiteRtGliner

SpanTagger over a GLiNER .tflite. Construct with LiteRtGliner(tflite_path: str \| pathlib.Path, *, tokenizer: str \| pathlib.Path = 'gliner-community/gliner_small-v2.5', cache_dir: str \| pathlib.Path \| None = None, device: str = 'gpu', local_files_only: bool = False, encoder_kind: Literal['auto', 'tokenizers', 'gliner'] = 'auto', runtime: _Runtime \| None = None, encoder: _Encoder \| None = None).

decode_spans

logits: (words, max_width, label_slots) of one text.

to_spans

Word spans to character spans of text.

ner.tokenizers_encoder

GLiNER’s input preparation without PyTorch: the tokenizers library, a regex and numpy.

TokenizersEncoder

Implements the encoder protocol of litert_gliner. Construct with TokenizersEncoder(checkpoint: str \| pathlib.Path, *, cache_dir: str \| pathlib.Path \| None = None, local_files_only: bool = False).

ner.windows

Text longer than a tagger can take: cut it into overlapping word windows, tag each, move the spans back, merge.

recognize_windowed

The spans of one long text, in its own coordinates.

word_windows

[(character offset of the window in text, window text)], size words each, stepping size - overlap words.