Views
No views yet
0.8.0.dev01# ============================================================
2# Configuração Axolotl para finetuning do modelo Mistral 8B
3# (arquivo: axolotl_2_a40_runpod_config.yaml)
4# ============================================================
5
6# ============================================================
7# 1. Modelo Base e Configurações Gerais
8# ------------------------------------------------------------
9base_model: mistralai/Ministral-8B-Instruct-2410
10
11# ------------------------------------------------------------
12# 2. Quantização / dtype
13# - load_in_4bit: false (vamos usar LoRA puro)
14# - load_in_8bit: false
15# - bf16: true (carregar em bfloat16 para A40)
16# - fp16: false
17# ------------------------------------------------------------
18load_in_8bit: false
19load_in_4bit: false
20bf16: true
21fp16: false
22
23# ------------------------------------------------------------
24# 3. Chat template e tokens especiais
25# ------------------------------------------------------------
26chat_template: mistral_v2v3
27special_tokens:
28 bos_token: "<s>"
29 eos_token: "</s>"
30
31# ============================================================
32# 4. Paths dos Datasets (cada split numa linha separada)
33#
34# Atenção: cada bloco dentro de `datasets:` deve ter um "path: <string>"
35# e um "split: train" ou "split: validation".
36# ============================================================
37datasets:
38 - path: dataset
39 split: train
40 type: alpaca
41 field_instruction: instruction
42 field_input: input
43 field_output: output
44 field_weight: weight
45
46validation_datasets:
47 - path: dataset
48 split: validation
49 type: alpaca
50 field_instruction: instruction
51 field_input: input
52 field_output: output
53
54# (Opcional) Se quiser um split separado de test para avaliação final,
55# basta descomentar este bloco e criar “datasets/test.jsonl”.
56test_datasets:
57 - path: dataset
58 split: test
59 type: alpaca
60 field_instruction: instruction
61 field_input: input
62 field_output: output
63
64# ============================================================
65# 5. Configuração de Treino LoRA
66# ------------------------------------------------------------
67adapter: lora
68lora_r: 8
69lora_alpha: 16
70lora_dropout: 0.05
71lora_target_modules:
72 - gate_proj
73 - down_proj
74 - up_proj
75 - q_proj
76 - v_proj
77 - k_proj
78 - o_proj
79
80# Módulos LoRA a salvar para inferência leve
81lora_modules_to_save:
82 - embed_tokens
83 - lm_head
84
85# ============================================================
86# 6. Batch / Gradiente / Checkpointing
87# ------------------------------------------------------------
88micro_batch_size: 20
89gradient_accumulation_steps: 4
90gradient_checkpointing: true
91
92# ============================================================
93# 7. Otimizador / Scheduler
94# ------------------------------------------------------------
95learning_rate: 0.0001
96optimizer: adamw_bnb_8bit
97lr_scheduler: cosine
98
99# ============================================================
100# 8. Épocas / Sequence Len / Packing
101# ------------------------------------------------------------
102num_epochs: 3
103sequence_len: 1536
104pad_to_sequence_len: false
105sample_packing: true
106
107# ============================================================
108# 9. Log / Checkpoints / Avaliações
109# ------------------------------------------------------------
110logging_steps: 40
111evals_per_epoch: 4
112save_per_epoch: 4
113
114# ============================================================
115# 10. Diretórios de Saída
116# ------------------------------------------------------------
117output_dir: ./outputs/cid11-agent-mistral-8b
118save_safetensors: true
119
120# ============================================================
121# 11. Atenção / Configurações Adicionais
122# ------------------------------------------------------------
123device_map: auto
124attn_implementation: flash_attention_2
125flash_attention: false
126
127resume_from_checkpoint: null
128save_total_limit: 3
129
130# ============================================================
131# 12. Métricas de Avaliação Personalizadas
132# ------------------------------------------------------------
133# O Axolotl monitora internamente “eval_loss”.
134# Se quiser acrescentar “eval_accuracy” (por ex., comparar
135# o conteúdo dentro de <code>…</code>), tem que fazer por fora.
136#
137# Basta manter estas duas linhas (não removê-las), mesmo que
138# você tenha retirado o bloco callbacks. Depois, rodar um script
139# externo que leia o arquivo “outputs/predictions.jsonl” e
140# compare com “datasets/validation.jsonl” para obter a acurácia.
141monitor: eval_loss
142
143# — Forçar o Axolotl a gerar predições em cada validação ——
144predict_with_generate: true
145
146# — Se quiser salvar essas predições no disco, deixe true ——
147save_preds: true
148
149# ============================================================
150# 13. (Não há mais callback_modules nem callbacks aqui)
151# ============================================================
152
153# ============================================================
154# 14. Estrutura esperada de pastas no repositório:
155#
156# CIEL-Clinical-Concepts-to-ICD-11/
157# ├── axolotl_2_a40_runpod_config.yaml ← este arquivo
158# ├── datasets/
159# │ ├── train.jsonl
160# │ ├── validation.jsonl
161# │ └── test.jsonl (opcional se você quisesse finetune+teste juntos)
162# ├── scripts/
163# │ └── custom_metrics_callback.py (se for usar callback externamente)
164# ├── outputs/ (aqui ficarão checkpoints e predictions.jsonl)
165# └── train.py (opcional, não é mandatório para Axolotl CLI)
166# ============================================================| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| No log | 0.0025 | 1 | 2.1747 |
| 0.0736 | 0.2516 | 101 | 0.0500 |
| 0.0379 | 0.5031 | 202 | 0.0351 |
| 0.0308 | 0.7547 | 303 | 0.0292 |
| 0.0255 | 1.0050 | 404 | 0.0251 |
| 0.0201 | 1.2565 | 505 | 0.0220 |
| 0.0183 | 1.5081 | 606 | 0.0201 |
| 0.0172 | 1.7597 | 707 | 0.0185 |
| 0.0157 | 2.0100 | 808 | 0.0174 |
| 0.0122 | 2.2615 | 909 | 0.0170 |
| 0.0119 | 2.5131 | 1010 | 0.0166 |
| 0.0118 | 2.7646 | 1111 | 0.0164 |