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
'''
简化文本特征化,解码,当前ner为crf 解码
https://github.com/ssbuild/bert_text_pretty.git
'''
text_list = ["你是谁123456","你是谁123456222222222222"]
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=False)
print(feat)
feat = ner.ner_text_feature(tokenizer,text_list,max_seq_len=128,with_padding=False)
print(feat)
feat = relation.re_text_feature(tokenizer,text_list,max_seq_len=128,with_padding=False)
print(feat)
labels = ['标签1','标签2']
print(cls.load_labels(labels))
print(ner.load_label_bio(labels))
# logits 为bert 预测结果
# ner.ner_decoding(text_list,labels,logits,trans=None)
# ner 是否启用trans预测
#text_list 文本list , labels id2label list,logits 2D or 3D , trans 2D
#ner.ner_decoding(text_list,labels,logits,trans)
# logits 为bert 预测结果
# cls.cls_decoding(text_list,labels,logits)
# cls.cls_decoding(text_list,labels,logits)
# relation.re_decoding(example_all, id2spo, logits_all)
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.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09c4048e8a85fbede8ec3b1b0474c763326ddd960a75f3c46416bd4df4c93f3b |
|
MD5 | c178780bd5009683591e77eae650899b |
|
BLAKE2b-256 | 14ab42affb3dc5bd17a6f71f3c3f44a0c4a9f2267b00ee479ea2c837c14127c8 |