@ondeinference / cli Mirror · read-only
Fork 0

Read-only mirror of github.com/ondeinference/onde-cli.

Mirrored from https://github.com/ondeinference/onde-cli.git

Synced Nov 23, 21:00 UTC

development
md 66 lines 3.3 KB
Rendered Raw
1 # Fine-tuning
2
3 `onde` includes a LoRA fine-tuning pipeline for Qwen2, Qwen2.5, and Qwen3 models. It runs locally: Metal on Apple Silicon, CPU elsewhere. No cloud setup. No Python environment.
4
5 The flow is straightforward: download a safetensors base model, fine-tune it with LoRA, merge the adapter back into the base weights, then export to GGUF for use in the Onde SDK.
6
7 If you want a quick refresher on what the model is actually doing at inference time, Onde has a short note on the [forward pass](https://ondeinference.com/forward-pass).
8
9 ## Training data format
10
11 Each line should be one complete conversation in Qwen's chat template:
12
13 ```jsonl
14 {"text": "<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n<|im_start|>user\nWhat is LoRA?<|im_end|>\n<|im_start|>assistant\nLoRA adds small trainable matrices to frozen layers, letting you fine-tune large models without updating all the weights.<|im_end|>"}
15 ```
16
17 Save the file wherever you want. The TUI lets you point to it directly.
18
19 ## Running it
20
21 ```
22 onde --tui
23 → Models tab (Tab from Apps)
24 → Select a safetensors model (↑↓, Enter)
25 → Press f
26 ```
27
28 Only safetensors models can be fine-tuned. GGUF models are already quantized, so their weights are not differentiable.
29
30 Configure the run:
31
32 | Field | Default | Notes |
33 |---|---|---|
34 | Training data | `~/.onde/finetune/train.jsonl` | Path to your JSONL file |
35 | LoRA rank | `8` | Higher means more capacity and more memory use |
36 | Epochs | `3` | Full passes over the dataset |
37 | Learning rate | `0.0001` | AdamW default |
38
39 Press `Enter` to start. In a healthy run, loss usually starts dropping by epoch 2. If it stays flat, try `0.0003`.
40
41 ## After training
42
43 For rank 8 on a 0.6B model, the adapter is about 1.5 MB. From the fine-tune complete screen:
44
45 - `m` to merge the adapter into the base model
46 - `g` to export the merged model to GGUF as Q8_0
47 - `G` (Shift+g) to export it as Q4_K_M, about a quarter the size of F16
48
49 The resulting GGUF loads directly in the [Onde SDK](https://ondeinference.com/sdk) for on-device AI inference.
50
51 Q4_K_M follows llama.cpp's mix: Q4_K for most weights, Q6_K for `attn_v` and `ffn_down` in the first and last eighth of the layers and every third layer between, and Q6_K for the output head (the token embedding when the model ties them, in which case no separate `output.weight` is written). Norms and biases stay F32. Tensors whose row length is not a multiple of 256 fall back to Q8_0.
52
53 ## Uploading
54
55 Open the exported GGUF from the model's artifacts and press Enter to upload it to the repo named in the field. New repos are created private; Ctrl+P switches to public. Tab moves the cursor between the repo name and an optional tag (for example `v1`), which is created on `main` after the commit. If the project directory has a `README.md` or `LICENSE`, they go into the same commit as the model. The visibility flag only applies when the upload creates the repo; an existing repo keeps its current setting.
56
57 ## Supported base models
58
59 | Model | Size | Notes |
60 |---|---|---|
61 | `Qwen/Qwen3-0.6B` | ~1.2 GB | Smallest and quickest to train |
62 | `Qwen/Qwen2.5-1.5B-Instruct` | ~3.0 GB | Good default for instruction tuning |
63 | `Qwen/Qwen3-1.7B` | ~3.4 GB | Newer small Qwen3 model |
64 | `Qwen/Qwen3-4B` | ~8.0 GB | Best quality, better suited to macOS |
65
66 You can search for any of these from the Models tab with `/`.