keybert
KeyBERT performs keyword extraction with state-of-the-art transformer models.
What it is and what it does
KeyBERT is a lightweight keyword extraction library that uses pre-trained BERT embeddings to identify the words and phrases in a document that best represent its semantic content. It works by computing a document-level embedding, then embedding candidate n-grams, and ranking them by cosine similarity to the document. The library requires four runtime dependencies: numpy and scikit-learn for numerical operations, sentence-transformers to load and run embedding models, and rich for output formatting.
The package is designed for minimal setup. It supports multiple extraction strategies, configurable n-gram ranges, and pluggable embedding backends. It is actively maintained, supports Python 3.8, 3.9, 3.10, 3.11, and 3.12, and has no known security vulnerabilities.
Use it for:
- Extract single-word keywords from research papers or articles to build document summaries or search indices.
- Generate multi-word keyphrases from product descriptions or customer feedback to identify key topics.
- Diversify keyword results using maximal marginal relevance to avoid redundant or near-duplicate extractions.
- Build a document tagger by extracting keywords and using them to label or categorize incoming text.
- Integrate semantic keyword extraction into a content recommendation system to match documents by extracted terms.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
KeyBERT extracts keywords and keyphrases from documents by computing BERT embeddings and finding n-grams most similar to the document as a whole using cosine similarity.
Yes. KeyBERT is worth installing for semantic keyword extraction tasks. It has low install friction, active maintenance, permissive licensing, no known vulnerabilities, and a straightforward API. The main consideration is that sentence-transformers downloads a transformer model on first use; verify that the model can be pre-cached and that extraction latency meets your needs.
Install
keybert on PyPI
pip
pip install keybertuv
uv add keybertpoetry
poetry add keybertInstalling keybert
Before you install
Low install friction: pure Python wheel with four runtime dependencies (numpy, scikit-learn, sentence-transformers, rich). Actively maintained with recent commits and no known vulnerabilities.
License in practice
MIT License permits commercial and private use, modification, and redistribution with minimal restrictions—suitable for most projects.
Quickstart
pip install keybert
from keybert import KeyBERT
kw_model = KeyBERT()
keywords = kw_model.extract_keywords(doc)
sentence-transformers downloads a transformer model on first use; requires internet access or pre-cached model.
Verify before relying
- Whether the package works offline after initial model download, or requires network access per extraction call.
- Memory footprint and latency characteristics for large documents or batch processing.
- Whether optional extras (flair, gensim, spacy, use) are required for production use or only for advanced embedding backends.
- Performance characteristics and typical extraction latency on standard document sizes.
Package facts
| License | MIT License Copyright (c) 2020, Maarten P. Grootendorst Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — numpy, rich, scikit-learn, sentence-transformers |
| Maintenance | actively maintained — 553 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 720,941/month — #5,232 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: keybert-0.9.0-py3-none-any.whl
Keywords: nlp, bert, keyword, extraction, embeddings
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
bertopicBERTopic performs topic modeling on text…
permissive · top 15,000 on PyPI
keyphrase-vectorizersExtracts keyphrases from text documents using…
permissive · top 15,000 on PyPI
rake-nltkExtracts keywords and key phrases from text…
permissive · top 15,000 on PyPI
yakeYAKE extracts keywords from text documents…
copyleft · top 15,000 on PyPI
sentence-transformersComputes embeddings and reranking scores for…
permissive · top 1,000 on PyPI
flashtextExtracts or replaces keywords in text using the…
permissive · top 5,000 on PyPI
stop-wordsProvides curated stop-word lists for multiple…
permissive · top 15,000 on PyPI
bert-scoreBERTScore computes automatic evaluation metrics…
permissive · top 15,000 on PyPI
flairFlair is a PyTorch-based NLP framework that…
permissive · top 15,000 on PyPI
floretfloret trains compact word embeddings using…
permissive · top 15,000 on PyPI