Lightweight keyword & keyphrase extraction and ranking using TF-IDF with optional embedding re-ranking.
Project description
auto-keyword-ranker
A lightweight Python library to automatically extract and rank the most relevant keywords and keyphrases from text.
Goal: Provide a single-line call to obtain ranked keywords for articles, blog posts, or short documents. Uses TF-IDF by default, with optional re-ranking via sentence-transformer embeddings.
Installation
pip install auto-keyword-ranker
With optional embedding-based re-ranking:
pip install auto-keyword-ranker[embed]
Quickstart
from autokeyword import rank_keywords
text = """
Artificial intelligence is transforming industries by enabling new capabilities
such as natural language processing, computer vision, and advanced data analytics.
Companies across healthcare, finance, and manufacturing are investing heavily in AI
to automate decision-making, enhance efficiency, and unlock new insights from
large datasets.
"""
# Simple TF-IDF keyword ranking
keywords = rank_keywords(text, top_n=10)
print(keywords)
Output
A list of (keyword, score) pairs, for example:
[('new', 0.25),
('vision advanced', 0.12),
('unlock new', 0.12),
('unlock', 0.12),
('transforming industries', 0.12),
('vision', 0.12),
('transforming', 0.12),
('processing computer', 0.12),
('new insights', 0.12),
('processing', 0.12)]
API
rank_keywords(
texts,
top_n=10,
method='tfidf',
ngram_range=(1,2),
stop_words=True,
use_embeddings=False,
embedding_model=None,
combine_score_alpha=0.6
)
See docstrings in core.py for full parameter descriptions.
CLI
You can also run the CLI (after installation):
python -m autokeyword.cli --text "Your article text here" --top 10
How It Works
TF-IDF scoring formula:
$$ \text{TF-IDF}(t, d) = \text{TF}(t, d) \times \log \frac{N}{1 + \text{DF}(t)} $$
Where:
- ( t ) = term
- ( d ) = document
- ( N ) = total number of documents
Use Cases
- SEO keyword extraction for blog posts
- Automatic tagging in content management systems
- Quick summarization of research papers
- Preprocessing for search or recommendation engines
License
MIT License © 2025 Reya Oberoi
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file auto_keyword_ranker-0.1.10.tar.gz.
File metadata
- Download URL: auto_keyword_ranker-0.1.10.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
beefaa87f818a1e2233c1d89824338d4dd8e128ebac3624d9c22f053133e73d9
|
|
| MD5 |
4fe1f963e516facbc089c0a9b4893a28
|
|
| BLAKE2b-256 |
e47b748634eb3cc5d1487f389ca4daaff44f99989f959d0b1f55cf2651e1e9a8
|
File details
Details for the file auto_keyword_ranker-0.1.10-py3-none-any.whl.
File metadata
- Download URL: auto_keyword_ranker-0.1.10-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9d707526529e754933156e3712b56da683d6f6d84cc5ece3eb7b7b9b4aa6752
|
|
| MD5 |
f9dcfff6f0c3a9b24051b27c876e46ad
|
|
| BLAKE2b-256 |
3700b1de56d31a057c5541f4e96a62acd2421c269bbd108969d826cacff3dfb2
|