Views
No views yet
ACRONYM allows fully punctuating tokens such as "pm" → "p.m.".SentencePiece tokenizer and an ONNX graph.pip install punctuators1from typing import List
2
3from punctuators.models import PunctCapSegModelONNX
4
5# Instantiate this model
6# This will download the ONNX and SPE models. To clean up, delete this model from your HF cache directory.
7m = PunctCapSegModelONNX.from_pretrained("pcs_romance")
8
9# Define some input texts to punctuate, at least one per language
10input_texts: List[str] = [
11 "este modelo fue entrenado en un gpu a100 en realidad no se que dice esta frase lo traduje con nmt",
12 "hola amigo cómo estás es un día lluvioso hoy",
13 "hola amic com va avui ha estat un dia plujós el català prediu massa puntuació per com s'ha entrenat",
14 "ciao amico come va oggi è stata una giornata piovosa",
15 "olá amigo como tá indo estava chuvoso hoje",
16 "salut l'ami comment ça va il pleuvait aujourd'hui",
17 "salut prietene cum stă treaba azi a fost ploios",
18]
19results: List[List[str]] = m.infer(input_texts)
20for input_text, output_texts in zip(input_texts, results):
21 print(f"Input: {input_text}")
22 print(f"Outputs:")
23 for text in output_texts:
24 print(f"\t{text}")
25 print()
261Input: este modelo fue entrenado en un gpu a100 en realidad no se que dice esta frase lo traduje con nmt
2Outputs:
3 Este modelo fue entrenado en un GPU A100.
4 En realidad, no se que dice esta frase lo traduje con NMT.
5
6Input: hola amigo cómo estás es un día lluvioso hoy
7Outputs:
8 Hola, amigo.
9 ¿Cómo estás?
10 Es un día lluvioso hoy.
11
12Input: hola amic com va avui ha estat un dia plujós el català prediu massa puntuació per com s'ha entrenat
13Outputs:
14 Hola, amic.
15 Com va avui?
16 Ha estat un dia plujós.
17 El català prediu massa puntuació per com s'ha entrenat.
18
19Input: ciao amico come va oggi è stata una giornata piovosa
20Outputs:
21 Ciao amico, come va?
22 Oggi è stata una giornata piovosa.
23
24Input: olá amigo como tá indo estava chuvoso hoje
25Outputs:
26 Olá, amigo, como tá indo?
27 Estava chuvoso hoje.
28
29Input: salut l'ami comment ça va il pleuvait aujourd'hui
30Outputs:
31 Salut l'ami.
32 Comment ça va?
33 Il pleuvait aujourd'hui.
34
35Input: salut prietene cum stă treaba azi a fost ploios
36Outputs:
37 Salut prietene, cum stă treaba azi?
38 A fost ploios.1input_texts: List[str] = [
2 "hola amigo cómo estás es un día lluvioso hoy",
3]
4results: List[str] = m.infer(input_texts, apply_sbd=False)
5print(results[0])List[List[str]] (a list of output sentences for each input), we get a List[str] (one output
sentence per input):Hola, amigo. ¿Cómo estás? Es un día lluvioso hoy.OpenSubtitles was used for Catalan.
Due to this, Catalan performance may be sub-par and may over-predict punctuation and sentence breaks, which is typical of OpenSubtitles.punctuators package can punctuate inputs of any length.
This is accomplished behind the scenes by splitting the input into overlapping subsegments of 256 tokens, and combining the results.1Pre-punctuation report:
2 label precision recall f1 support
3 <NULL> (label_id: 0) 99.92 99.97 99.95 572069
4 ¿ (label_id: 1) 81.93 60.46 69.57 1095
5 -------------------
6 micro avg 99.90 99.90 99.90 573164
7 macro avg 90.93 80.22 84.76 573164
8 weighted avg 99.89 99.90 99.89 573164
9
10Punctuation report:
11 label precision recall f1 support
12 <NULL> (label_id: 0) 98.70 98.44 98.57 517310
13 <ACRONYM> (label_id: 1) 39.68 86.21 54.35 58
14 . (label_id: 2) 87.72 90.41 89.04 29267
15 , (label_id: 3) 73.17 74.68 73.92 25422
16 ? (label_id: 4) 69.49 59.26 63.97 1107
17 -------------------
18 micro avg 96.90 96.90 96.90 573164
19 macro avg 73.75 81.80 75.97 573164
20 weighted avg 96.94 96.90 96.92 573164
21
22True-casing report:
23 label precision recall f1 support
24 LOWER (label_id: 0) 99.85 99.73 99.79 2164982
25 UPPER (label_id: 1) 92.01 95.32 93.64 69437
26 -------------------
27 micro avg 99.60 99.60 99.60 2234419
28 macro avg 95.93 97.53 96.71 2234419
29 weighted avg 99.61 99.60 99.60 2234419
30
31Fullstop report:
32 label precision recall f1 support
33 NOSTOP (label_id: 0) 100.00 99.98 99.99 543228
34 FULLSTOP (label_id: 1) 99.66 99.93 99.80 32931
35 -------------------
36 micro avg 99.98 99.98 99.98 576159
37 macro avg 99.83 99.96 99.89 576159
38 weighted avg 99.98 99.98 99.98 5761591Pre-punctuation report:
2 label precision recall f1 support
3 <NULL> (label_id: 0) 100.00 100.00 100.00 539822
4 ¿ (label_id: 1) 0.00 0.00 0.00 0
5 -------------------
6 micro avg 100.00 100.00 100.00 539822
7 macro avg 100.00 100.00 100.00 539822
8 weighted avg 100.00 100.00 100.00 539822
9
10Punctuation report:
11 label precision recall f1 support
12 <NULL> (label_id: 0) 98.77 98.27 98.52 481148
13 <ACRONYM> (label_id: 1) 0.00 0.00 0.00 0
14 . (label_id: 2) 87.63 90.63 89.11 29090
15 , (label_id: 3) 74.44 78.69 76.50 28549
16 ? (label_id: 4) 66.30 52.27 58.45 1035
17 -------------------
18 micro avg 96.74 96.74 96.74 539822
19 macro avg 81.79 79.96 80.65 539822
20 weighted avg 96.82 96.74 96.77 539822
21
22True-casing report:
23 label precision recall f1 support
24 LOWER (label_id: 0) 99.90 99.82 99.86 2082598
25 UPPER (label_id: 1) 94.75 97.08 95.90 70555
26 -------------------
27 micro avg 99.73 99.73 99.73 2153153
28 macro avg 97.32 98.45 97.88 2153153
29 weighted avg 99.73 99.73 99.73 2153153
30
31Fullstop report:
32 label precision recall f1 support
33 NOSTOP (label_id: 0) 100.00 99.98 99.99 509905
34 FULLSTOP (label_id: 1) 99.72 99.98 99.85 32909
35 -------------------
36 micro avg 99.98 99.98 99.98 542814
37 macro avg 99.86 99.98 99.92 542814
38 weighted avg 99.98 99.98 99.98 542814
391Pre-punctuation report:
2 label precision recall f1 support
3 <NULL> (label_id: 0) 100.00 100.00 100.00 580702
4 ¿ (label_id: 1) 0.00 0.00 0.00 0
5 -------------------
6 micro avg 100.00 100.00 100.00 580702
7 macro avg 100.00 100.00 100.00 580702
8 weighted avg 100.00 100.00 100.00 580702
9
10Punctuation report:
11 label precision recall f1 support
12 <NULL> (label_id: 0) 98.56 98.47 98.51 520647
13 <ACRONYM> (label_id: 1) 52.00 79.89 63.00 179
14 . (label_id: 2) 87.29 89.37 88.32 29852
15 , (label_id: 3) 75.26 74.69 74.97 29218
16 ? (label_id: 4) 60.73 55.46 57.98 806
17 -------------------
18 micro avg 96.74 96.74 96.74 580702
19 macro avg 74.77 79.57 76.56 580702
20 weighted avg 96.74 96.74 96.74 580702
21
22Truecasing report:
23 label precision recall f1 support
24 LOWER (label_id: 0) 99.84 99.75 99.79 2047297
25 UPPER (label_id: 1) 93.56 95.65 94.59 77424
26 -------------------
27 micro avg 99.60 99.60 99.60 2124721
28 macro avg 96.70 97.70 97.19 2124721
29 weighted avg 99.61 99.60 99.60 2124721
30
31Fullstop report:
32 label precision recall f1 support
33 NOSTOP (label_id: 0) 100.00 99.96 99.98 550858
34 FULLSTOP (label_id: 1) 99.26 99.94 99.60 32833
35 -------------------
36 micro avg 99.95 99.95 99.95 583691
37 macro avg 99.63 99.95 99.79 583691
38 weighted avg 99.96 99.95 99.96 583691
391Pre-punctuation report:
2 label precision recall f1 support
3 <NULL> (label_id: 0) 100.00 100.00 100.00 577636
4 ¿ (label_id: 1) 0.00 0.00 0.00 0
5 -------------------
6 micro avg 100.00 100.00 100.00 577636
7 macro avg 100.00 100.00 100.00 577636
8 weighted avg 100.00 100.00 100.00 577636
9
10Punctuation report:
11 label precision recall f1 support
12 <NULL> (label_id: 0) 98.10 97.73 97.91 522727
13 <ACRONYM> (label_id: 1) 41.76 48.72 44.97 78
14 . (label_id: 2) 81.71 86.70 84.13 28881
15 , (label_id: 3) 61.72 63.24 62.47 24703
16 ? (label_id: 4) 62.55 41.78 50.10 1247
17 -------------------
18 micro avg 95.58 95.58 95.58 577636
19 macro avg 69.17 67.63 67.92 577636
20 weighted avg 95.64 95.58 95.60 577636
21
22Truecasing report:
23 label precision recall f1 support
24 LOWER (label_id: 0) 99.76 99.70 99.73 2160781
25 UPPER (label_id: 1) 91.18 92.76 91.96 72471
26 -------------------
27 micro avg 99.47 99.47 99.47 2233252
28 macro avg 95.47 96.23 95.85 2233252
29 weighted avg 99.48 99.47 99.48 2233252
30
31Fullstop report:
32 label precision recall f1 support
33 NOSTOP (label_id: 0) 99.99 99.98 99.99 547875
34 FULLSTOP (label_id: 1) 99.72 99.91 99.82 32742
35 -------------------
36 micro avg 99.98 99.98 99.98 580617
37 macro avg 99.86 99.95 99.90 580617
38 weighted avg 99.98 99.98 99.98 5806171Pre-punctuation report:
2 label precision recall f1 support
3 <NULL> (label_id: 0) 100.00 100.00 100.00 614010
4 ¿ (label_id: 1) 0.00 0.00 0.00 0
5 -------------------
6 micro avg 100.00 100.00 100.00 614010
7 macro avg 100.00 100.00 100.00 614010
8 weighted avg 100.00 100.00 100.00 614010
9
10Punctuation report:
11 label precision recall f1 support
12 <NULL> (label_id: 0) 98.72 98.57 98.65 556366
13 <ACRONYM> (label_id: 1) 38.46 71.43 50.00 49
14 . (label_id: 2) 86.41 88.56 87.47 28969
15 , (label_id: 3) 72.15 72.80 72.47 27183
16 ? (label_id: 4) 75.81 67.78 71.57 1443
17 -------------------
18 micro avg 96.88 96.88 96.88 614010
19 macro avg 74.31 79.83 76.03 614010
20 weighted avg 96.91 96.88 96.89 614010
21
22Truecasing report:
23 label precision recall f1 support
24 LOWER (label_id: 0) 99.84 99.80 99.82 2127174
25 UPPER (label_id: 1) 93.72 94.73 94.22 66496
26 -------------------
27 micro avg 99.65 99.65 99.65 2193670
28 macro avg 96.78 97.27 97.02 2193670
29 weighted avg 99.65 99.65 99.65 2193670
30
31Fullstop report:
32 label precision recall f1 support
33 NOSTOP (label_id: 0) 99.99 99.94 99.97 584331
34 FULLSTOP (label_id: 1) 98.92 99.90 99.41 32661
35 -------------------
36 micro avg 99.94 99.94 99.94 616992
37 macro avg 99.46 99.92 99.69 616992
38 weighted avg 99.94 99.94 99.94 616992
391Pre-punctuation report:
2 label precision recall f1 support
3 <NULL> (label_id: 0) 99.97 100.00 99.98 143817
4 ¿ (label_id: 1) 0.00 0.00 0.00 50
5 -------------------
6 micro avg 99.97 99.97 99.97 143867
7 macro avg 49.98 50.00 49.99 143867
8 weighted avg 99.93 99.97 99.95 143867
9
10Punctuation report:
11 label precision recall f1 support
12 <NULL> (label_id: 0) 97.61 97.73 97.67 119040
13 <ACRONYM> (label_id: 1) 0.00 0.00 0.00 28
14 . (label_id: 2) 74.02 79.46 76.65 15282
15 , (label_id: 3) 60.88 50.75 55.36 5836
16 ? (label_id: 4) 64.94 60.28 62.52 3681
17 -------------------
18 micro avg 92.90 92.90 92.90 143867
19 macro avg 59.49 57.64 58.44 143867
20 weighted avg 92.76 92.90 92.80 143867
21
22Truecasing report:
23 label precision recall f1 support
24 LOWER (label_id: 0) 99.81 99.83 99.82 422395
25 UPPER (label_id: 1) 97.09 96.81 96.95 24854
26 -------------------
27 micro avg 99.66 99.66 99.66 447249
28 macro avg 98.45 98.32 98.39 447249
29 weighted avg 99.66 99.66 99.66 447249
30
31Fullstop report:
32 label precision recall f1 support
33 NOSTOP (label_id: 0) 99.93 99.63 99.78 123867
34 FULLSTOP (label_id: 1) 97.97 99.59 98.77 22000
35 -------------------
36 micro avg 99.63 99.63 99.63 145867
37 macro avg 98.95 99.61 99.28 145867
38 weighted avg 99.63 99.63 99.63 145867
39