File size: 9,143 Bytes
584b4c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4ba7177
584b4c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99ab93e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
584b4c2
 
 
50ba001
584b4c2
d6db3e4
 
 
 
f4b3f18
d6db3e4
 
f4b3f18
 
d6db3e4
c340886
d6db3e4
c340886
d6db3e4
7716e29
4bc3ac7
7716e29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d6db3e4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
---
license: mit
datasets:
- Mattimax/DATA-AI_Conversation_ITA
language:
- it
base_model:
- Mattimax/DACMini
library_name: transformers
tags:
- DAC
- DATA-AI
- data-ai
---

[![HuggingFace](https://img.shields.io/badge/HuggingFace-Mattimax-brightgreen)](https://huggingface.co/Mattimax)
[![M.INC](https://img.shields.io/badge/M.INC-Labs-blue)](https://huggingface.co/MINC01)

# Mattimax/DACMini-IT

![Logo di DACMini](https://huggingface.co/Mattimax/DACMini/resolve/main/DACMini_Logo/DACMini_Logo.png)

* **Autore:** [Mattimax](https://huggingface.co/Mattimax)
* **Organizzazione:** [M.INC](https://huggingface.co/MINC01)
* **Licenza:** MIT

---

## Descrizione

**DACMini-IT** è un modello di linguaggio compatto e instruction tuned per **chat e dialogo in lingua italiana**.
Basato sull’architettura **GPT-2 Small (italian adaptation)**, è progettato per essere rapido, leggero e facilmente distribuibile su dispositivi con risorse limitate.

Rispetto a DACMini “base”, **DACMini-IT** è addestrato su dataset italiani conversazionali strutturati in formato *user-assistant*, ottimizzando la capacità di seguire istruzioni e gestire conversazioni multi-turno naturali.

---

## Dimensioni e caratteristiche tecniche

* **Parametri:** 109M
* **Architettura:** GPT-2 Small (italian adaptation)
* **Lunghezza massima del contesto:** 512 token
* **Numero di strati:** 12
* **Numero di teste di attenzione:** 12
* **Dimensione embedding:** 768
* **Vocabolario:** ~50.000 token
* **Quantizzazione:** supportata (8-bit / 4-bit opzionale con `bitsandbytes`)

---

## Dataset di addestramento

Addestrato su [**Mattimax/DATA-AI_Conversation_ITA**](https://huggingface.co/datasets/Mattimax/DATA-AI_Conversation_ITA), un dataset italiano di dialoghi instruction tuned, contenente coppie *prompt-response* strutturate per favorire risposte coerenti, naturali e grammaticalmente corrette.

---

## Obiettivi

* Chatbot in lingua italiana con capacità di seguire istruzioni.
* Risposte concise, chiare e naturali in contesti multi-turno.
* Applicazioni leggere o offline dove la dimensione del modello è un vincolo.

---

## Avvertenze e limitazioni

* Modello **sperimentale**: può produrre errori logici o risposte non pertinenti.
* Non addestrato su temi sensibili o contenuti specialistici.
* Prestazioni limitate su conversazioni molto lunghe o prompt complessi.
* Non destinato ad usi commerciali senza ulteriore validazione.

---

## Uso consigliato

* Applicazioni chatbot leggere o offline in italiano.
* Prototipazione e test di pipeline NLP italiane.
* Generazione di risposte sintetiche e dataset per training o valutazione.

---

## Codice per inferenza di esempio

```python
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

# 1. Carica modello e tokenizer addestrati
model_path = "Mattimax/DACMini-IT"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(model_path)
model.eval()

# 2. Funzione di generazione
def chat_inference(prompt, max_new_tokens=150, temperature=0.7, top_p=0.9):
    # Costruisci input nel formato usato in training
    formatted_prompt = f"<|user|> {prompt.strip()} <|assistant|>"

    # Tokenizza
    inputs = tokenizer(formatted_prompt, return_tensors="pt")

    # Genera risposta
    with torch.no_grad():
        output = model.generate(
            **inputs,
            max_new_tokens=max_new_tokens,
            temperature=temperature,
            top_p=top_p,
            do_sample=True,
            pad_token_id=tokenizer.pad_token_id or tokenizer.eos_token_id
        )

    # Decodifica e rimuovi prompt iniziale
    generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
    response = generated_text.split("<|assistant|>")[-1].strip()
    return response

# 3. Esempio d’uso
if __name__ == "__main__":
    while True:
        user_input = input("👤 Utente: ")
        if user_input.lower() in ["exit", "quit"]:
            break
        response = chat_inference(user_input)
        print(f"🤖 Assistant: {response}\n")
````

## Referenze

* Dataset: [Mattimax/DATA-AI_Conversation_ITA](https://huggingface.co/datasets/Mattimax/DATA-AI_Conversation_ITA)
* Modello di base: [DACMini](https://huggingface.co/Mattimax/DACMini)
* Organizzazione: [M.INC](https://huggingface.co/MINC01)
* Collezione: [Little_DAC Collection](https://huggingface.co/collections/Mattimax/little-dac-collection-68e11d19a5949d08e672b312)

## Citazione

Se utilizzi **Mattimax/DACMini-IT** in un progetto, un articolo o qualsiasi lavoro, ti chiediamo gentilmente di citarlo usando il file `CITATION.bib` incluso nel repository:

```bibtex
@misc{mattimax2025dacminiit,
    title = {{Mattimax/DACMini-IT}: Un modello di linguaggio open source},
    author = {Mattimax},
    howpublished = {\url{https://huggingface.co/Mattimax/DACMini-IT}},
    year = {2025},
    note = {License: MIT. Se usi questo modello, per favore citane la fonte originale.}
}
```
---

# English version

## Description

**DACMini-IT** is a compact, instruction-tuned language model for **Italian chat and dialogue**.
Based on the **GPT-2 Small (Italian adaptation)** architecture, it is designed to be fast, lightweight, and easily deployable on low-resource devices.

Compared to the “base” DACMini, **DACMini-IT** is trained on Italian conversational datasets structured in *user-assistant* format, optimizing its ability to follow instructions and handle natural multi-turn conversations.

---

## Size and technical specs

* **Parameters:** 109M
* **Architecture:** GPT-2 Small (Italian adaptation)
* **Max context length:** 512 tokens
* **Number of layers:** 12
* **Number of attention heads:** 12
* **Embedding size:** 768
* **Vocabulary:** ~50,000 tokens
* **Quantization:** supported (optional 8-bit / 4-bit via `bitsandbytes`)

---

## Training dataset

Trained on [**Mattimax/DATA-AI_Conversation_ITA**](https://huggingface.co/datasets/Mattimax/DATA-AI_Conversation_ITA), an Italian instruction-tuned conversational dataset containing structured *prompt-response* pairs designed to promote coherent, natural, and grammatically correct answers.

---

## Objectives

* Italian-language chatbot with instruction-following capabilities.
* Concise, clear, and natural responses in multi-turn contexts.
* Lightweight or offline applications where model size is a constraint.

---

## Warnings and limitations

* **Experimental** model: may produce logical errors or irrelevant answers.
* Not trained on sensitive topics or specialized content.
* Limited performance on very long conversations or complex prompts.
* Not intended for commercial use without further validation.

---

## Recommended use

* Lightweight or offline Italian chatbot applications.
* Prototyping and testing of Italian NLP pipelines.
* Synthetic response generation and datasets for training or evaluation.

---

## Example inference code

```python
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

# 1. Load trained model and tokenizer
model_path = "Mattimax/DACMini-IT"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(model_path)
model.eval()

# 2. Generation function
def chat_inference(prompt, max_new_tokens=150, temperature=0.7, top_p=0.9):
    # Build input in the format used during training
    formatted_prompt = f"<|user|> {prompt.strip()} <|assistant|>"

    # Tokenize
    inputs = tokenizer(formatted_prompt, return_tensors="pt")

    # Generate response
    with torch.no_grad():
        output = model.generate(
            **inputs,
            max_new_tokens=max_new_tokens,
            temperature=temperature,
            top_p=top_p,
            do_sample=True,
            pad_token_id=tokenizer.pad_token_id or tokenizer.eos_token_id
        )

    # Decode and remove initial prompt
    generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
    response = generated_text.split("<|assistant|>")[-1].strip()
    return response

# 3. Usage example
if __name__ == "__main__":
    while True:
        user_input = input("👤 User: ")
        if user_input.lower() in ["exit", "quit"]:
            break
        response = chat_inference(user_input)
        print(f"🤖 Assistant: {response}\n")
```

---

## References

* Dataset: [Mattimax/DATA-AI_Conversation_ITA](https://huggingface.co/datasets/Mattimax/DATA-AI_Conversation_ITA)
* Base model: [DACMini](https://huggingface.co/Mattimax/DACMini)
* Organization: [M.INC](https://huggingface.co/MINC01)
* Collection: [Little_DAC Collection](https://huggingface.co/collections/Mattimax/little-dac-collection-68e11d19a5949d08e672b312)

---

## Citation

If you use **Mattimax/DACMini-IT** in a project, paper, or any work, please cite it using the `CITATION.bib` file included in the repository:

```bibtex
@misc{mattimax2025dacminiit,
    title = {{Mattimax/DACMini-IT}: An open-source language model},
    author = {Mattimax},
    howpublished = {\url{https://huggingface.co/Mattimax/DACMini-IT}},
    year = {2025},
    note = {License: MIT. If you use this model, please cite the original source.}
}
```