这是一个基于 bert-base-uncased 的模型,在 Yelp Reviews 数据集上进行了标点恢复的微调。
该模型可对纯文本、小写文本进行标点预测和大小写转换。一个典型的使用场景是语音识别(ASR)输出,或者其他文本丢失标点的情况。
此模型旨在直接用作通用英语的标点恢复模型。或者,您也可以将其用于特定领域文本的进一步微调,以完成标点恢复任务。
模型可恢复以下标点符号——[! ? . , - : ; ' ]
该模型还能恢复单词的大写。
以下是快速上手使用该模型的方法。
pip install rpunctfrom rpunct import RestorePuncts
# The default language is 'english'
rpunct = RestorePuncts()
rpunct.punctuate("""in 2018 cornell researchers built a high-powered detector that in combination with an algorithm-driven process called ptychography set a world record
by tripling the resolution of a state-of-the-art electron microscope as successful as it was that approach had a weakness it only worked with ultrathin samples that were
a few atoms thick anything thicker would cause the electrons to scatter in ways that could not be disentangled now a team again led by david muller the samuel b eckert
professor of engineering has bested its own record by a factor of two with an electron microscope pixel array detector empad that incorporates even more sophisticated
3d reconstruction algorithms the resolution is so fine-tuned the only blurring that remains is the thermal jiggling of the atoms themselves""")
# Outputs the following:
# In 2018, Cornell researchers built a high-powered detector that, in combination with an algorithm-driven process called Ptychography, set a world record by tripling the
# resolution of a state-of-the-art electron microscope. As successful as it was, that approach had a weakness. It only worked with ultrathin samples that were a few atoms
# thick. Anything thicker would cause the electrons to scatter in ways that could not be disentangled. Now, a team again led by David Muller, the Samuel B.
# Eckert Professor of Engineering, has bested its own record by a factor of two with an Electron microscope pixel array detector empad that incorporates even more
# sophisticated 3d reconstruction algorithms. The resolution is so fine-tuned the only blurring that remains is the thermal jiggling of the atoms themselves.该模型适用于任意长度的英文文本,若有 GPU 则会启用 GPU 进行处理。
以下是我们用于微调模型的产品评论数量:
| 语言 | 文本样本数量 |
|---|---|
| English | 560,000 |
我们发现模型在 3 个 epoch 左右收敛效果最佳,这也是本文展示的结果,且相关模型可下载获取。
微调后的模型在 45,990 个预留文本样本上的准确率如下:
| 准确率 | 总体 F1 | 评估支持数 |
|---|---|---|
| 91% | 90% | 45,990 |
以下是模型针对每个标签的性能细分:
| label | precision | recall | f1-score | support |
|---|---|---|---|---|
| ! | 0.45 | 0.17 | 0.24 | 424 |
| !+Upper | 0.43 | 0.34 | 0.38 | 98 |
| ' | 0.60 | 0.27 | 0.37 | 11 |
| , | 0.59 | 0.51 | 0.55 | 1522 |
| ,+Upper | 0.52 | 0.50 | 0.51 | 239 |
| - | 0.00 | 0.00 | 0.00 | 18 |
| . | 0.69 | 0.84 | 0.75 | 2488 |
| .+Upper | 0.65 | 0.52 | 0.57 | 274 |
| : | 0.52 | 0.31 | 0.39 | 39 |
| :+Upper | 0.36 | 0.62 | 0.45 | 16 |
| ; | 0.00 | 0.00 | 0.00 | 17 |
| ? | 0.54 | 0.48 | 0.51 | 46 |
| ?+Upper | 0.40 | 0.50 | 0.44 | 4 |
| none | 0.96 | 0.96 | 0.96 | 35352 |
| Upper | 0.84 | 0.82 | 0.83 | 5442 |
如有问题、反馈或需要类似模型,请联系 Daulet Nurmanbetov。