Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
Python named entity recognition libraries find the names of people, organizations, places, and other entities in text and label each one. A model returns each entity with its label and its character position in the original text. These libraries let search systems, compliance tools, and AI agents pull structured facts out of documents.
Popularity
Transformers has the most monthly downloads in this comparison, at 120.5M, a count that covers every model task in the library.
def _build_simple_ner_pipeline():
"""Create a Hugging Face token-classification pipeline for NER.
Returns a callable like: ner(text) -> List[dict]
"""
try:
from transformers import (
AutoModelForTokenClassification,
AutoTokenizer,
pipeline,
)
except Exception:
_log.error("Transformers not installed. Please run: pip install transformers")
raise
tokenizer = AutoTokenizer.from_pretrained(HF_MODEL)
model = AutoModelForTokenClassification.from_pretrained(HF_MODEL)
ner = pipeline(
"token-classification",
model=model,
tokenizer=tokenizer,
aggregation_strategy="simple", # groups subwords into complete entities
# Note: modern Transformers returns `start`/`end` when possible with aggregation )
return ner
def _annotate_entities(self, text):
spans = list(self.nltk_tokenizer.span_tokenize(text))
tokens = [text[b:e] for (b, e) in spans]
annotations = []
trees = nltk.ne_chunk(nltk.pos_tag(tokens))
start_index = 0
for tree in trees:
if hasattr(tree, 'label'):
children = [text for text, pos in tree]
end_index = start_index + len(children)
if tree.label() in self.nltk_pos_types:
begin, _ = spans[start_index]
_, end = spans[end_index - 1]
surface_form = ' '.join(children)
# There are edge cases when these are not equal. # For example, Diminish'd != Diminish 'd # assert text[begin:end] == surface_form, text surface_form = text[begin:end]
annotations.append(
data_utils.Annotation(
begin=begin, end=end - 1, text=surface_form, label=1, type=1))
start_index = end_index
else:
start_index += 1
annotations.sort(key=lambda a: (a.begin, a.end))
sentence = data_utils.Sentence(text=text, annotations=annotations)
sentence.strip_whitespaces()
return sentence
spaCy
Recognizes labeled entity spans through a configurable NLP pipeline.
Downloads / mo
25.2M
Stars
34.1K
Last release
3.8.18
License
MIT
Strengths
Adds rules alongside learned entities.Use EntityRuler patterns to assign entity labels from text rules.
Retains character positions.Read start_char and end_char from the returned entity spans.
Limitations
Standard NER excludes overlapping entities.Doc.ents entity spans must remain non-overlapping.
from presidio_analyzer import AnalyzerEngine
analyzer = AnalyzerEngine()
results = analyzer.analyze(text="Ada Lovelace worked in London.", language="en")
from gliner import GLiNER
model = GLiNER.from_pretrained("gliner-community/gliner_small-v2.5")
entities = model.predict_entities("Ada Lovelace worked in London.", ["person", "city"])
import sparknlp
from sparknlp.pretrained import PretrainedPipeline
spark = sparknlp.start()
model = PretrainedPipeline("explain_document_dl", lang="en")
result = model.annotate("Ada Lovelace worked in London.")
Polyglot
Runs a natural language pipeline for multilingual applications.
from polyglot.text import Text
text = Text("Ada Lovelace worked in London.", hint_language_code="en")
entities = text.entities
FAQ
spaCy suits production pipelines with trained entity recognizers and rule-based matching. GLiNER suits extracting entity types named at inference time. Transformers suits teams that run or fine-tune pretrained token classification models.
Presidio Analyzer finds personal information in text by combining NER models, patterns, and other recognizers. It can call GLiNER as an optional backend.
GLiNER is a generalist NER model that accepts entity labels as input at inference time. The model still determines how well it finds each label.
spaCy runs a trained entity recognizer in its pipeline and stores each result as a span with character offsets. An entity ruler adds matches from patterns.
spaCy returns entities with character offsets from a trainable recognizer. NLTK chunks entities from tokens that the caller has already tagged with parts of speech.
For coding agents
Found your named entity recognition library? Help your agent use it.
Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.