rufaelfekadu commited on
Commit
440ac0f
·
verified ·
1 Parent(s): 2fcde3b

Upload model checkpoint and constants (http)

Browse files
Files changed (3) hide show
  1. README.md +121 -0
  2. best_model.ckpt +3 -0
  3. hparams.yaml +307 -0
README.md ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: ['ar']
3
+ tags:
4
+ - diacritization
5
+ - nlp
6
+ - arabic
7
+ metrics:
8
+ - DER
9
+ - WER
10
+ - SER
11
+ model_type: to_push
12
+ datasets:
13
+ - transformer-text-only
14
+ ---
15
+
16
+ # Model Card
17
+
18
+ This is a To_Push model for Arabic text diacritization.
19
+
20
+ ## Model Details
21
+
22
+ **Source checkpoint:** `/home/rufael/Projects/forced_alignment/Diac/results/to_push/transformer-text-only/tashkeela/tensorboard/version_0/checkpoints/best_model.ckpt`
23
+
24
+ **Included config files:**
25
+ - `/home/rufael/Projects/forced_alignment/Diac/results/to_push/transformer-text-only/tashkeela/tensorboard/version_0/hparams.yaml`
26
+
27
+ ## Evaluation Results
28
+
29
+ ### Evaluation on clartts
30
+
31
+ ### DER (Diacritic Error Rate)
32
+
33
+ | Configuration | With case ending | Without case ending |
34
+ |---|---|---|
35
+ | **Including no diacritic** | 10.33% | 8.45% |
36
+ | **Excluding no diacritic** | 12.72% | 10.33% |
37
+
38
+
39
+ ### WER (Word Error Rate)
40
+
41
+ | Configuration | With case ending | Without case ending |
42
+ |---|---|---|
43
+ | **Including no diacritic** | 30.16% | 19.71% |
44
+ | **Excluding no diacritic** | 29.91% | 19.60% |
45
+
46
+
47
+ ### SER (Sentence Error Rate)
48
+
49
+ | Configuration | With case ending | Without case ending |
50
+ |---|---|---|
51
+ | **Including no diacritic** | 91.62% | 79.34% |
52
+ | **Excluding no diacritic** | 91.62% | 79.34% |
53
+
54
+
55
+ ## How to Use
56
+
57
+ ### Installation
58
+
59
+ ```bash
60
+ pip install torch
61
+ ```
62
+
63
+ ### Loading the Model
64
+
65
+ ```python
66
+ from diac.models import DiacritizationModule
67
+
68
+ model = DiacritizationModule.from_pretrained(
69
+ "rufaelfekadu/diac-transformer-text-only-tashkeela",
70
+ tokenizer_constants_path="constants/" # Path to constants directory
71
+ )
72
+ ```
73
+
74
+ ### Running Inference
75
+
76
+ ```python
77
+ # Predict diacritization for a text file
78
+ model.predict_file(
79
+ input_file="path/to/input.txt",
80
+ output_file="path/to/output.txt"
81
+ )
82
+
83
+ # Or predict for a single text string
84
+ diacritized_text = model.predict_text("مرحبا بك")
85
+ ```
86
+
87
+ ### Running Evaluation
88
+
89
+ To evaluate the model on your own test set:
90
+
91
+ 1. **Run inference** to generate predictions:
92
+
93
+ ```bash
94
+ python inference.py \
95
+ --config configs/<model>.yml \
96
+ --opts \
97
+ DATA.TEST_PATH path/to/test.txt \
98
+ INFERENCE.MODEL_PATH <path_to_checkpoint> \
99
+ INFERENCE.OUTPUT_PATH path/to/predictions.txt
100
+ ```
101
+
102
+ 2. **Prepare reference file** (if needed):
103
+
104
+ ```bash
105
+ python src/diac/utils/prep_ref.py \
106
+ --input_file path/to/test.txt \
107
+ -o path/to/output_dir
108
+ ```
109
+
110
+ 3. **Calculate metrics** (DER, WER, SER):
111
+
112
+ ```bash
113
+ python src/diac/utils/eval.py \
114
+ -ofp path/to/predictions.txt \
115
+ -tfp path/to/reference.txt \
116
+ --style Fadel
117
+ ```
118
+
119
+ The evaluation script will output DER, WER, and SER metrics with different configurations:
120
+ - With/without case ending
121
+ - Including/excluding no diacritic
best_model.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5364a8e32a8847fd7152689508aed769c2675bc72120f751aa38e4096c2245a
3
+ size 8538913
hparams.yaml ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ config: !!python/object/new:yacs.config.CfgNode
2
+ dictitems:
3
+ CONSTANTS_PATH: constants/
4
+ DATA: !!python/object/new:yacs.config.CfgNode
5
+ dictitems:
6
+ MAX_LENGTH: 270
7
+ TEST_PATH: data/clartts/ClarTTS_test_Ref.txt
8
+ TRAIN_PATH: data/tashkeela/train.txt
9
+ VAL_PATH: data/tashkeela/val.txt
10
+ state:
11
+ __deprecated_keys__: !!set {}
12
+ __immutable__: true
13
+ __new_allowed__: false
14
+ __renamed_keys__: {}
15
+ INFERENCE: !!python/object/new:yacs.config.CfgNode
16
+ dictitems:
17
+ ASR_MODEL_NAME: sashat/whisper-medium-ClassicalAr
18
+ BATCH_SIZE: 16
19
+ BUFFER_SIZE: 25
20
+ DEVICE: cuda
21
+ FORCED_IDS: null
22
+ MAX_LENGTH: 300
23
+ MODEL_PATH: null
24
+ OUTPUT_PATH: results/transformer-text-only_clartts.txt
25
+ USE_ASR: false
26
+ WINDOW_SIZE: 50
27
+ state:
28
+ __deprecated_keys__: !!set {}
29
+ __immutable__: true
30
+ __new_allowed__: false
31
+ __renamed_keys__: {}
32
+ MODEL: !!python/object/new:yacs.config.CfgNode
33
+ dictitems:
34
+ ASR_VOCAB_SIZE: 91
35
+ DFF: 128
36
+ DROPOUT_RATE: 0.2
37
+ D_MODEL: 256
38
+ LOAD_TEXT_BRANCH_ONLY: false
39
+ MAXLEN: 272
40
+ NUM_BLOCKS: 2
41
+ NUM_HEADS: 4
42
+ OUTPUT_SIZE: 19
43
+ PRETRAINED_PATH: null
44
+ TYPE: Transformer
45
+ USE_ASR: false
46
+ VOCAB_SIZE: 77
47
+ WITH_CONN: false
48
+ state:
49
+ __deprecated_keys__: !!set {}
50
+ __immutable__: true
51
+ __new_allowed__: false
52
+ __renamed_keys__: {}
53
+ TRAIN: !!python/object/new:yacs.config.CfgNode
54
+ dictitems:
55
+ ACCUMULATE_GRAD_BATCHES: 1
56
+ BATCH_SIZE: 128
57
+ DEVICE: cuda
58
+ EARLY_STOPPING_PATIENCE: 10
59
+ EVAL_FREQ: 1
60
+ LEARNING_RATE: 0.001
61
+ NUM_EPOCHS: 100
62
+ SAVE_DIR: results/transformer-text-only/tashkeela
63
+ SAVE_FREQ: 30
64
+ VAL_CHECK_INTERVAL: 1.0
65
+ state:
66
+ __deprecated_keys__: !!set {}
67
+ __immutable__: true
68
+ __new_allowed__: false
69
+ __renamed_keys__: {}
70
+ state:
71
+ __deprecated_keys__: !!set {}
72
+ __immutable__: true
73
+ __new_allowed__: false
74
+ __renamed_keys__: {}
75
+ tokenizer: !!python/object:tokenizer.ArabicDiacritizationTokenizer
76
+ constants: !!python/object:tokenizer.TokenizerConstants
77
+ arabic_letters_list: "\u0621\u0622\u0623\u0624\u0625\u0626\u0627\u0628\u0629\u062A\
78
+ \u062B\u062C\u062D\u062E\u062F\u0630\u0631\u0632\u0633\u0634\u0635\u0636\u0637\
79
+ \u0638\u0639\u063A\u0641\u0642\u0643\u0644\u0645\u0646\u0647\u0648\u0649\u064A"
80
+ characters_mapping:
81
+ ? '
82
+
83
+ '
84
+ : 4
85
+ ' ': 5
86
+ '!': 6
87
+ '"': 7
88
+ '''': 8
89
+ (: 9
90
+ ): 10
91
+ '*': 11
92
+ ',': 12
93
+ '-': 13
94
+ .: 14
95
+ /: 15
96
+ '0': 16
97
+ '1': 17
98
+ '2': 18
99
+ '3': 19
100
+ '4': 20
101
+ '5': 21
102
+ '6': 22
103
+ '7': 23
104
+ '8': 24
105
+ '9': 25
106
+ ':': 26
107
+ ;: 27
108
+ <EOS>: 2
109
+ <PAD>: 0
110
+ <SOS>: 1
111
+ <UNK>: 3
112
+ '[': 28
113
+ ']': 29
114
+ '`': 30
115
+ '{': 31
116
+ '}': 32
117
+ '~': 33
118
+ "\xAB": 34
119
+ "\xBB": 35
120
+ "\u060C": 36
121
+ "\u061B": 37
122
+ "\u061F": 38
123
+ "\u0621": 39
124
+ "\u0622": 40
125
+ "\u0623": 41
126
+ "\u0624": 42
127
+ "\u0625": 43
128
+ "\u0626": 44
129
+ "\u0627": 45
130
+ "\u0628": 46
131
+ "\u0629": 47
132
+ "\u062A": 48
133
+ "\u062B": 49
134
+ "\u062C": 50
135
+ "\u062D": 51
136
+ "\u062E": 52
137
+ "\u062F": 53
138
+ "\u0630": 54
139
+ "\u0631": 55
140
+ "\u0632": 56
141
+ "\u0633": 57
142
+ "\u0634": 58
143
+ "\u0635": 59
144
+ "\u0636": 60
145
+ "\u0637": 61
146
+ "\u0638": 62
147
+ "\u0639": 63
148
+ "\u063A": 64
149
+ "\u0641": 65
150
+ "\u0642": 66
151
+ "\u0643": 67
152
+ "\u0644": 68
153
+ "\u0645": 69
154
+ "\u0646": 70
155
+ "\u0647": 71
156
+ "\u0648": 72
157
+ "\u0649": 73
158
+ "\u064A": 74
159
+ "\u200F": 75
160
+ "\u2013": 76
161
+ classes_mapping:
162
+ ? ''
163
+ : 0
164
+ <EOS>: 17
165
+ <N/A>: 18
166
+ <PAD>: 15
167
+ <SOS>: 16
168
+ "\u064B": 2
169
+ "\u064C": 4
170
+ "\u064D": 6
171
+ "\u064E": 1
172
+ "\u064F": 3
173
+ "\u0650": 5
174
+ "\u0651": 8
175
+ "\u0651\u064B": 10
176
+ "\u0651\u064C": 12
177
+ "\u0651\u064D": 14
178
+ "\u0651\u064E": 9
179
+ "\u0651\u064F": 11
180
+ "\u0651\u0650": 13
181
+ "\u0652": 7
182
+ diacritics_list:
183
+ - "\u064E"
184
+ - "\u064B"
185
+ - "\u0650"
186
+ - "\u064D"
187
+ - "\u064F"
188
+ - "\u064C"
189
+ - "\u0652"
190
+ - "\u0651"
191
+ expanded_vocabulary:
192
+ ? '
193
+
194
+ '
195
+ : 4
196
+ ' ': 5
197
+ '!': 6
198
+ '"': 7
199
+ '''': 8
200
+ (: 9
201
+ ): 10
202
+ '*': 11
203
+ ',': 12
204
+ '-': 13
205
+ .: 14
206
+ /: 15
207
+ '0': 16
208
+ '1': 17
209
+ '2': 18
210
+ '3': 19
211
+ '4': 20
212
+ '5': 21
213
+ '6': 22
214
+ '7': 23
215
+ '8': 24
216
+ '9': 25
217
+ ':': 26
218
+ ;: 27
219
+ <EOS>: 2
220
+ <PAD>: 0
221
+ <SOS>: 1
222
+ <UNK>: 3
223
+ '[': 28
224
+ ']': 29
225
+ '`': 30
226
+ '{': 31
227
+ '}': 32
228
+ '~': 33
229
+ "\xAB": 34
230
+ "\xBB": 35
231
+ "\u060C": 36
232
+ "\u061B": 37
233
+ "\u061F": 38
234
+ "\u0621": 39
235
+ "\u0622": 40
236
+ "\u0623": 41
237
+ "\u0624": 42
238
+ "\u0625": 43
239
+ "\u0626": 44
240
+ "\u0627": 45
241
+ "\u0628": 46
242
+ "\u0629": 47
243
+ "\u062A": 48
244
+ "\u062B": 49
245
+ "\u062C": 50
246
+ "\u062D": 51
247
+ "\u062E": 52
248
+ "\u062F": 53
249
+ "\u0630": 54
250
+ "\u0631": 55
251
+ "\u0632": 56
252
+ "\u0633": 57
253
+ "\u0634": 58
254
+ "\u0635": 59
255
+ "\u0636": 60
256
+ "\u0637": 61
257
+ "\u0638": 62
258
+ "\u0639": 63
259
+ "\u063A": 64
260
+ "\u0641": 65
261
+ "\u0642": 66
262
+ "\u0643": 67
263
+ "\u0644": 68
264
+ "\u0645": 69
265
+ "\u0646": 70
266
+ "\u0647": 71
267
+ "\u0648": 72
268
+ "\u0649": 73
269
+ "\u064A": 74
270
+ "\u064B": 78
271
+ "\u064C": 80
272
+ "\u064D": 82
273
+ "\u064E": 77
274
+ "\u064F": 79
275
+ "\u0650": 81
276
+ "\u0651": 84
277
+ "\u0651\u064B": 86
278
+ "\u0651\u064C": 88
279
+ "\u0651\u064D": 90
280
+ "\u0651\u064E": 85
281
+ "\u0651\u064F": 87
282
+ "\u0651\u0650": 89
283
+ "\u0652": 83
284
+ "\u200F": 75
285
+ "\u2013": 76
286
+ rev_classes_mapping:
287
+ 0: ''
288
+ 1: "\u064E"
289
+ 2: "\u064B"
290
+ 3: "\u064F"
291
+ 4: "\u064C"
292
+ 5: "\u0650"
293
+ 6: "\u064D"
294
+ 7: "\u0652"
295
+ 8: "\u0651"
296
+ 9: "\u0651\u064E"
297
+ 10: "\u0651\u064B"
298
+ 11: "\u0651\u064F"
299
+ 12: "\u0651\u064C"
300
+ 13: "\u0651\u0650"
301
+ 14: "\u0651\u064D"
302
+ 15: <PAD>
303
+ 16: <SOS>
304
+ 17: <EOS>
305
+ 18: <N/A>
306
+ constants_path: constants/
307
+ with_extra_train: false