← All courses ← Course home

Lesson 01 of 08

What a writing-style LoRA means

A writing-style adapter changes a small instruct model toward your phrasing. The device then runs a baked copy of that model. It does not run a live adapter you swap in later.

Agent brief (llms.md)

Why this matters on the device

Your drafts are not a public dataset. Keep your writing on a Mac you control. Then ship a baked .aimodel. The model file is stored on the phone. Chat works without a network. The writing style does not need a vendor adapter in the cloud. Speed is local. If you delete your writing after export, the app still runs, because the style is inside the model file.

That is also the privacy rule. The baked model can still repeat phrases it memorized. Treat the export as sensitive. Do not upload it to a random host to "try a LoRA slot."

Core AI has no documented hot-swap LoRA. Train on a Mac with MPS or CPU. Merge into the base. Export with coreai.llm.export, or with torch.export plus coreai-torch. Keep the tokenizer sidecar. The device loads one ordinary language model.

The steps, one box at a time

Start with writing you own.

OwnYour writing examples

Training writes a small LoRA. The instruct base stays frozen. That means the base weights do not change.

OwnYour writing examples
MacLoRA checkpoint

Merge bakes the ranks into the base weights. After that you have one ordinary instruct model.

OwnYour writing examples
MacLoRA checkpoint
BakeMerged instruct LLM

Export writes the Core AI file and the tokenizer files that define its token ids.

OwnYour writing examples
MacLoRA checkpoint
BakeMerged instruct LLM
Export.aimodel plus tokenizer

The app loads that pair and chats offline. It does not download an adapter.

OwnYour writing examples
MacLoRA checkpoint
BakeMerged instruct LLM
Export.aimodel plus tokenizer
DeviceOffline chat

Adapter versus full fine-tune

A full fine-tune rewrites many weights and takes a lot of disk space. LoRA adds a smaller trainable path to a few layers. That makes experiments cheap to compare. It does not make the adapter a Core AI runtime feature. After you pick a checkpoint, you still merge.

Style is rhythm, how direct you sound, the words you pick, and the shape of an answer. It does not mean the model knows your calendar. Keep facts, retrieval, and writing style as separate questions. The sibling course, Diffusion LoRA to Core AI on device, is the same method for images.

Worked path for this map lesson

Set up the Mac project before any later training command. Use Python 3.11 or newer. Use uv for the environment. Prefer MPS. Use CPU if MPS is missing. Do not use CUDA.

curl -LsSf https://astral.sh/uv/install.sh | sh
mkdir -p writing-style-lora && cd writing-style-lora
uv init --python 3.11
uv venv
uv add torch torchvision transformers peft datasets accelerate safetensors coreai-torch
uv run python -c "import torch; print(torch.__version__); print('MPS:', torch.backends.mps.is_available())"
uv run coreai.llm.export --help

Write the contract you will not break later.

{
  "goal": "writing_style",
  "base": "qwen3-0.6b",
  "success": "Short rewrite requests come back in my usual cadence without inventing private facts.",
  "runtime_lora_swap": false,
  "keep_corpus_local": true
}

Failure modes

Done when

Keep learning

PyTorch to Core AI in Xcode · From the metal to the model · Core AI models, typed · Model architectures in plain English · Diffusion LoRA to Core AI on device

Key concepts

  • The chain is your writing, LoRA, merged instruct LLM, .aimodel plus tokenizer, offline chat.
  • Style is rhythm, directness, word choice, and answer shape. It is not facts.
  • A LoRA still needs merge for Core AI. There is no documented runtime adapter.
  • A baked model can memorize phrases. Treat the export as sensitive.

Takeaways

  • The contract sets runtime_lora_swap: false and keeps the corpus local.
  • The device loads one ordinary language model, not a live adapter.
  • The tokenizer sidecar is required.