Instructions to use lbertolino/MLK-de-Vila-1.0-1.3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use lbertolino/MLK-de-Vila-1.0-1.3B with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("lbertolino/MLK-de-Vila-1.0-1.3B") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- MLX LM
How to use lbertolino/MLK-de-Vila-1.0-1.3B with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "lbertolino/MLK-de-Vila-1.0-1.3B"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "lbertolino/MLK-de-Vila-1.0-1.3B" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lbertolino/MLK-de-Vila-1.0-1.3B", "messages": [ {"role": "user", "content": "Hello"} ] }' - Atomic Chat
MLK de Vila 1.0-1.3B
LLM de educaรงรฃo financeira que fala a lรญngua da periferia brasileira
MLK de Vila รฉ um modelo de linguagem fine-tuned para ser um educador financeiro que compreende e responde no dialeto da periferia brasileira. Treinado inteiramente em hardware acessรญvel (8GB de memรณria, GPU integrada, processador ARM).
Model Details
| Attribute | Value |
|---|---|
| Base Model | mlx-community/gemma-3-1b-it-bf16 (Gemma 3 1B IT) |
| Architecture | Gemma3ForCausalLM |
| Parameters | 1,301,875,840 (~1.3B) |
| Format | bf16 (safetensors) |
| Framework | MLX (Apple Silicon) |
| Size | ~2.6 GB |
| Training Pipeline | CPT โ fuse โ SFT โ fuse โ DPO โ fuse |
| Training Data | ~842,000 tokens |
| Peak Memory | 5.08 GB |
| Total Training Time | ~4 hours |
| Hardware | 8GB RAM, GPU integrada, ARM |
Training Pipeline
Gemma 3 1B IT โโCPTโโโ Dialeto bruto โโSFTโโโ Dialeto + Conteรบdo โโDPOโโโ Modelo Final
โ โ โ โ
Vocabulรกrio Como falar O que falar Qual estilo
e estruturas da periferia sobre finanรงas preferir
Continuous Pre-Training (CPT)
- Data: 302k tokens โ 99 transcriรงรตes YouTube, artigos, textos sintรฉticos em dialeto
- Config: LoRA rank 32, scale 20.0, 10 layers, LR 2e-5, 500 iters
- Result: Val loss 4.362 โ 3.258 (25% reduction)
Supervised Fine-Tuning (SFT)
- Data: 180k tokens โ 558 instruction-response pairs (94 financial topics, 64 slang terms)
- Config: LoRA rank 16, scale 10.0, 12 layers, LR 1e-5, 1950 iters
- Result: Val loss 4.518 โ 1.587
Direct Preference Optimization (DPO)
- Data: 360k tokens โ 564 preference pairs (dialect chosen vs formal rejected)
- Config: LoRA rank 4, 4 layers, 479K params, beta 0.3, LR 1e-6, 300 iters
- Result: Loss 0.693 โ 0.495
Results
Benchmark (16 questions: 8 formal + 8 dialect)
| Stage | Functional Responses | Uses Dialect |
|---|---|---|
| Base (Gemma 3 1B IT) | 16/16 | 0/16 |
| After CPT | 16/16 | Partial |
| After SFT | 16/16 | 14/16 |
| After DPO (this model) | 16/16 | 16/16 |
Interpretability Test
Input (100% slang):
"Ae parceiro, to no busรฃo chegando na quebrada, mano esse bagulho de grana รฉ embaรงado, vocรช dรก mรณ trampo e essa parada de inflaรงรฃo engole sua grana. Na moral, papo reto memo, vocรช precisa pegar a visรฃo de investir."
Model response:
"Vou te passar a visรฃo de investir, mas รฉ importante entender que nรฃo รฉ pra ser feito no seu bolso. Se vocรช รฉ um estudante, um jovem de 17 anos, tem que ter um plano. O dinheiro que vocรช ganha no mรชs รฉ pra ser usado com responsabilidade. Por exemplo, se vocรช รฉ MEI e tem R$ 1.200 por mรชs, รฉ melhor que vocรช anote cada centavo que recebe e distribua para despesas fixas, como aluguel, contas, e depois deixar um monte pra investir."
The model: (1) understood the intent, (2) responded in dialect ("passar a visรฃo"), (3) provided concrete financial advice contextualized for a young person.
How to Use
With MLX (recommended for Apple Silicon)
from mlx_lm import load, generate
model, tokenizer = load("lbertolino/MLK-de-Vila-1.0-1.3B")
# IMPORTANT: <end_of_turn> is NOT EOS in Gemma 3 โ must add manually
tokenizer.add_eos_token("<end_of_turn>")
messages = [{"role": "user", "content": "Mano, como organizar a grana do mรชs?"}]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
response = generate(model, tokenizer, prompt=prompt, max_tokens=500)
print(response)
Gradio Demo
git clone https://github.com/LeviBertolino/MLK-De-Vila.git
cd MLK-De-Vila
pip install mlx-lm gradio
python app.py
Important Notes
<end_of_turn>is NOT EOS in Gemma 3. You MUST addtokenizer.add_eos_token("<end_of_turn>")or the model will generate infinitely after the end of turn.Do NOT use system messages. The model was trained with
mask_prompt=True, which means it never learned to associate system messages with response style. Including a system message causes immediate<end_of_turn>generation.This model is optimized for MLX on Apple Silicon. For other frameworks, you may need to convert the weights.
Training Data
| Stage | Tokens | Proportion |
|---|---|---|
| CPT | ~302,000 | 36% |
| SFT | ~180,000 | 21% |
| DPO | ~360,000 | 43% |
| Total | ~842,000 | 100% |
The 64 slang terms used include: mano, parceiro, trampo, grana, bico, quebrada, padoca, busรฃo, corre, maloca, perrengue, rolรช, bagulho, embaรงado, suave, de boa, na moral, pode crer, รฉ nรณis, tรก ligado, passa a visรฃo, papo reto, correria, among others.
Key Technical Discoveries
- Aggressive CPT is essential to break the alignment resistance of instruction-tuned models
- 6 bad examples (1% of dataset) corrupted the entire SFT โ data quality > quantity
- RAG cannot achieve dialect adaptation โ it operates on content, not style
alphaparameter is ignored by mlx-lm โ onlyrank,scale,dropoutare effective- System message + mask_prompt = broken โ model generates immediate
<end_of_turn>
Limitations
- Small CPT corpus (~302k tokens) โ more authentic speech data could deepen comprehension
- Qualitative benchmark with 16 questions โ automatic dialect metrics are needed
- Aggressive CPT can introduce undesirable associations (e.g., periferia โ crime) corrected by SFT/DPO
- Some SFT/DPO responses show repetitions, suggesting incomplete fluency internalization
- Deep/uncommon slang (e.g., "goma" = work) still has limited comprehension
Paper & Code
- Paper: GitHub README
- Code: GitHub Repository
- Datasets: Included in the GitHub repository under
data/
Citation
@misc{bertolino2025mlkdevila,
title={Mlk de Vila: Fine-Tuning de LLMs para Educaรงรฃo Financeira no Dialeto da Periferia Brasileira},
author={Bertolino, Levi},
year={2025},
url={https://github.com/LeviBertolino/MLK-De-Vila}
}
License
Apache 2.0 โ Same as the base model (Gemma 3).
"Quando o jovem da quebrada pergunta 'Mano, como organizar a grana do mรชs?' e o modelo responde com orientaรงรฃo financeira concreta no dialeto dele โ isso nรฃo รฉ traduรงรฃo. ร comunicaรงรฃo."
- Downloads last month
- 11
Quantized
Model tree for lbertolino/MLK-de-Vila-1.0-1.3B
Base model
google/gemma-3-1b-ptEvaluation results
- Functional Responsesself-reported100.000
- Dialect Usage (DPO)self-reported100.000