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

  1. <end_of_turn> is NOT EOS in Gemma 3. You MUST add tokenizer.add_eos_token("<end_of_turn>") or the model will generate infinitely after the end of turn.

  2. 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.

  3. 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
  • alpha parameter is ignored by mlx-lm โ€” only rank, scale, dropout are 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

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
Safetensors
Model size
1B params
Tensor type
BF16
ยท
MLX
Hardware compatibility
Log In to add your hardware

Quantized

Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for lbertolino/MLK-de-Vila-1.0-1.3B

Finetuned
(2)
this model

Evaluation results