Views
No views yet
punctuators:pip install punctuators1from punctuators.models import PunctCapSegModelONNX
2
3# Instantiate this model
4# This will download the ONNX and SPE models. To clean up, delete this model from your HF cache directory.
5m = PunctCapSegModelONNX.from_pretrained("pcs_47lang")
6
7# Define some input texts to punctuate
8input_texts: List[str] = [
9 "hola mundo cómo estás estamos bajo el sol y hace mucho calor santa coloma abre los huertos urbanos a las escuelas de la ciudad",
10 "hello friend how's it going it's snowing outside right now in connecticut a large storm is moving in",
11 "未來疫苗將有望覆蓋3歲以上全年齡段美國與北約軍隊已全部撤離還有鐵路公路在內的各項基建的來源都將枯竭",
12 "በባለፈው ሳምንት ኢትዮጵያ ከሶማሊያ 3 ሺህ ወታደሮቿንም እንዳስወጣች የሶማሊያው ዳልሳን ሬድዮ ዘግቦ ነበር ጸጥታ ሃይሉና ህዝቡ ተቀናጅቶ በመስራቱ በመዲናዋ ላይ የታቀደው የጥፋት ሴራ ከሽፏል",
13 "all human beings are born free and equal in dignity and rights they are endowed with reason and conscience and should act towards one another in a spirit of brotherhood",
14 "सभी मनुष्य जन्म से मर्यादा और अधिकारों में स्वतंत्र और समान होते हैं वे तर्क और विवेक से संपन्न हैं तथा उन्हें भ्रातृत्व की भावना से परस्पर के प्रति कार्य करना चाहिए",
15 "wszyscy ludzie rodzą się wolni i równi pod względem swej godności i swych praw są oni obdarzeni rozumem i sumieniem i powinni postępować wobec innych w duchu braterstwa",
16 "tous les êtres humains naissent libres et égaux en dignité et en droits ils sont doués de raison et de conscience et doivent agir les uns envers les autres dans un esprit de fraternité",
17]
18results: List[List[str]] = m.infer(input_texts)
19for input_text, output_texts in zip(input_texts, results):
20 print(f"Input: {input_text}")
21 print(f"Outputs:")
22 for text in output_texts:
23 print(f"\t{text}")
24 print()
251Input: hola mundo cómo estás estamos bajo el sol y hace mucho calor santa coloma abre los huertos urbanos a las escuelas de la ciudad
2Outputs:
3 Hola Mundo, ¿cómo estás?
4 Estamos bajo el sol y hace mucho calor.
5 Santa Coloma abre los huertos urbanos a las escuelas de la ciudad.
6
7Input: hello friend how's it going it's snowing outside right now in connecticut a large storm is moving in
8Outputs:
9 Hello Friend, how's it going?
10 It's snowing outside right now.
11 In Connecticut, a large storm is moving in.
12
13Input: 未來疫苗將有望覆蓋3歲以上全年齡段美國與北約軍隊已全部撤離還有鐵路公路在內的各項基建的來源都將枯竭
14Outputs:
15 未來,疫苗將有望覆蓋3歲以上全年齡段。
16 美國與北約軍隊已全部撤離。
17 還有鐵路公路在內的各項基建的來源都將枯竭。
18
19Input: በባለፈው ሳምንት ኢትዮጵያ ከሶማሊያ 3 ሺህ ወታደሮቿንም እንዳስወጣች የሶማሊያው ዳልሳን ሬድዮ ዘግቦ ነበር ጸጥታ ሃይሉና ህዝቡ ተቀናጅቶ በመስራቱ በመዲናዋ ላይ የታቀደው የጥፋት ሴራ ከሽፏል
20Outputs:
21 በባለፈው ሳምንት ኢትዮጵያ ከሶማሊያ 3 ሺህ ወታደሮቿንም እንዳስወጣች የሶማሊያው ዳልሳን ሬድዮ ዘግቦ ነበር።
22 ጸጥታ ሃይሉና ህዝቡ ተቀናጅቶ በመስራቱ በመዲናዋ ላይ የታቀደው የጥፋት ሴራ ከሽፏል።
23
24Input: all human beings are born free and equal in dignity and rights they are endowed with reason and conscience and should act towards one another in a spirit of brotherhood
25Outputs:
26 All human beings are born free and equal in dignity and rights.
27 They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood.
28
29Input: सभी मनुष्य जन्म से मर्यादा और अधिकारों में स्वतंत्र और समान होते हैं वे तर्क और विवेक से संपन्न हैं तथा उन्हें भ्रातृत्व की भावना से परस्पर के प्रति कार्य करना चाहिए
30Outputs:
31 सभी मनुष्य जन्म से मर्यादा और अधिकारों में स्वतंत्र और समान होते हैं।
32 वे तर्क और विवेक से संपन्न हैं तथा उन्हें भ्रातृत्व की भावना से परस्पर के प्रति कार्य करना चाहिए।
33
34Input: wszyscy ludzie rodzą się wolni i równi pod względem swej godności i swych praw są oni obdarzeni rozumem i sumieniem i powinni postępować wobec innych w duchu braterstwa
35Outputs:
36 Wszyscy ludzie rodzą się wolni i równi pod względem swej godności i swych praw.
37 Są oni obdarzeni rozumem i sumieniem i powinni postępować wobec innych w duchu braterstwa.
38
39Input: tous les êtres humains naissent libres et égaux en dignité et en droits ils sont doués de raison et de conscience et doivent agir les uns envers les autres dans un esprit de fraternité
40Outputs:
41 Tous les êtres humains naissent libres et égaux, en dignité et en droits.
42 Ils sont doués de raison et de conscience et doivent agir les uns envers les autres.
43 Dans un esprit de fraternité.
44
SentencePiece model with a vocabulary size of 64k.
Next, the input sequence is encoded with a base-sized Transformer, consisting of 6 layers with a model dimension of 512.¿.
Note that a ¿ can only appear if a ? is predicted, hence the conditioning.N-1 is a sentence boundary, token N is the first word of a sentence.
Concatenating this with the re-encoded text, each time step contains whether it is the first word of a sentence as predicted by the SBD head.N predictions per token, where N is the length of the subtoken.
(In practice, N is the longest possible subword, and the extra predictions are ignored).
This scheme captures acronyms, e.g., "NATO", as well as bi-capitalized words, e.g., "MacDonald".| Token | Description | Relevant Languages |
|---|---|---|
| . | Latin full stop | Many |
| , | Latin comma | Many |
| ? | Latin question mark | Many |
| ? | Full-width question mark | Chinese, Japanese |
| , | Full-width comma | Chinese, Japanese |
| 。 | Full-width full stop | Chinese, Japanese |
| 、 | Ideographic comma | Chinese, Japanese |
| ・ | Middle dot | Japanese |
| । | Danda | Hindi, Bengali, Oriya |
| ؟ | Arabic question mark | Arabic |
| ; | Greek question mark | Greek |
| ። | Ethiopic full stop | Amharic |
| ፣ | Ethiopic comma | Amharic |
| ፧ | Ethiopic question mark | Amharic |
| Token | Description | Relevant Languages |
|---|---|---|
| ¿ | Inverted question mark | Spanish |
Hola mundo, ¿cómo estás?Hola mundo. ¿Cómo estás?punct_post test report:
label precision recall f1 support
<NULL> (label_id: 0) 98.71 98.66 98.68 156605
. (label_id: 1) 87.72 88.85 88.28 8752
, (label_id: 2) 68.06 67.81 67.93 5216
? (label_id: 3) 79.38 77.20 78.27 693
? (label_id: 4) 0.00 0.00 0.00 0
, (label_id: 5) 0.00 0.00 0.00 0
。 (label_id: 6) 0.00 0.00 0.00 0
、 (label_id: 7) 0.00 0.00 0.00 0
・ (label_id: 8) 0.00 0.00 0.00 0
। (label_id: 9) 0.00 0.00 0.00 0
؟ (label_id: 10) 0.00 0.00 0.00 0
، (label_id: 11) 0.00 0.00 0.00 0
; (label_id: 12) 0.00 0.00 0.00 0
። (label_id: 13) 0.00 0.00 0.00 0
፣ (label_id: 14) 0.00 0.00 0.00 0
፧ (label_id: 15) 0.00 0.00 0.00 0
-------------------
micro avg 97.13 97.13 97.13 171266
macro avg 83.46 83.13 83.29 171266
weighted avg 97.13 97.13 97.13 171266
cap test report:
label precision recall f1 support
LOWER (label_id: 0) 99.63 99.49 99.56 526612
UPPER (label_id: 1) 89.19 91.84 90.50 24161
-------------------
micro avg 99.15 99.15 99.15 550773
macro avg 94.41 95.66 95.03 550773
weighted avg 99.17 99.15 99.16 550773
seg test report:
label precision recall f1 support
NOSTOP (label_id: 0) 99.37 99.42 99.39 162044
FULLSTOP (label_id: 1) 89.75 88.84 89.29 9222
-------------------
micro avg 98.85 98.85 98.85 171266
macro avg 94.56 94.13 94.34 171266
weighted avg 98.85 98.85 98.85 171266punct_pre test report:
label precision recall f1 support
<NULL> (label_id: 0) 99.94 99.92 99.93 185535
¿ (label_id: 1) 55.01 64.86 59.53 296
-------------------
micro avg 99.86 99.86 99.86 185831
macro avg 77.48 82.39 79.73 185831
weighted avg 99.87 99.86 99.87 185831
punct_post test report:
label precision recall f1 support
<NULL> (label_id: 0) 98.74 98.86 98.80 170282
. (label_id: 1) 90.07 89.58 89.82 9959
, (label_id: 2) 68.33 67.00 67.66 5300
? (label_id: 3) 70.25 58.62 63.91 290
? (label_id: 4) 0.00 0.00 0.00 0
, (label_id: 5) 0.00 0.00 0.00 0
。 (label_id: 6) 0.00 0.00 0.00 0
、 (label_id: 7) 0.00 0.00 0.00 0
・ (label_id: 8) 0.00 0.00 0.00 0
। (label_id: 9) 0.00 0.00 0.00 0
؟ (label_id: 10) 0.00 0.00 0.00 0
، (label_id: 11) 0.00 0.00 0.00 0
; (label_id: 12) 0.00 0.00 0.00 0
። (label_id: 13) 0.00 0.00 0.00 0
፣ (label_id: 14) 0.00 0.00 0.00 0
፧ (label_id: 15) 0.00 0.00 0.00 0
-------------------
micro avg 97.39 97.39 97.39 185831
macro avg 81.84 78.51 80.05 185831
weighted avg 97.36 97.39 97.37 185831
cap test report:
label precision recall f1 support
LOWER (label_id: 0) 99.62 99.60 99.61 555041
UPPER (label_id: 1) 90.60 91.06 90.83 23538
-------------------
micro avg 99.25 99.25 99.25 578579
macro avg 95.11 95.33 95.22 578579
weighted avg 99.25 99.25 99.25 578579
[NeMo I 2023-02-22 17:24:04 punct_cap_seg_model:427] seg test report:
label precision recall f1 support
NOSTOP (label_id: 0) 99.44 99.54 99.49 175908
FULLSTOP (label_id: 1) 91.68 89.98 90.82 9923
-------------------
micro avg 99.03 99.03 99.03 185831
macro avg 95.56 94.76 95.16 185831
weighted avg 99.02 99.03 99.02 185831punct_post test report:
label precision recall f1 support
<NULL> (label_id: 0) 98.82 97.34 98.07 147920
. (label_id: 1) 0.00 0.00 0.00 0
, (label_id: 2) 0.00 0.00 0.00 0
? (label_id: 3) 0.00 0.00 0.00 0
? (label_id: 4) 85.77 80.71 83.16 560
, (label_id: 5) 59.88 78.02 67.75 6901
。 (label_id: 6) 92.50 93.92 93.20 10988
、 (label_id: 7) 0.00 0.00 0.00 0
・ (label_id: 8) 0.00 0.00 0.00 0
। (label_id: 9) 0.00 0.00 0.00 0
؟ (label_id: 10) 0.00 0.00 0.00 0
، (label_id: 11) 0.00 0.00 0.00 0
; (label_id: 12) 0.00 0.00 0.00 0
። (label_id: 13) 0.00 0.00 0.00 0
፣ (label_id: 14) 0.00 0.00 0.00 0
፧ (label_id: 15) 0.00 0.00 0.00 0
-------------------
micro avg 96.25 96.25 96.25 166369
macro avg 84.24 87.50 85.55 166369
weighted avg 96.75 96.25 96.45 166369
cap test report:
label precision recall f1 support
LOWER (label_id: 0) 97.07 92.39 94.67 394
UPPER (label_id: 1) 70.59 86.75 77.84 83
-------------------
micro avg 91.40 91.40 91.40 477
macro avg 83.83 89.57 86.25 477
weighted avg 92.46 91.40 91.74 477
seg test report:
label precision recall f1 support
NOSTOP (label_id: 0) 99.58 99.53 99.56 156369
FULLSTOP (label_id: 1) 92.77 93.50 93.13 10000
-------------------
micro avg 99.17 99.17 99.17 166369
macro avg 96.18 96.52 96.35 166369
weighted avg 99.17 99.17 99.17 166369punct_post test report:
label precision recall f1 support
<NULL> (label_id: 0) 99.58 99.59 99.59 176743
. (label_id: 1) 0.00 0.00 0.00 0
, (label_id: 2) 68.32 65.23 66.74 1815
? (label_id: 3) 60.27 44.90 51.46 98
? (label_id: 4) 0.00 0.00 0.00 0
, (label_id: 5) 0.00 0.00 0.00 0
。 (label_id: 6) 0.00 0.00 0.00 0
、 (label_id: 7) 0.00 0.00 0.00 0
・ (label_id: 8) 0.00 0.00 0.00 0
। (label_id: 9) 96.45 97.43 96.94 10136
؟ (label_id: 10) 0.00 0.00 0.00 0
، (label_id: 11) 0.00 0.00 0.00 0
; (label_id: 12) 0.00 0.00 0.00 0
። (label_id: 13) 0.00 0.00 0.00 0
፣ (label_id: 14) 0.00 0.00 0.00 0
፧ (label_id: 15) 0.00 0.00 0.00 0
-------------------
micro avg 99.11 99.11 99.11 188792
macro avg 81.16 76.79 78.68 188792
weighted avg 99.10 99.11 99.10 188792
cap test report:
label precision recall f1 support
LOWER (label_id: 0) 98.25 95.06 96.63 708
UPPER (label_id: 1) 89.46 96.12 92.67 309
-------------------
micro avg 95.38 95.38 95.38 1017
macro avg 93.85 95.59 94.65 1017
weighted avg 95.58 95.38 95.42 1017
seg test report:
label precision recall f1 support
NOSTOP (label_id: 0) 99.87 99.85 99.86 178892
FULLSTOP (label_id: 1) 97.38 97.58 97.48 9900
-------------------
micro avg 99.74 99.74 99.74 188792
macro avg 98.62 98.72 98.67 188792
weighted avg 99.74 99.74 99.74 188792punct_post test report:
label precision recall f1 support
<NULL> (label_id: 0) 99.58 99.42 99.50 236298
. (label_id: 1) 0.00 0.00 0.00 0
, (label_id: 2) 0.00 0.00 0.00 0
? (label_id: 3) 0.00 0.00 0.00 0
? (label_id: 4) 0.00 0.00 0.00 0
, (label_id: 5) 0.00 0.00 0.00 0
。 (label_id: 6) 0.00 0.00 0.00 0
、 (label_id: 7) 0.00 0.00 0.00 0
・ (label_id: 8) 0.00 0.00 0.00 0
। (label_id: 9) 0.00 0.00 0.00 0
؟ (label_id: 10) 0.00 0.00 0.00 0
، (label_id: 11) 0.00 0.00 0.00 0
; (label_id: 12) 0.00 0.00 0.00 0
። (label_id: 13) 89.79 95.24 92.44 9169
፣ (label_id: 14) 66.85 56.58 61.29 1504
፧ (label_id: 15) 67.67 83.72 74.84 215
-------------------
micro avg 98.99 98.99 98.99 247186
macro avg 80.97 83.74 82.02 247186
weighted avg 98.99 98.99 98.98 247186
cap test report:
label precision recall f1 support
LOWER (label_id: 0) 96.65 99.78 98.19 1360
UPPER (label_id: 1) 98.90 85.13 91.50 316
-------------------
micro avg 97.02 97.02 97.02 1676
macro avg 97.77 92.45 94.84 1676
weighted avg 97.08 97.02 96.93 1676
seg test report:
label precision recall f1 support
NOSTOP (label_id: 0) 99.85 99.74 99.80 239845
FULLSTOP (label_id: 1) 91.72 95.25 93.45 7341
-------------------
micro avg 99.60 99.60 99.60 247186
macro avg 95.79 97.49 96.62 247186
weighted avg 99.61 99.60 99.61 247186