File size: 1,130 Bytes
dcc24f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Fine-tune Model v6.
Final task-specific fine-tuning for UPI emails, bank statements,
and payment app statements. Uses the domain-pretrained base.

Author: Ranjit Behera
"""

import subprocess
import argparse
from pathlib import Path

def run_finetune():
    base_model = "models/base/phi3-finance-base"
    data_dir = "data/training"
    adapter_path = "models/adapters/finance-lora-v6"
    
    print(f"🚀 Starting Fine-tuning v6 using {base_model}...")
    
    cmd = [
        "mlx_lm.lora",
        "--model", base_model,
        "--data", data_dir,
        "--train",
        "--iters", "1500",
        "--batch-size", "1",
        "--num-layers", "16",
        "--learning-rate", "1e-5",
        "--adapter-path", adapter_path,
        "--max-seq-length", "1024" # Increased seq length for statements
    ]
    
    print(f"Command: {' '.join(cmd)}")
    
    try:
        subprocess.run(cmd, check=True)
        print(f"✅ Successfully trained v6 adapters at {adapter_path}")
    except subprocess.CalledProcessError as e:
        print(f"❌ Fine-tuning failed: {e}")

if __name__ == "__main__":
    run_finetune()