mimba commited on
Commit
8b2a735
·
verified ·
1 Parent(s): 64042a3

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ assets/0.png filter=lfs diff=lfs merge=lfs -text
37
+ assets/2.png filter=lfs diff=lfs merge=lfs -text
38
+ step_1000000.t7 filter=lfs diff=lfs merge=lfs -text
39
+ step_950000.t7 filter=lfs diff=lfs merge=lfs -text
assets/0.png ADDED

Git LFS Details

  • SHA256: d9d3c93e9b5d2b28bab84fcd1539baa9619657ff05e03fb2ae91a41a5bccd92b
  • Pointer size: 131 Bytes
  • Size of remote file: 340 kB
assets/1.png ADDED
assets/2.png ADDED

Git LFS Details

  • SHA256: e3d965e6725c1be80b04eeca39d568fe3051ff39dcf87cd04a79003acb4d96d9
  • Pointer size: 131 Bytes
  • Size of remote file: 185 kB
plbert_plt_README.md ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - plt
4
+ license: cc-by-nc-sa-4.0
5
+ pretty_name: Mimba PL-BERT PLT (Plateau Malagasy Phonetic-Level BERT)
6
+ tags:
7
+ - text-to-speech
8
+ - pl-bert
9
+ - plbert
10
+ - albert
11
+ - malagasy
12
+ - plt
13
+ - african-languages
14
+ - low-resource
15
+ - masked-language-modeling
16
+ - phoneme
17
+ library_name: transformers
18
+ ---
19
+
20
+ # Mimba PL-BERT PLT — Phonetic-Level BERT for Plateau Malagasy
21
+
22
+ A **phonetic-level pre-trained language model (PL-BERT)** for **Plateau Malagasy (PLT)**,
23
+ trained from scratch to provide text/phoneme-context-aware embeddings for
24
+ **StyleTTS2** synthesis. Adapted from the original
25
+ [PL-BERT](https://github.com/yl4579/PL-BERT) architecture (Li et al., used in
26
+ StyleTTS2) and trained on a large phonemized Malagasy corpus with the same
27
+ 55-symbol phoneme vocabulary used across every Mimba PLT model (StyleTTS2,
28
+ NeuTTS-Nano, Supertonic 3).
29
+
30
+ > ⚠️ **Not a standalone TTS model.** PL-BERT is a text/phoneme encoder only —
31
+ > it produces contextual embeddings consumed by a downstream acoustic model
32
+ > (StyleTTS2 Stage 1/Stage 2). It cannot synthesize audio by itself.
33
+
34
+ ## Summary
35
+
36
+ | | |
37
+ |---|---|
38
+ | Language | Plateau Malagasy (`plt`) |
39
+ | Architecture | ALBERT (`transformers.AlbertModel` + 2 prediction heads) |
40
+ | Phoneme vocabulary | 55 symbols (`phoneme_symbols.pkl`, shared with StyleTTS2/NeuTTS-Nano) |
41
+ | Hidden size | 768 |
42
+ | Attention heads | 12 |
43
+ | Hidden layers | 12 |
44
+ | Intermediate size | 2048 |
45
+ | Max position embeddings | 512 |
46
+ | Dropout | 0.1 |
47
+ | Training objective | Masked language modeling, dual head (phoneme-level + word-level) |
48
+ | Training steps | 1,000,000 |
49
+ | Final masked-phoneme accuracy | **65.52%** (measured on ~200K masked positions) |
50
+ | Checkpoint format | `step_{N}.t7` (`{'net': state_dict, 'optimizer': ..., 'step': N}`) |
51
+
52
+
53
+ ### Loss curve
54
+
55
+ <!DOCTYPE html>
56
+ <html>
57
+ <head>
58
+ <style>
59
+ .conteneur-images {
60
+ display: flex; /* Active le mode horizontal */
61
+ gap: 10px; /* Espace de 10px entre les images */
62
+ }
63
+ .conteneur-images img {
64
+ width: 25%; /* 100% / 4 images = 25% */
65
+ height: auto; /* Maintient les proportions */
66
+ flex-shrink: 1; /* Permet de rétrécir si besoin */
67
+ }
68
+ </style>
69
+ </head>
70
+ <body>
71
+ <p class="conteneur-images">
72
+ <img src="assets/0.png" width="900" alt="Loss curve PL BERT">
73
+ <img src="assets/1.png" width="900" alt="Loss curve PL BERT">
74
+ <img src="assets/2.png" width="900" alt="Loss curve PL BERT">
75
+ </p>
76
+ </body>
77
+ </html>
78
+
79
+ ## Training details
80
+
81
+ The model is trained with a dual masked-language-modeling objective — one
82
+ head predicts the masked **phoneme token** (55-way classification), the other
83
+ predicts the masked **word form** (large open vocabulary of Malagasy word
84
+ forms, zipfian-distributed due to the language's agglutinative morphology).
85
+ Only the phoneme-level task is used downstream by StyleTTS2, but the joint
86
+ objective helps the encoder learn richer contextual representations.
87
+
88
+ Training ran for 1,000,000 steps with a cosine learning-rate decay
89
+ (`1e-4 → 1e-6`) applied over the final ~270K steps. Accuracy on masked
90
+ phoneme positions (measured periodically on held-out batches, not just
91
+ training loss) tracked as follows:
92
+
93
+ | Step | Masked-phoneme accuracy |
94
+ |---|---|
95
+ | 136,000 | 58.55% |
96
+ | 727,514 | 61–63% |
97
+ | 900,000 | 63.92% |
98
+ | 1,000,000 | **65.52%** |
99
+
100
+ Accuracy plateaued in the final third of training despite the LR decay
101
+ reaching down to `1e-6` — this is treated as the effective ceiling for this
102
+ model size/corpus, not a sign that more steps would help. For reference,
103
+ comparable phoneme/sup-phoneme masked-LM setups in other languages (e.g.
104
+ Mixed-Phoneme BERT, PnG-BERT) report converged accuracies around 70–75%;
105
+ this PLT model sits somewhat below that range, likely due to corpus size and
106
+ language-specific factors rather than an implementation issue.
107
+
108
+ ## Usage
109
+
110
+ ```python
111
+ import torch, yaml
112
+ from transformers import AlbertConfig, AlbertModel
113
+ from huggingface_hub import hf_hub_download
114
+ from collections import OrderedDict
115
+
116
+ REPO = "mimba/plbert-plt"
117
+
118
+ class CustomAlbert(AlbertModel):
119
+ def forward(self, *args, **kwargs):
120
+ return super().forward(*args, **kwargs).last_hidden_state
121
+
122
+ def load_plbert(repo_id=REPO, step=1_000_000):
123
+ config_path = hf_hub_download(repo_id, "config.yml")
124
+ plbert_config = yaml.safe_load(open(config_path))
125
+ config = AlbertConfig(**plbert_config["model_params"])
126
+ bert = CustomAlbert(config)
127
+
128
+ ckpt_path = hf_hub_download(repo_id, f"step_{step}.t7")
129
+ checkpoint = torch.load(ckpt_path, map_location="cpu")
130
+ state_dict = checkpoint["net"]
131
+
132
+ new_state_dict = OrderedDict()
133
+ for k, v in state_dict.items():
134
+ name = k[7:] if k.startswith("module.") else k
135
+ if name.startswith("encoder."):
136
+ new_state_dict[name[8:]] = v
137
+ new_state_dict.pop("embeddings.position_ids", None)
138
+ bert.load_state_dict(new_state_dict, strict=False)
139
+ return bert
140
+
141
+ model = load_plbert()
142
+ model.eval()
143
+ ```
144
+
145
+ **As a StyleTTS2 `PLBERT_dir`**: download `config.yml` + `step_1000000.t7`
146
+ into `Utils/PLBERT/` of the StyleTTS2 repo — `util.py`'s `load_plbert()`
147
+ (shown above) is what `train_first.py`/`train_second.py` call automatically.
148
+
149
+ ## Relation to other Mimba datasets/models
150
+
151
+ ```
152
+ mimba/text2text (source text corpus)
153
+ -> mimba/plt-tts-dataset (audio + text, 4 speakers)
154
+ -> phonemized PLT corpus (IPA phonemization, mode PHRASE)
155
+ -> mimba/plbert-plt <- this model
156
+ -> mimba/styletts2-plt-corpus (StyleTTS2-ready corpus)
157
+ -> mimba/styletts2-plt-stage1 / stage2 (StyleTTS2 checkpoints)
158
+ ```
159
+
160
+ ## Limitations
161
+
162
+ - Masked-phoneme accuracy (65.52%) is below reference points from other
163
+ languages' phoneme-level BERT models (~70–75%); treat this as this
164
+ model's practical ceiling rather than an intermediate result.
165
+ - The word-level prediction head operates over a very large, zipfian
166
+ vocabulary (agglutinative morphology) and is noisy on rare word forms —
167
+ this does not affect StyleTTS2 usage, which only consumes phoneme-level
168
+ embeddings.
169
+ - Trained on synthetic/derived text sources (see `mimba/text2text` and
170
+ `mimba/plt-tts-dataset` cards for provenance); verify licensing
171
+ independently before commercial use.
172
+
173
+ ## Citation
174
+
175
+ ```bibtex
176
+ @misc{mimba2026plbertplt,
177
+ title = {Mimba PL-BERT PLT: A Phonetic-Level BERT for Plateau Malagasy},
178
+ author = {Mimba Ngouana Fofou},
179
+ year = {2026},
180
+ }
181
+ ```
182
+
183
+ ### Contact
184
+
185
+ For questions or contributions, open a discussion in the "Community" tab of
186
+ this repository.
187
+
188
+ ##### *Contact: [@Mimba](baounabaouna@gmail.com)*
step_1000000.t7 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:041739bc315df409dfb9d09f88c9c4d392175e5e9a4cabc36aa28c253636646a
3
+ size 3762349415
step_1000000_meta.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"step": 1000000, "loss_vocab": 0.5753036141395569, "loss_token": 1.22299063205719, "accuracy": 65.51792630847154, "vocab_cap": 400000, "num_vocab": 400001, "num_tokens": 55}
step_950000.t7 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b30734e84fe38b51e08a134c38b83e8372b3ca40532821e297aa2b361fedfd3
3
+ size 3762349299
step_950000_meta.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"step": 950000, "loss_vocab": 0.946972668170929, "loss_token": 1.188152551651001, "accuracy": 66.25453100948408, "vocab_cap": 400000, "num_vocab": 400001, "num_tokens": 55}
train.log ADDED
The diff for this file is too large to render. See raw diff