Chinese_keyBERT
Chinese_keyBERT is a minimal Chinese keywords extraction library that leverage the contextual embeddings generated from BERT models to extract relevant keywords from the given texts.
Installation
pip install chinese_keybert
Get started
from chinese_keybert import Chinese_Extractor
kw_extractor = Chinese_Extractor()
text = [
'''
渾水創始人:七月開始調查貝殼,因為“好得難以置信” 2021年12月16日,做空機構渾水在社交媒體上公開表示,正在做空美股上市公司貝殼...
'''
]
result = kw_extractor.generate_keywords(text,top_k=5,rank_methods="mmr")
How it works
The core idea behind chinese_keyBERT is to utilize a word segmentation models to segments a piece of text into smaller n-grams and filter the n-grams according to the defined part-of-speech (as some pos are not suitable to be used as a keyword). Then, an embedding model (eg. BERT) is used to encode the text and filtered n_grams into embeddings and using some ranking methods (eg. maximun sum/maximun marginal relevance) to compute the cosine distances betweens the text and n-grams embeddings and rank the keywords according to the scores.
To-do
- Documentations
- Vectorization operations to speed-up processing of multiple documents
- Add support for other word segmentation, part-of-speech and embeddings model
Credit
Chinese_keyBERT was largely inspired by KeyBERT, a minimal library for embedding based keywords extractions. Besides, Chinese_keyBERT is also heavily relies on Chinese word segmentation and POS library from CKIP as well as sentence-transformer for generating quality embeddings.
Release files for chinese-keybert 0.1.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 | |
|---|---|---|---|
| chinese_keybert-0.1.0.tar.gz | 8.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| chinese_keybert-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.8 kB
Release files / chinese_keybert-0.1.0.tar.gz
| Download URL | chinese_keybert-0.1.0.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
505358bcd300fc78900dfe189e4b13f6dc6d4b8314e5f3bb6c11bf6e3375013f
|
|
BLAKE2b-256 checksum How to use checksums |
7899db56f3aef86c2d7fa7cf9d670ba1448b90ee5a4194da9dd7cd11ab5cc68f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.7.9
|
Release files / chinese_keybert-0.1.0-py3-none-any.whl
| Download URL | chinese_keybert-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bedfb59adbfeb84936f0f72386a955973d3096151d609c52fa503a9c858f6407
|
|
BLAKE2b-256 checksum How to use checksums |
0543b389f81eece163a83777cf7a537d19e91e1551a07b5941e8f42ee63c86b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.7.9
|