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

# Simple TF-IDF keyword ranking
keywords = rank_keywords(text, top_n=5)
print(keywords)

Output

A list of (keyword, score) pairs, for example:

[('artificial intelligence', 0.42),
 ('data analytics', 0.33),
 ('natural language processing', 0.29),
 ('computer vision', 0.25),
 ('industries', 0.21)]

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
  • ( \text{DF}(t) ) = number of documents containing term ( t )

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.6.tar.gz (5.6 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.6-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: auto_keyword_ranker-0.1.6.tar.gz
  • Upload date:
  • Size: 5.6 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.6.tar.gz
Algorithm Hash digest
SHA256 1fd0b192273e4aba6e7b513c1b72435da45373a1a33f779758276eca47c68442
MD5 5f0a94dc9dce3b60ba078d83d2d76cf8
BLAKE2b-256 14d540bdd6b390f7723dda0990348e3d20a2aaca2cc87de06f42b8a93a9db4ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for auto_keyword_ranker-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3b6d35aaf01279b4b735183c3a49f7836d4cfa79fe3d118a265db6814dab9a52
MD5 2276aec6740a6ded06abce20f8fb6bc2
BLAKE2b-256 26c40aa493441ec0f10752a0ab3c691b09c36a972931b4d702632617cea5718b

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