bert_text_pretty 是一个bert 文本特征化和文本后处理解码的包,用于bert工程推理
Project description
bert_text_pretty 是一个bert 文本特征化和文本后处理解码的包,用于bert工程推理
# -*- coding:utf-8 -*-
import numpy as np
from bert_text_pretty import cls,ner,relation,tokenization
text_list = ["你是谁123456"]
tokenizer = tokenization.FullTokenizer(vocab_file=r'F:\pretrain\chinese_L-12_H-768_A-12\vocab.txt',do_lower_case=True)
feat = cls.cls_text_feature(tokenizer,text_list,max_seq_len=128,with_padding=None)
print(feat)
feat = ner.ner_text_feature(tokenizer,text_list,max_seq_len=128,with_padding=None)
print(feat)
feat = relation.re_text_feature(tokenizer,text_list,max_seq_len=128,with_padding=None)
print(feat)
labels = ['标签1','标签2']
print(cls.load_labels(labels))
print(ner.load_label_bio(labels))
# logits 为bert 预测结果
# ner.ner_decoding(text_list,logits,labels,logits)
# logits 为bert 预测结果
# cls.cls_decoding(text_list,logits,labels,logits)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for bert_text_pretty-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee761fc242b798a746f89a98a6b31a5043b9ab26be52511de1bfb87074d1601a |
|
MD5 | 6d2f602e73b1450152fae1008020815f |
|
BLAKE2b-256 | a0ae40639f8d8e7eb8f73203db40fd014452e82201af51c9c106a4f50f0eeb69 |