Update README.md
Browse files
README.md
CHANGED
|
@@ -1,150 +1,215 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: gpl-3.0
|
|
|
|
|
|
|
| 3 |
language:
|
| 4 |
- it
|
| 5 |
library_name: transformers
|
| 6 |
tags:
|
| 7 |
- DAC
|
|
|
|
| 8 |
- DATA-AI
|
|
|
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
# 🧠 microDAC
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
**Modello:** Decoder-only, 40M parametri
|
| 18 |
-
**Linguaggio target:** Italiano conversazionale
|
| 19 |
|
| 20 |
---
|
| 21 |
|
| 22 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
---
|
| 30 |
|
| 31 |
-
##
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
| Precisione | FP16/BF16 |
|
| 45 |
-
| Gradient checkpointing | ✅ Attivo |
|
| 46 |
|
| 47 |
---
|
| 48 |
|
| 49 |
## 🗣️ Tokenizer
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
- `<|user
|
| 55 |
-
- `<|assistant
|
| 56 |
-
- `<|sep
|
| 57 |
-
- `<|pad|>`, `<|bos|>`, `<|eos
|
| 58 |
|
| 59 |
-
Il tokenizer è salvato in `tokenizer_microDAC/` e viene
|
| 60 |
|
| 61 |
---
|
| 62 |
|
| 63 |
## 🎯 Obiettivo di training
|
| 64 |
|
| 65 |
-
Il modello è addestrato per generare
|
| 66 |
-
I token dell’utente vengono mascherati con `-100` nei label per evitare che il modello li imiti.
|
| 67 |
|
| 68 |
-
|
| 69 |
```text
|
| 70 |
<|user|> ... <|sep|> → label = -100
|
| 71 |
<|assistant|> ... <|sep|> → label = token_id
|
| 72 |
-
|
| 73 |
|
| 74 |
---
|
| 75 |
|
| 76 |
-
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|-------------------------|----------------|
|
| 80 |
-
| Epochs | 2 |
|
| 81 |
-
| Batch per device | 8 |
|
| 82 |
-
| Gradient accumulation | 4 |
|
| 83 |
-
| Learning rate | 3e-4 |
|
| 84 |
-
| Weight decay | 0.01 |
|
| 85 |
-
| Scheduler | Cosine |
|
| 86 |
-
| Warmup ratio | 0.05 |
|
| 87 |
-
| Max grad norm | 1.0 |
|
| 88 |
-
| Precision | FP16/BF16 |
|
| 89 |
-
| Optimizer | AdamW (torch) |
|
| 90 |
-
| Checkpointing | ogni 2000 step |
|
| 91 |
-
| Resume automatico | ✅ |
|
| 92 |
-
| Save best model | ✅ |
|
| 93 |
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
-
## 🖥️ Compatibilità e ambiente
|
| 97 |
|
| 98 |
-
- Sistema operativo: Windows (con `freeze_support`)
|
| 99 |
-
- GPU consigliata: ≥12 GB VRAM
|
| 100 |
-
- Framework: Hugging Face Transformers + Datasets
|
| 101 |
-
- Precisione: FP16/BF16 automatico
|
| 102 |
-
- Multiprocessing: gestito con `if __name__ == "__main__"` e `dataloader_num_workers=0`
|
| 103 |
|
| 104 |
---
|
| 105 |
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
-
Lo script cerca automaticamente l’ultimo checkpoint valido (`checkpoint-XXXX`) e riprende il training.
|
| 109 |
-
Se non trova nulla, parte da zero.
|
| 110 |
|
| 111 |
---
|
| 112 |
|
| 113 |
-
|
|
|
|
|
|
|
| 114 |
|
| 115 |
-
Alla fine del training, il modello e il tokenizer vengono salvati in:
|
| 116 |
-
```
|
| 117 |
./microDAC-40M/final/
|
| 118 |
-
```
|
| 119 |
|
| 120 |
Contiene:
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
---
|
| 128 |
|
| 129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
-
- Per aumentare la qualità: alza `N_LAYER` a 24 e `N_EMBD` a 768 (→ ~120M parametri)
|
| 132 |
-
- Per ridurre VRAM: abbassa `N_CTX` a 1024 e usa `adamw_bnb_8bit` con bitsandbytes
|
| 133 |
-
- Per training multi-turno: costruisci prompt concatenati con alternanza `<|user|>...<|assistant|>...` e maschera solo l’ultimo blocco
|
| 134 |
|
| 135 |
---
|
| 136 |
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
-
**Mattia — M.INC.**
|
| 140 |
-
Per domande tecniche, ottimizzazioni o estensioni del progetto, contattare il team AI di M.INC.
|
| 141 |
-
Questo file è pensato per essere modificabile e aggiornabile da qualsiasi sviluppatore.
|
| 142 |
|
| 143 |
---
|
| 144 |
|
| 145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
-
|
| 148 |
-
- [ ] Supporto FlashAttention
|
| 149 |
-
- [ ] Training multi-turno con contesto esteso
|
| 150 |
-
- [ ] Valutazione automatica su benchmark italiani
|
|
|
|
| 1 |
+
Perfetto 😎
|
| 2 |
+
Ecco la versione finale e completa della model card di microDAC, con i badge in stile professionale identico a quello del whitepaper di PicoDAC & PicoDAC-IT:
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
---
|
| 8 |
license: gpl-3.0
|
| 9 |
+
datasets:
|
| 10 |
+
- Mattimax/Little_ITA_60k
|
| 11 |
language:
|
| 12 |
- it
|
| 13 |
library_name: transformers
|
| 14 |
tags:
|
| 15 |
- DAC
|
| 16 |
+
- data-ai
|
| 17 |
- DATA-AI
|
| 18 |
+
- transformer
|
| 19 |
+
- experimental
|
| 20 |
+
new_version: Mattimax/microDAC
|
| 21 |
---
|
| 22 |
|
| 23 |
# 🧠 microDAC
|
| 24 |
|
| 25 |
+
[](https://huggingface.co/Mattimax)
|
| 26 |
+
[](https://huggingface.co/MINC01)
|
| 27 |
+
|
| 28 |
+

|
|
|
|
|
|
|
| 29 |
|
| 30 |
---
|
| 31 |
|
| 32 |
+
## ℹ️ Informazioni sul modello
|
| 33 |
+
|
| 34 |
+
- **Autore:** [Mattimax](https://huggingface.co/Mattimax)
|
| 35 |
+
- **Organizzazione:** [M.INC](https://huggingface.co/MINC01)
|
| 36 |
+
- **Pagina GitHub:** [microDAC](https://github.com/M-INC-01/microDAC)
|
| 37 |
+
- **Licenza:** GPL-3.0
|
| 38 |
|
| 39 |
+
**Descrizione:**
|
| 40 |
+
microDAC è un modello linguistico compatto di tipo *Decoder-only*, con circa **40 milioni di parametri**, progettato per la **generazione di testo in italiano**.
|
| 41 |
+
È un’evoluzione di PicoDAC, con maggiore profondità architetturale e un contesto più ampio, mantenendo leggerezza e velocità d’esecuzione.
|
| 42 |
|
| 43 |
+
Pensato per **chatbot, agenti vocali e applicazioni embedded**, è ottimizzato per risposte fluide, coerenti e naturali, con training supervisionato per evitare la ripetizione dei prompt.
|
| 44 |
|
| 45 |
---
|
| 46 |
|
| 47 |
+
## ⚙️ Caratteristiche tecniche
|
| 48 |
|
| 49 |
+
* **Architettura:** Transformer Decoder-only (GPT2-like)
|
| 50 |
+
* **Parametri totali:** ~40 milioni
|
| 51 |
+
* **Vocabolario:** 32.000 token
|
| 52 |
+
* **Lunghezza massima del contesto:** 2048 token
|
| 53 |
+
* **Dimensione embedding:** 512
|
| 54 |
+
* **Numero di layer:** 16
|
| 55 |
+
* **Teste di attenzione:** 8
|
| 56 |
+
* **Feed-Forward (FFN):** 2048 (GELU-new)
|
| 57 |
+
* **Attivazione:** GELU (new)
|
| 58 |
+
* **Precisione:** FP16 / BF16
|
| 59 |
+
* **Gradient checkpointing:** ✅ Attivo
|
|
|
|
|
|
|
| 60 |
|
| 61 |
---
|
| 62 |
|
| 63 |
## 🗣️ Tokenizer
|
| 64 |
|
| 65 |
+
* **Tipo:** Byte-Pair Encoding (BPE)
|
| 66 |
+
* **Addestramento:** da zero su `microDAC_dataset.jsonl`
|
| 67 |
+
* **Token speciali:**
|
| 68 |
+
- `<|user|>` → inizio turno utente
|
| 69 |
+
- `<|assistant|>` → risposta del modello
|
| 70 |
+
- `<|sep|>` → fine turno
|
| 71 |
+
- `<|pad|>`, `<|bos|>`, `<|eos|>` → padding e delimitatori
|
| 72 |
|
| 73 |
+
Il tokenizer è salvato in `tokenizer_microDAC/` e viene ricreato automaticamente se non presente.
|
| 74 |
|
| 75 |
---
|
| 76 |
|
| 77 |
## 🎯 Obiettivo di training
|
| 78 |
|
| 79 |
+
Il modello è addestrato per **generare esclusivamente le risposte dell’assistente**, mascherando i token dell’utente.
|
|
|
|
| 80 |
|
| 81 |
+
**Schema di masking:**
|
| 82 |
```text
|
| 83 |
<|user|> ... <|sep|> → label = -100
|
| 84 |
<|assistant|> ... <|sep|> → label = token_id
|
| 85 |
+
|
| 86 |
|
| 87 |
---
|
| 88 |
|
| 89 |
+
🧩 Parametri di training
|
| 90 |
|
| 91 |
+
Parametro Valore
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
+
Epochs 2
|
| 94 |
+
Batch per device 8
|
| 95 |
+
Gradient accumulation 4
|
| 96 |
+
Learning rate 3e-4
|
| 97 |
+
Weight decay 0.01
|
| 98 |
+
Scheduler Cosine
|
| 99 |
+
Warmup ratio 0.05
|
| 100 |
+
Max grad norm 1.0
|
| 101 |
+
Precision FP16 / BF16
|
| 102 |
+
Optimizer AdamW (torch)
|
| 103 |
+
Checkpointing ogni 2000 step
|
| 104 |
+
Resume automatico ✅
|
| 105 |
+
Save best model ✅
|
| 106 |
|
|
|
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
---
|
| 110 |
|
| 111 |
+
💻 Compatibilità e ambiente
|
| 112 |
+
|
| 113 |
+
OS: Windows / Linux
|
| 114 |
+
|
| 115 |
+
GPU consigliata: ≥ 12 GB VRAM
|
| 116 |
+
|
| 117 |
+
Framework: Hugging Face Transformers + Datasets
|
| 118 |
+
|
| 119 |
+
Precisione: FP16 / BF16 automatica
|
| 120 |
+
|
| 121 |
+
Multiprocessing: gestito con if __name__ == "__main__"
|
| 122 |
+
|
| 123 |
|
|
|
|
|
|
|
| 124 |
|
| 125 |
---
|
| 126 |
|
| 127 |
+
📦 Output finale
|
| 128 |
+
|
| 129 |
+
Alla fine del training, il modello viene salvato in:
|
| 130 |
|
|
|
|
|
|
|
| 131 |
./microDAC-40M/final/
|
|
|
|
| 132 |
|
| 133 |
Contiene:
|
| 134 |
+
|
| 135 |
+
pytorch_model.bin
|
| 136 |
+
|
| 137 |
+
config.json
|
| 138 |
+
|
| 139 |
+
tokenizer.json
|
| 140 |
+
|
| 141 |
+
special_tokens_map.json
|
| 142 |
+
|
| 143 |
+
vocab.json
|
| 144 |
+
|
| 145 |
+
|
| 146 |
|
| 147 |
---
|
| 148 |
|
| 149 |
+
⚠️ Avvertenze e limitazioni
|
| 150 |
+
|
| 151 |
+
microDAC è un modello sperimentale, soggetto a miglioramenti futuri.
|
| 152 |
+
|
| 153 |
+
Le prestazioni su conversazioni complesse o troppo lunghe possono degradare.
|
| 154 |
+
|
| 155 |
+
Non adatto a contenuti sensibili o critici.
|
| 156 |
+
|
| 157 |
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
---
|
| 160 |
|
| 161 |
+
🚀 Uso previsto
|
| 162 |
+
|
| 163 |
+
Chatbot leggeri e assistenti in lingua italiana
|
| 164 |
+
|
| 165 |
+
Prototipi embedded o mobile
|
| 166 |
+
|
| 167 |
+
Fine-tuning personalizzati su dataset specifici
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
Nota: mantenere input sotto i 2 000 token per risultati ottimali.
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
---
|
| 174 |
+
|
| 175 |
+
🧰 Installazione
|
| 176 |
+
|
| 177 |
+
pip install transformers torch
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
---
|
| 181 |
+
|
| 182 |
+
🧪 Esempio di utilizzo in Python
|
| 183 |
+
|
| 184 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 185 |
+
import torch
|
| 186 |
+
|
| 187 |
+
tokenizer = AutoTokenizer.from_pretrained("Mattimax/microDAC")
|
| 188 |
+
model = AutoModelForCausalLM.from_pretrained("Mattimax/microDAC").to("cuda")
|
| 189 |
+
|
| 190 |
+
prompt = "<|user|> Ciao, come stai oggi?<|assistant|>"
|
| 191 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 192 |
+
|
| 193 |
+
outputs = model.generate(**inputs, max_new_tokens=100, temperature=0.7)
|
| 194 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 195 |
|
|
|
|
|
|
|
|
|
|
| 196 |
|
| 197 |
---
|
| 198 |
|
| 199 |
+
🔗 Integrazione consigliata
|
| 200 |
+
|
| 201 |
+
Applicazioni mobile o embedded: basso consumo e rapidità.
|
| 202 |
+
|
| 203 |
+
Sperimentazione NLP: ottimo punto di partenza per LoRA o adattamenti leggeri.
|
| 204 |
+
|
| 205 |
+
Dataset sintetici: utile per generare coppie domanda-risposta.
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
---
|
| 210 |
+
|
| 211 |
+
📚 Riferimenti
|
| 212 |
+
|
| 213 |
+
Autore: [Mattimax](https://huggingface.co/Mattimax)
|
| 214 |
|
| 215 |
+
Organizzazione: M.INC
|
|
|
|
|
|
|
|
|