CSKE: Class-Specific Keyword Extraction
CSKE is a high-performance Python library designed for iterative, class-specific keyword extraction. Unlike generic extractors, CSKE maintains coherence to a user-defined class, and leverages clustering techniques to ensure that expanded keyword sets remain semantically anchored to the target class.
This code was introduced in the KONVENS 2024 paper titled: An Improved Method for Class-specific Keyword Extraction: A Case Study in the German Business Registry
Key Features
- Iterative Expansion: Automatically discovers new keywords by walking through your dataset starting from a small seed list (defined by you!).
- Drift Prevention: Uses clustering and filtering to weed out out "semantic drift" keywords that do not fit will to your defined domain.
- Weighted Extraction: Balance the influence between the local document context and the global seed keywords.
- Hardware Accelerated: Built on top of PyTorch and Sentence Transformers with automatic support for CUDA.
Installation
pip install cske
Usage
import pandas as pd
from cske import CSKE
df = pd.DataFrame({
"text_content": [
"Neural networks are a subset of machine learning.",
"The transformer architecture revolutionized NLP.",
"Deep learning models require significant GPU resources.".
"..."
]
})
# 2. Initialize the extractor, using any sentence transformer model, i.e., from Hugging Face
extractor = CSKE(embedding_model="all-MiniLM-L6-v2")
# 3. Run the pipeline
keywords = extractor.keyword_pipeline(
starting_seed=["machine learning", "neural networks"],
df=df,
df_col_to_extract="text_content",
n_iterations=3, # number of iterations (partitions of your data)
number_newseed=2, # maximum number of "new" seeds per iteration
do_filter=True # whether to perform filtering to prevent drift
)
print(f"Expanded Keyword Set: {keywords}")
Key Parameters, and what they mean
| Parameter | Default | Description |
|---|---|---|
n_iterations |
5 |
How many rounds of expansion to perform. |
seed_weight |
1.0 |
Importance given to the original seed keywords. |
doc_weight |
0.0 |
Importance given to document context. |
do_filter |
True |
Whether or not to apply filtering. |
topk |
None |
If set, limits the final output to the top-k keywords. |
Citation
If you find CSKE useful or utilize it for your work, please considering citing:
@inproceedings{meisenbacher-etal-2024-improved,
title = "An Improved Method for Class-specific Keyword Extraction: A Case Study in the {G}erman Business Registry",
author = "Meisenbacher, Stephen and
Schopf, Tim and
Yan, Weixin and
Holl, Patrick and
Matthes, Florian",
editor = "Luz de Araujo, Pedro Henrique and
Baumann, Andreas and
Gromann, Dagmar and
Krenn, Brigitte and
Roth, Benjamin and
Wiegand, Michael",
booktitle = "Proceedings of the 20th Conference on Natural Language Processing (KONVENS 2024)",
month = sep,
year = "2024",
address = "Vienna, Austria",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2024.konvens-main.18/",
pages = "159--165"
}
This work makes use of the KeyBERT library, so please also consider citing it: KeyBERT
Metadata
Release files for CSKE 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cske-0.3.0.tar.gz | 11.3 kB | Without provenance | Details for cske-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cske-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for cske-0.3.0-py3-none-any.whl |
Total release size: 25.4 kB
Release files / cske-0.3.0.tar.gz
| Download URL | cske-0.3.0.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b8740d6f6b9d857f0eea1678aa8a606f8d2d39b1dde3e78ed857b93a133b006e
|
|
BLAKE2b-256 checksum How to use checksums |
5d8022d79a281144ff3929e1eabaabfe9857c22b37afb7fe37fcbb17c03e7be7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Release files / cske-0.3.0-py3-none-any.whl
| Download URL | cske-0.3.0-py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
88dfd81fe40407d4e78c1854665cd3e0f3bdd57e6c10ce1a8108c01cbb889920
|
|
BLAKE2b-256 checksum How to use checksums |
d19d8418f0132f0db5528437fa63f5f1b2f40e90a04fef4dbe45617d1928769b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Security for CSKE 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.