Python NLP libraries

Updated Nov 2026

Python NLP (natural language processing) libraries split text into words and sentences, label them, and turn them into numbers that models can use. These libraries handle the text steps inside search engines, document tagging, and the embedding step of retrieval for AI agents.

Popularity

NLTK has the most monthly downloads in this comparison, at 42.0M.

LibraryMonthly downloadsStarsLast releaseLicense
Transformers
119.8M
169.2KNov 2026Apache 2.0 License
NLTK
48.3M
14.8KOct 2026Apache License, Version 2.0
spaCy
25.0M
34.0KOct 2026MIT
Sentence Transformers
22.6M
19.3KNov 2026Apache-2.0
Jieba
6.2M
35.2KJan 2020MIT
TextBlob
3.2M
9.6KJul 2026MIT
Gensim
3.0M
16.5KOct 2025LGPL-2.1-only
fastText
2.2M
26.5KJun 2024MIT
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Transformers loads pretrained language models from the Hugging Face Hub and runs them for tasks such as text classification. pipeline pairs a model with its tokenizer. One call on a sentence returns a label and a score. Fine-tuning uses the same model classes, and training frameworks and inference engines reuse the model definitions. The library runs on PyTorch.

Downloads / mo
119.8M
Stars
169.2K
Last release
5.23.0
License
Apache 2.0 License

Strengths

  • Models by name. A task and a model name from the Hub are enough for pipeline to download and run a model.

Limitations

  • Weights download on first use. Each model fetches its weights the first time it loads, and large models need a GPU with enough memory to hold them.

Quickstart

From text_classification.py
$ pip install torch transformers
from transformers import pipeline

classifier = pipeline(model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")
classifier("This movie is disgustingly good !")

Transformers examples

From open-source projects on GitHub

NLTK, the Natural Language Toolkit, is a suite of Python modules, data sets, and tutorials for natural language processing research and development. nltk.word_tokenize splits text into words, and other modules tag parts of speech, parse sentences, chunk named entities, and classify text. Corpora and lexical resources download separately with nltk.download.

Downloads / mo
48.3M
Stars
14.8K
Last release
3.10.4
License
Apache License, Version 2.0

Strengths

  • Offers a broad algorithm toolkit. Choose tokenization, tagging, parsing, and classification tools alongside corpus resources.
  • Extracts named entity chunks. Run the named-entity chunker on already tagged tokens.

Limitations

  • Resources download separately. Tokenizer models, taggers, and corpora each need nltk.download before first use.

Quickstart

From index.rst
$ pip install --user -U nltk
import nltk
sentence = """At eight o'clock on Thursday morning
Arthur didn't feel very good."""
tokens = nltk.word_tokenize(sentence)
print(tokens)

NLTK examples

From open-source projects on GitHub

spaCy processes text through a pipeline of components that tokenize, tag parts of speech, parse dependencies, recognize named entities, and classify text. spacy.load loads a trained pipeline such as en_core_web_sm, and calling it on a string returns a Doc that holds every token and its labels. Pipelines can include pretrained transformers such as BERT, and spaCy supports tokenization and training for more than seventy languages.

Downloads / mo
25.0M
Stars
34.0K
Last release
3.8.18
License
MIT

Strengths

  • Combines linguistic pipeline components. Process text with trained tagging, parsing, and entity-recognition components.
  • Serializes annotated documents as JSON. Export token-level annotations through the document JSON API.

Limitations

  • Labels need a trained pipeline. Statistical tags and entities come from a trained pipeline, which installs as a separate package.

Quickstart

From models.mdx
$ pip install spacy python -m spacy download en_core_web_sm
import spacy
nlp = spacy.load("en_core_web_sm")
doc = nlp("This is a sentence.")
print([(w.text, w.pos_) for w in doc])

spaCy examples

From open-source projects on GitHub

Sentence Transformers

Sentence Transformers computes embeddings, vectors that place texts with similar meaning close together, using pretrained models from Hugging Face. SentenceTransformer loads a model, encode turns a list of sentences into embeddings, and similarity compares them. Cross-encoder models score pairs of texts for reranking, and sparse encoder models produce sparse embeddings. The same library trains and fine-tunes these models.

Downloads / mo
22.6M
Stars
19.3K
Last release
6.3.0
License
Apache-2.0

Strengths

  • Pretrained models by name. More than fifteen thousand pretrained models on Hugging Face load by name.

Limitations

  • Models download on first use. Each model downloads from Hugging Face the first time it loads.

Quickstart

From quickstart.rst
$ pip install -U sentence-transformers
from sentence_transformers import SentenceTransformer



# 1. Load a pretrained Sentence Transformer model

model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")



# The sentences to encode

sentences = [

    "The weather is lovely today.",

    "It's so sunny outside!",

    "He drove to the stadium.",

]



# 2. Calculate embeddings by calling model.encode()

embeddings = model.encode(sentences)

Sentence Transformers examples

From open-source projects on GitHub

Jieba segments Chinese text into words, which Chinese writing does not separate with spaces. jieba.cut runs in accurate mode by default, full mode lists every possible word, and search engine mode splits long words again to improve recall. Custom dictionaries add domain terms, and the segmenter also handles Traditional Chinese.

Downloads / mo
6.2M
Stars
35.2K
Last release
0.42.1
License
MIT

Strengths

  • Custom dictionaries. A user dictionary adds names and terms that the default dictionary misses.

Limitations

  • Paddle mode needs PaddlePaddle. The deep learning mode requires the separate paddlepaddle-tiny package.

Quickstart

From README.md
$ pip install jieba
import jieba
seg_list = jieba.cut("我来到北京清华大学", cut_all=False)
print("Default Mode: " + "/ ".join(seg_list))  # 精确模式

Jieba examples

From open-source projects on GitHub

TextBlob wraps NLTK and pattern in a single object for common text tasks. TextBlob(text) exposes part-of-speech tags, noun phrases, sentences, and a sentiment score with polarity and subjectivity. The library also tokenizes text and trains Naive Bayes and decision tree classifiers.

Downloads / mo
3.2M
Stars
9.6K
Last release
0.20.1
License
MIT

Strengths

  • One object for common tasks. Tags, noun phrases, and sentiment come from attributes on the same TextBlob object.

Limitations

  • Built on NLTK data. TextBlob relies on NLTK corpora, which download separately before first use.

Quickstart

From quickstart.rst
$ pip install -U textblob python -m textblob.download_corpora
from textblob import TextBlob
testimonial = TextBlob("Textblob is amazingly simple to use. What great fun!")
print(testimonial.sentiment)

TextBlob examples

From open-source projects on GitHub

Gensim builds topic models and word vectors from large collections of documents. Its algorithms, including word vector training, LDA, and LSA, stream documents from disk, so a corpus larger than RAM can be processed. gensim.downloader loads pretrained vectors such as GloVe by name, and most_similar returns the nearest words. LSA and LDA can also run on a cluster of computers.

Downloads / mo
3.0M
Stars
16.5K
Last release
4.4.0
License
LGPL-2.1-only

Strengths

  • Fits unsupervised semantic models. Train topic and word-vector models from a corpus of documents.
  • Streams corpora from disk. Iterate over corpus documents without loading the entire matrix into memory.

Limitations

  • Features must match training. New documents need the same preprocessing and dictionary as the training corpus.
  • Maintenance mode. Gensim accepts bug and documentation fixes but takes no new features.
$ pip install --upgrade gensim
import gensim.downloader as api
model = api.load("glove-wiki-gigaword-50")
model.most_similar("glass")

Gensim examples

From open-source projects on GitHub

fastText learns word representations and trains text classifiers. fasttext.train_unsupervised learns word vectors from a text file, and fasttext.train_supervised trains a classifier from lines that start with __label__ tags. Vectors are built from character n-grams, so words outside the training vocabulary still get a vector.

Downloads / mo
2.2M
Stars
26.5K
Last release
0.9.3
License
MIT

Strengths

  • Pretrained word vectors. Facebook publishes word vectors for a hundred and fifty-seven languages, trained on Wikipedia and Common Crawl.
  • Language identification. A downloadable model identifies the language of a text.

Limitations

  • Compiled during install. The package compiles C++ code when it installs and builds on macOS and Linux.

Quickstart

From python-module.md
$ pip install fasttext
import fasttext
model = fasttext.train_supervised('data.train.txt')

fastText examples

From open-source projects on GitHub

FAQ

For a pipeline that tags, parses, and finds entities, spaCy loads a trained pipeline in one call. NLTK collects many separate algorithms and corpora for research and teaching. For embeddings and semantic search, Sentence Transformers encodes text with pretrained models, and Transformers runs pretrained models for classification and other tasks.

Sentence Transformers computes embeddings, vectors that place similar texts close together, with pretrained models from Hugging Face. model.encode turns a list of sentences into embeddings, and cross-encoder models score pairs of texts for reranking. Uses include semantic search, semantic textual similarity, and paraphrase mining.

NLTK is a toolkit of separate algorithms, corpora, and lexical resources, each downloaded as needed. spaCy runs text through one pipeline of trained components that tags, parses, and labels entities, and returns a Doc object holding every annotation.

spaCy's trained pipelines are packages, such as en_core_web_sm, installed with spacy download and loaded with spacy.load. Statistical tags and entities come from these pipelines, and spaCy supports tokenization and training for more than seventy languages.

Gensim trains word vector models on documents streamed from disk, so the corpus can be larger than memory. Pretrained vectors such as GloVe load by name through gensim.downloader, and most_similar returns the nearest words.

For coding agents

Found your NLP 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.

Run in your terminal

claude plugin install exa@claude-plugins-official