# Python named entity recognition libraries

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

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [Transformers](#transformers) | 120.5M | 169.2K | Nov 2026 | Apache-2.0 |
| [NLTK](#nltk) | 48.7M | 14.8K | Oct 2026 | Apache-2.0 |
| [spaCy](#spacy) | 25.2M | 34.1K | Oct 2026 | MIT |
| [Presidio Analyzer](#presidio-analyzer) | 6.3M | 12.0K | Oct 2026 | MIT |
| [Stanza](#stanza) | 997.2K | 7.9K | Nov 2026 | Apache-2.0 |
| [GLiNER](#gliner) | 799.3K | 4.3K | Oct 2026 | Apache-2.0 |
| [Spark NLP](#spark-nlp) | 790.4K | 4.2K | Nov 2026 | Apache-2.0 |
| [Polyglot](#polyglot) | 88.3K | 2.4K | Jul 2016 | GPLv3 |

Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[Transformers](#transformers) has the most monthly downloads in this comparison, at 120.5M, a count that covers every model task in the library.

## Capabilities

| Library | NER character offsets | Inference-time label prompts |
| --- | --- | --- |
| [Transformers](#transformers) | Yes | No |
| [NLTK](#nltk) | No | No |
| [spaCy](#spacy) | Yes | No |
| [Presidio Analyzer](#presidio-analyzer) | Yes | Via plugin |
| [Stanza](#stanza) | Yes | No |
| [GLiNER](#gliner) | Yes | Yes |
| [Spark NLP](#spark-nlp) | Yes | No |
| [Polyglot](#polyglot) | No | No |

## Libraries

### Transformers

[GitHub](https://github.com/huggingface/transformers) · [PyPI](https://pypi.org/project/transformers) · [Docs](https://huggingface.co/docs/transformers/en/tasks/token_classification)

Defines and runs machine learning models for text, vision, audio, and multimodal tasks.

- Downloads / mo: 120.5M
- Stars: 169.2K
- Last release: 5.23.0
- License: Apache-2.0
- Capabilities: [From the Transformers docs](https://huggingface.co/docs/transformers/en/tasks/token_classification)

```sh
pip install "transformers[torch,sentencepiece]"
```

**docling-project/docling** (70.8K stars)

[docling-project/docling](https://github.com/docling-project/docling) 

```python
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

```

[docs/examples/pii_obfuscate.py](https://github.com/docling-project/docling/blob/b5563e921265c8e8a6ec36a0fd8680620458cfe8/docs/examples/pii_obfuscate.py#L56-L80) · [More projects using Transformers →](https://dashboard.exa.ai/playground/search?q=transformers%20GitHub%20projects)

**Quickstart**

```python
from transformers import pipeline

ner = pipeline(model="Jean-Baptiste/camembert-ner", aggregation_strategy="simple")
entities = ner("Je m’appelle Jean-Baptiste.")

```

From [token_classification.py](https://github.com/huggingface/transformers/blob/v5.23.0/src/transformers/pipelines/token_classification.py)

### NLTK

[GitHub](https://github.com/nltk/nltk) · [PyPI](https://pypi.org/project/nltk) · [Docs](https://www.nltk.org/api/nltk.chunk.html)

Provides the Natural Language Toolkit.

- Downloads / mo: 48.7M
- Stars: 14.8K
- Last release: 3.10.4
- License: Apache-2.0
- Capabilities: [From the NLTK docs](https://www.nltk.org/api/nltk.chunk.html)

```sh
pip install nltk
```

**google-research/google-research** (39.2K stars)

[google-research/google-research](https://github.com/google-research/google-research) 

```python
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

```

[readtwice/models/trivia_qa/preprocess_lib.py](https://github.com/google-research/google-research/blob/f4598eb0d4f8947b880cad470e157d37bd2f858b/readtwice/models/trivia_qa/preprocess_lib.py#L392-L419) · [More projects using NLTK →](https://dashboard.exa.ai/playground/search?q=nltk%20GitHub%20projects)

**Quickstart**

```python
import nltk

nltk.download("maxent_ne_chunker_tab")
nltk.download("words")
entities = nltk.ne_chunk([("Ada", "NNP"), ("Lovelace", "NNP")])

```

From [named_entity.py](https://www.nltk.org/_modules/nltk/chunk/named_entity.html)

### spaCy

[GitHub](https://github.com/explosion/spaCy) · [PyPI](https://pypi.org/project/spacy) · [Docs](https://spacy.io/usage/linguistic-features#named-entities)

Recognizes labeled entity spans through a configurable NLP pipeline.

- Downloads / mo: 25.2M
- Stars: 34.1K
- Last release: 3.8.18
- License: MIT
- Capabilities: [From the spaCy docs](https://spacy.io/usage/linguistic-features#named-entities)

**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.

**Watch out for**

- **Standard NER excludes overlapping entities.** Doc.ents entity spans must remain non-overlapping.

```sh
pip install spacy
```

**ml-tooling/opyrator** (3.1K stars)

[ml-tooling/opyrator](https://github.com/ml-tooling/opyrator) 

```python
def named_entity_recognition(input: TextInput) -> NamedEntitiesOutput:
    doc = nlp(input.text)
    results = []
    for ent in doc.ents:
        try:
            entity_type = Entity(ent.label_)
            if entity_type in input.entity_types:
                results.append(
                    NamedEntity(
                        text=ent.text,
                        start_char=ent.start_char,
                        end_char=ent.end_char,
                        label=entity_type,
                    )
                )
        except ValueError:
            continue

    return NamedEntitiesOutput(__root__=results)

```

[examples/named_entity_recognition/app.py](https://github.com/ml-tooling/opyrator/blob/3f443f05b6b21f00685c2b9bba16cf080edf2385/examples/named_entity_recognition/app.py#L76-L94) · [More projects using spaCy →](https://dashboard.exa.ai/playground/search?q=Projects%20using%20spacy%20for%20named%20entity%20extraction%20with%20character%20offsets&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import spacy

nlp = spacy.load("en_core_web_sm")
doc = nlp("Ada Lovelace worked in London.")

```

From [rule-based-matching.mdx](https://pypi.org/pypi/spacy/3.8.18/json#info.description)

### Presidio Analyzer

[GitHub](https://github.com/data-privacy-stack/presidio) · [PyPI](https://pypi.org/project/presidio-analyzer) · [Docs](https://data-privacy-stack.github.io/presidio/analyzer/)

Provides the Presidio Analyzer package.

- Downloads / mo: 6.3M
- Stars: 12.0K
- Last release: 2.2.366
- License: MIT
- Capabilities: [From the Presidio Analyzer docs](https://data-privacy-stack.github.io/presidio/analyzer/)

```sh
pip install presidio-analyzer
```

**simstudioai/sim** (30.2K stars)

[simstudioai/sim](https://github.com/simstudioai/sim) 

```python
def _analyze_one(
    text: str,
    language: str,
    entities: list[str] | None,
    score_threshold: float | None,
    return_decision_process: bool = False,
    ad_hoc_recognizers: list[PatternRecognizer] | None = None,
):
    regex_only = _regex_only(entities, score_threshold)
    if not regex_only and len(text) > NER_WINDOW_CHARS:
        return _analyze_long(
            text, language, entities, score_threshold, return_decision_process, ad_hoc_recognizers
        )
    # Regex-only requests reuse a blank NlpArtifacts to skip the spaCy NLP pass;
    # otherwise analyze() computes artifacts (runs spaCy) as usual. Custom-pattern
    # recognizers are regex-based, so they run fine against the blank artifacts.
    nlp_artifacts = _BLANK_ARTIFACTS.get(language) if regex_only else None
    with nullcontext() if regex_only else _NER_SLOT:
        return analyzer.analyze(
            text=text,
            language=language,
            entities=entities or None,
            score_threshold=score_threshold,
            return_decision_process=return_decision_process,
            nlp_artifacts=nlp_artifacts,
            ad_hoc_recognizers=ad_hoc_recognizers or None,
        )

```

[apps/pii/server.py](https://github.com/simstudioai/sim/blob/001ee933ba72c771562b9378d33c728a81ff7898/apps/pii/server.py#L377-L403) · [More projects using Presidio Analyzer →](https://dashboard.exa.ai/playground/search?q=presidio-analyzer%20GitHub%20projects)

**Quickstart**

```python
from presidio_analyzer import AnalyzerEngine

analyzer = AnalyzerEngine()
results = analyzer.analyze(text="Ada Lovelace worked in London.", language="en")

```

From [index.md](https://data-privacy-stack.github.io/presidio/analyzer/)

### Stanza

[GitHub](https://github.com/stanfordnlp/stanza) · [PyPI](https://pypi.org/project/stanza) · [Docs](https://stanfordnlp.github.io/stanza/ner.html)

Labels named-entity spans and individual tokens in a language pipeline.

- Downloads / mo: 997.2K
- Stars: 7.9K
- Last release: 1.15.1
- License: Apache-2.0
- Capabilities: [From the Stanza docs](https://stanfordnlp.github.io/stanza/ner.html)

**Strengths**

- **Returns span and token labels.** Read entities from the document or NER tags from individual tokens.
- **Retains outputs from multiple taggers.** Configure multiple NER packages and inspect per-token multi_ner labels.

**Watch out for**

- **NER depends on tokenization.** Include tokenize when selecting the NER pipeline’s processors.
- **Larger minibatches need more memory.** Reduce ner_batch_size when recognition batches exceed available memory.

```sh
pip install stanza
```

**explosion/spacy-stanza** (748 stars)

[explosion/spacy-stanza](https://github.com/explosion/spacy-stanza) 

```python
def tokenizer_factory(
    nlp,
    lang=lang,
    dir=dir,
    package=package,
    processors=processors,
    logging_level=logging_level,
    verbose=verbose,
    use_gpu=use_gpu,
    kwargs=kwargs,
) -> StanzaTokenizer:
    if dir is None:
        dir = DEFAULT_MODEL_DIR
    snlp = Pipeline(
        lang=lang,
        dir=dir,
        package=package,
        processors=processors,
        logging_level=logging_level,
        verbose=verbose,
        use_gpu=use_gpu,
        **kwargs,
    )
    return StanzaTokenizer(
        snlp,
        nlp.vocab,
    )

```

[spacy_stanza/tokenizer.py](https://github.com/explosion/spacy-stanza/blob/b57f3482582535f2f07afb0e4ed01df650925d9d/spacy_stanza/tokenizer.py#L24-L50) · [More projects using Stanza →](https://dashboard.exa.ai/playground/search?q=Projects%20using%20stanza%20for%20named%20entity%20extraction%20with%20character%20offsets&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import stanza

nlp = stanza.Pipeline(lang="en", processors="tokenize,ner")
doc = nlp("Ada Lovelace worked in London.")

```

From [ner.html](https://stanfordnlp.github.io/stanza/ner.html)

### GLiNER

[GitHub](https://github.com/urchade/GLiNER) · [PyPI](https://pypi.org/project/gliner)

Recognizes entities using labels supplied for the prediction task.

- Downloads / mo: 799.3K
- Stars: 4.3K
- Last release: 0.2.30
- License: Apache-2.0
- Capabilities: [From the GLiNER docs](https://github.com/urchade/GLiNER)

**Strengths**

- **Accepts labels at prediction time.** Pass the desired entity labels to predict_entities.
- **Can fine-tune custom models.** Use train_model with training and evaluation data.

**Watch out for**

- **Batch helper is deprecated.** Use inference instead of batch_predict_entities for multiple texts.

```sh
pip install gliner
```

**data-privacy-stack/presidio** (11.9K stars)

[data-privacy-stack/presidio](https://github.com/data-privacy-stack/presidio) 

```python
def predict_func(text: str) -> List[RecognizerResult]:
    # Get predictions from GLiNER (returns dicts)
    gliner_predictions = self.gliner.predict_entities(
        text=text,
        labels=labels,
        flat_ner=self.flat_ner,
        threshold=self.threshold,
        multi_label=self.multi_label,
    )

    # Convert dicts to RecognizerResult objects
    results = []
    for pred in gliner_predictions:
        presidio_entity = self.model_to_presidio_entity_mapping.get(
            pred["label"], pred["label"]
        )

        # Filter by requested entities
        if entities and presidio_entity not in entities:
            continue

        analysis_explanation = AnalysisExplanation(
            recognizer=self.name,
            original_score=pred["score"],
            textual_explanation=f"Identified as {presidio_entity} by GLiNER",
        )

        results.append(
            RecognizerResult(
                entity_type=presidio_entity,
                start=pred["start"],
                end=pred["end"],
                score=pred["score"],
                analysis_explanation=analysis_explanation,
            )
        )
    return results

```

[presidio-analyzer/presidio_analyzer/predefined_recognizers/ner/gliner_recognizer.py](https://github.com/data-privacy-stack/presidio/blob/fd78e974fbf9e15dad1f90de4fc125db39ef4200/presidio-analyzer/presidio_analyzer/predefined_recognizers/ner/gliner_recognizer.py#L188-L224) · [More projects using GLiNER →](https://dashboard.exa.ai/playground/search?q=Projects%20using%20gliner%20for%20named%20entity%20extraction%20with%20character%20offsets&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
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"])

```

From [README.md](https://pypi.org/pypi/gliner/0.2.30/json#info.description)

### Spark NLP

[GitHub](https://github.com/JohnSnowLabs/spark-nlp) · [PyPI](https://pypi.org/project/spark-nlp) · [Docs](https://sparknlp.org/docs/en/annotators)

Annotates text with NLP models on Apache Spark ML.

- Downloads / mo: 790.4K
- Stars: 4.2K
- Last release: 7.0.1
- License: Apache-2.0
- Capabilities: [From the Spark NLP docs](https://sparknlp.org/docs/en/annotators)

```sh
pip install spark-nlp
```

**Quickstart**

```python
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.")

```

From [README.md](https://pypi.org/pypi/spark-nlp/7.0.1/json#info.description) · [Find projects using Spark NLP →](https://dashboard.exa.ai/playground/search?q=spark-nlp%20GitHub%20projects)

### Polyglot

[GitHub](https://github.com/aboSamoor/polyglot) · [PyPI](https://pypi.org/project/polyglot) · [Docs](https://polyglot.readthedocs.io/en/latest/NamedEntityRecognition.html)

Runs a natural language pipeline for multilingual applications.

- Downloads / mo: 88.3K
- Stars: 2.4K
- Last release: 16.7.4
- License: GPLv3
- Capabilities: [From the Polyglot docs](https://polyglot.readthedocs.io/en/latest/NamedEntityRecognition.html)

```sh
pip install polyglot
```

**Quickstart**

```python
from polyglot.text import Text

text = Text("Ada Lovelace worked in London.", hint_language_code="en")
entities = text.entities

```

From [NamedEntityRecognition.html](https://polyglot.readthedocs.io/en/latest/NamedEntityRecognition.html) · [Find projects using Polyglot →](https://dashboard.exa.ai/playground/search?q=polyglot%20GitHub%20projects)

## FAQ

### Which Python NER library should I use?

[spaCy](#spacy) suits production pipelines with trained entity recognizers and rule-based matching. [GLiNER](#gliner) suits extracting entity types named at inference time. [Transformers](#transformers) suits teams that run or fine-tune pretrained token classification models.

### What is Presidio?

[Presidio Analyzer](#presidio-analyzer) finds personal information in text by combining NER models, patterns, and other recognizers. It can call GLiNER as an optional backend.

### What is GLiNER?

[GLiNER](#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.

### How does spaCy recognize named entities?

[spaCy](#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 vs NLTK: which should I use for NER?

[spaCy](#spacy) returns entities with character offsets from a trainable recognizer. [NLTK](#nltk) chunks entities from tokens that the caller has already tagged with parts of speech.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best Python named entity recognition libraries spaCy Stanza Flair GLiNER code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
