🚀 多語言標點預測模型
本項目的模型可對英文、意大利文、法文和德文文本進行標點預測,主要用於恢復轉錄口語中的標點。該多語言模型在 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}
}