Local LoRA Training for Specialised Domain Data

· Source: LLM on Medium · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Software Development & Engineering · Depth: Intermediate, medium

Summary

A personal project demonstrated local LoRA fine-tuning of a Large Language Model (LLM) on a 24GB MacBook Air M5 using LoRA and Apple's MLX framework. The objective was to override the base model's default refusals and enforce adherence to niche domain terminology, specifically from the "Honkai: Star Rail (HSR)" game. The author utilized `mlx-lm` to train a LoRA adapter on a `Qwen2.5-1.5B-Instruct` model. Data preparation involved creating `train.jsonl` and `valid.jsonl` files in a specific JSONL format, with diverse user questions and concise assistant answers, often bootstrapped synthetically. The training process successfully completed 1,000 iterations with a batch size of 2, 16 layers for LoRA adapters, and a learning rate of 2e-5, enabling the model to accurately answer HSR lore questions that the base model previously refused.

Key takeaway

For Machine Learning Engineers or AI Students seeking to customize LLMs for specialized domains without cloud reliance, this demonstrates that local LoRA fine-tuning on Apple silicon is highly effective. You can override base model refusals and inject niche terminology using tools like `mlx-lm` on consumer hardware like a MacBook Air M5. Focus on meticulously prepared, granular JSONL training data, even bootstrapping it with other LLMs, to achieve precise domain alignment while managing compute resources.

Key insights

Local LoRA fine-tuning on Apple silicon effectively overrides base model refusals for niche domain terminology using minimal resources.

Principles

Method

Train LoRA adapters using `mlx-lm` on Apple silicon, preparing data in JSONL format with diverse user prompts and concise assistant responses, then deploying the adapter with the base model.

In practice

Topics

Code references

Best for: Software Engineer, Machine Learning Engineer, AI Student

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by LLM on Medium.