Skip to main content

Lightweight keyword & keyphrase extraction and ranking using TF-IDF with optional embedding re-ranking.

Project description

auto-keyword-ranker

PyPI version License

Lightweight Python package to extract and rank the most relevant keywords and keyphrases from text.

Goal: One-line call to get ranked keywords for articles, blog posts, or short documents.
Core approach uses TF-IDF; optional re-ranking with 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)]

Example Bar Chart


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 autokeyword/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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

auto_keyword_ranker-0.1.8.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

auto_keyword_ranker-0.1.8-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file auto_keyword_ranker-0.1.8.tar.gz.

File metadata

  • Download URL: auto_keyword_ranker-0.1.8.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for auto_keyword_ranker-0.1.8.tar.gz
Algorithm Hash digest
SHA256 36efaa4feed29171a8192be3c3f1a605b32e5983903da0523e5f9b7c1e8d8bd0
MD5 0c7c9796efb7a605200e55fcdb706284
BLAKE2b-256 13d98532fd4e6c0f0f6e0161d8a6cde5e4f14b80ad80e766610d070658c02f7d

See more details on using hashes here.

File details

Details for the file auto_keyword_ranker-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for auto_keyword_ranker-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 39b14c34ad32c8ef8a87eb4ce5199a6f24ee500bb9720131bcddecf7fdcf39d7
MD5 c8308e961cdcde6def6b30200ac71697
BLAKE2b-256 b61666ed4322759dd99dbb181935a91ecd46a16d13d1e7ccd1d485877291b331

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page