ZenLP - NLP工具包
大道至简,返璞归真。
ZenLP 是一个为Python设计的极简、优雅的自然语言处理(NLP)工具包。
在大语言模型(LLM)席卷业界的今天,我们常常被其复杂的结构和高昂的资源需求所困扰。
ZenLP 回归初心,专注于那些历久弥新、效果稳健且具有高度可解释性的经典NLP算法。
我们相信,优雅的工程实现能让这些经典算法在现代NLP工作流中焕发新的光彩。
本项目旨在为每个算法提供:
- 清晰、完备的文档和注释。
- 符合直觉、易于使用的API。
- 生产就绪的性能和稳定性。
欢迎来到ZenNLP的世界,在这里,我们用最少的代码,解决最核心的问题。
✨ 特性
- 极简设计: 摒弃繁杂的依赖和配置,每个模块都力求小而美,专注做好一件事。
- 无监督与自适应: 核心算法多为无监督实现,能自动从原始文本中学习,轻松适应不同领域。
- 生产就绪: 所有代码均经过严格测试,并提供类型提示,确保在生产环境中的稳定性和可维护性。
- 教育友好: 不仅是工具,更是学习经典NLP算法的优秀参考资料。每一行代码、每一篇文档都在传递算法的精髓。
🚀 快速开始
1. 安装
通过 pip 可以轻松安装 ZenLP:
pip install zenlp
2. 使用示例:发现新词
只需几行代码,即可从您的语料中发现新词。
from zenlp import discover
from pprint import pprint
corpus = [
"大语言模型正在引领新一轮的技术革命。",
"生成式AI的快速发展对内容创作产生了深远影响。",
"遥遥领先的技术优势使得这家公司备受瞩目。",
"赛博朋克风格的艺术作品充满了对未来的想象。",
"这家公司的遥遥领先,得益于其强大的自研芯片。",
"许多人对生成式AI的未来既期待又担忧。",
"赛博朋克不仅仅是一种美学,更是一种文化现象。",
]
# 调用 discover 函数
# min_freq: 词语出现的最小频率
# min_pmi: 最小凝聚度 (内部关联性)
# min_entropy: 最小自由度 (外部多样性)
new_words = discover(
corpus_source=corpus,
min_freq=2,
min_pmi=1.0,
min_entropy=0.5
)
pprint(new_words)
📖 功能模块
ZenLP 将会逐步涵盖NLP中的多个核心领域,每个模块都遵循“禅”的设计哲学。
- ✅
zenlp.discovery- 新词发现- 功能: 基于
PMI + 左右熵的无监督新词发现。 - 状态: 已完成。
- 功能: 基于
🤝 贡献 (Contributing)
我们热烈欢迎任何形式的贡献!无论您是想修复一个Bug、增加一个新功能,还是改进文档,都请不要犹豫。
请在提交前确保您的代码通过了测试,并遵循了项目的编码风格。
📜 许可证 (License)
本项目采用 MIT License 授权。
Made with ❤️ and Zenlp.
Metadata
Release files for zenlp 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 | Provenance | |
|---|---|---|---|---|
| zenlp-0.1.0.tar.gz | 7.2 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| zenlp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.6 kB
Release files / zenlp-0.1.0.tar.gz
| Download URL | zenlp-0.1.0.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0a1a3f1331403b219d41b94c69fb9e7f7ae603ec4cf41d8f33eeb1ee4e52f0a
|
|
BLAKE2b-256 checksum How to use checksums |
7e5e1a9e58557990859f2463fa190b9f6bed97f4e1c753895484596325d0ae26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 19, 2025.
Transparency logRelease files / zenlp-0.1.0-py3-none-any.whl
| Download URL | zenlp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b0ae106afb64cafc40296095dd44ecd5590fab1ca2fce8198d54c84a2e465f66
|
|
BLAKE2b-256 checksum How to use checksums |
33a19cefe8e562446a3c8d4e16d358d073fe81f9d08dc8590705e029e1148557
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 19, 2025.
Transparency logSecurity for zenlp 0.1.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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for zenlp-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 19, 2025.
Transparency logA 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.