🚀 多语言标点预测模型
本项目的模型可对英文、意大利文、法文和德文文本进行标点预测,主要用于恢复转录口语中的标点。该多语言模型在 SEPP - NLG 共享任务 提供的 Europarl 数据集 上进行训练,对于荷兰语,我们还纳入了 SoNaR 数据集。请注意,此数据集由政治演讲组成,因此模型在其他领域的文本上可能表现不同。
模型可恢复以下标点符号:"." "," "?" "-" ":"
🚀 快速开始
我们提供了一个简单的 Python 包,可处理任意长度的文本。
📦 安装指南
要开始使用,请从 pypi 安装该包:
pip install deepmultilingualpunctuation
💻 使用示例
基础用法
from deepmultilingualpunctuation import PunctuationModel
model = PunctuationModel(model="oliverguhr/fullstop-punctuation-multilingual-sonar-base")
text = "My name is Clara and I live in Berkeley California Ist das eine Frage Frau Müller"
result = model.restore_punctuation(text)
print(result)
输出
My name is Clara and I live in Berkeley, California. Ist das eine Frage, Frau Müller?
高级用法
from deepmultilingualpunctuation import PunctuationModel
model = PunctuationModel(model="oliverguhr/fullstop-punctuation-multilingual-sonar-base")
text = "My name is Clara and I live in Berkeley California Ist das eine Frage Frau Müller"
clean_text = model.preprocess(text)
labled_words = model.predict(clean_text)
print(labled_words)
输出
[['My', '0', 0.99998856], ['name', '0', 0.9999708], ['is', '0', 0.99975926], ['Clara', '0', 0.6117834], ['and', '0', 0.9999014], ['I', '0', 0.9999808], ['live', '0', 0.9999666], ['in', '0', 0.99990165], ['Berkeley', ',', 0.9941764], ['California', '.', 0.9952892], ['Ist', '0', 0.9999577], ['das', '0', 0.9999678], ['eine', '0', 0.99998224], ['Frage', ',', 0.9952265], ['Frau', '0', 0.99995995], ['Müller', '?', 0.972517]]
📚 详细文档
模型表现
不同标点符号的恢复效果有所不同,因为连字符和冒号在很多情况下是可选的,可由逗号或句号替代。模型在不同语言上的 F1 分数如下:
属性 |
英文 |
德文 |
法文 |
意大利文 |
荷兰文 |
无标点 |
0.990 |
0.996 |
0.991 |
0.988 |
0.994 |
句号 |
0.924 |
0.951 |
0.921 |
0.917 |
0.959 |
问号 |
0.825 |
0.829 |
0.800 |
0.736 |
0.817 |
逗号 |
0.798 |
0.937 |
0.811 |
0.778 |
0.813 |
冒号 |
0.535 |
0.608 |
0.578 |
0.544 |
0.657 |
连字符 |
0.345 |
0.384 |
0.353 |
0.344 |
0.464 |
宏平均 |
0.736 |
0.784 |
0.742 |
0.718 |
0.784 |
微平均 |
0.975 |
0.987 |
0.977 |
0.972 |
0.983 |
可用模型
官方模型
社区模型
你可以通过设置 model
参数来使用不同的模型:
model = PunctuationModel(model = "oliverguhr/fullstop-dutch-punctuation-prediction")
📄 许可证
本项目采用 MIT 许可证。
如何引用我们
@article{guhr-EtAl:2021:fullstop,
title={FullStop: Multilingual Deep Models for Punctuation Prediction},
author = {Guhr, Oliver and Schumann, Anne-Kathrin and Bahrmann, Frank and Böhme, Hans Joachim},
booktitle = {Proceedings of the Swiss Text Analytics Conference 2021},
month = {June},
year = {2021},
address = {Winterthur, Switzerland},
publisher = {CEUR Workshop Proceedings},
url = {http://ceur-ws.org/Vol-2957/sepp_paper4.pdf}
}
@misc{https://doi.org/10.48550/arxiv.2301.03319,
doi = {10.48550/ARXIV.2301.03319},
url = {https://arxiv.org/abs/2301.03319},
author = {Vandeghinste, Vincent and Guhr, Oliver},
keywords = {Computation and Language (cs.CL), Artificial Intelligence (cs.AI), FOS: Computer and information sciences, FOS: Computer and information sciences, I.2.7},
title = {FullStop:Punctuation and Segmentation Prediction for Dutch with Transformers},
publisher = {arXiv},
year = {2023},
copyright = {Creative Commons Attribution Share Alike 4.0 International}
}