pybert
安装
>pip install pybert
预训练模型
下载地址:
- bert_Chinese 模型文件: https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-chinese.tar.gz
- 词表 https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-chinese-vocab.txt
- 【备用】百度网盘:https://pan.baidu.com/s/1HPZBvkMAyu0nDUqHWsb0SA?pwd=abbn
所需文件:
- pytorch_model.bin
- bert_config.json
- vocab.txt
放到 bert_pretrain 文件夹中
训练数据下载
- 可以任意指定文件夹名称,训练数据的格式要和上面一致
训练和预测
训练
from pybert.models import bert
from pybert.train_eval import load_and_train
dataset = 'THUCNews' # 数据集
logfile = 'log.txt' # 日志文件
config = bert.Config(dataset, logfile=logfile)
load_and_train(config)
预测
# coding: UTF-8
import pybert.models.bert as bert
from pybert.train_eval import Prediction
config = bert.Config(dataset='THUCNews')
prediction = Prediction(config)
sentences = ['野兽用纪录打爆第二中锋 掘金版三巨头已巍然成型', '56所高校预估2009年湖北录取分数线出炉']
predict_label, score = prediction.predict(sentences)
print("predict label:")
print(predict_label)
对应论文
[1] BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
Metadata
Release files for pybert 0.0.2
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 | |
|---|---|---|---|---|
| pybert-0.0.2.tar.gz | 28.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pybert-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 58.5 kB
Release files / pybert-0.0.2.tar.gz
| Download URL | pybert-0.0.2.tar.gz |
|---|---|
| Size | 28.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
88a558d14930ed546ff827e189955c8448dfdb90a06d3350e260fa34a32a1f93
|
|
BLAKE2b-256 checksum How to use checksums |
49f1372bd98b5ae7ebce3906ee284cb5fd507dcf9e897f020be7f1733f73e1e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
|
Release files / pybert-0.0.2-py3-none-any.whl
| Download URL | pybert-0.0.2-py3-none-any.whl |
|---|---|
| Size | 29.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c8ffa6ccfd44232ada27082d285690c8cbda9b363c4c20f284365796151116d4
|
|
BLAKE2b-256 checksum How to use checksums |
baee4873531be4c3c307749b15bd894ae38c805a16902c5acbaf0787a6bf1ddf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
|
Security for pybert 0.0.2
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.