cagataydev commited on
Commit
3c3fa74
·
verified ·
1 Parent(s): b5ce267

card: loopl 4B v1 (bf16) — train/cards.py

Browse files
Files changed (1) hide show
  1. README.md +113 -17
README.md CHANGED
@@ -1,29 +1,125 @@
1
  ---
2
  base_model: Qwen/Qwen3.5-4B
 
3
  library_name: transformers
4
- license: apache-2.0
5
  pipeline_tag: image-text-to-text
6
- tags: [loopl, strands-agents, sft, trl, lora, on-device, qwen3_5]
7
- language: [en]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
- # loopl-4b
11
 
12
- **loopl** — the on-device agent model built by Cagatay Cali ([@cagataycali](https://github.com/cagataycali)) for the
13
- [loopl](https://loopl.dev) Swift agent SDK + iOS app. Post-trained from `Qwen/Qwen3.5-4B` on `cagataydev/loopl-train` to know
14
- Strands Agents, the owner's projects and robots, loopl itself, and to emit well-formed tool calls in both dialects loopl uses
15
- (native Qwen3.5 `<function=…>` and hermes JSON `<tool_call>`), with `enable_thinking=false`-style empty think blocks.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  | | |
18
  |---|---|
19
- | base | `Qwen/Qwen3.5-4B` (Apache-2.0) |
20
- | method | LoRA r=64 α=128 → merged , bf16, assistant-only loss |
21
- | data | `cagataydev/loopl-train` split `train` · 5126 rendered rows · 8,133,959 tokens · max_length 4096 |
22
- | epochs / steps | 2.0 / -1 · lr 0.0001 · batch 2×8 |
23
- | train loss | 1.1592365289774267 · eval loss 1.918319821357727 |
24
  | stack | transformers 5.18.0 · trl 1.14.1 · peft 0.21.2 |
25
- | job | 6ac4784afbc85ba6823b09c6 · 6928 s |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
- Artifacts: `cagataydev/loopl-4b-4bit` (MLX, 4-bit) and `cagataydev/loopl-4b-GGUF` (Q4_K_M) are produced by `train/convert.sh` in
28
- [cagataycali/loopl-train](https://github.com/cagataycali/loopl-train). Scorecard: `scorecard.json` (train/eval.py).
29
- Identity: "I'm loopl, built by Cagatay Cali — I know Strands Agents, robots, and loopl itself."
 
1
  ---
2
  base_model: Qwen/Qwen3.5-4B
3
+ base_model_relation: finetune
4
  library_name: transformers
 
5
  pipeline_tag: image-text-to-text
6
+ license: apache-2.0
7
+ language:
8
+ - en
9
+ - tr
10
+ datasets:
11
+ - cagataydev/loopl-train
12
+ tags:
13
+ - loopl
14
+ - on-device
15
+ - agent
16
+ - tool-calling
17
+ - qwen3.5
18
+ - qwen3_5
19
+ - sft
20
+ - vision
21
+ - image-text-to-text
22
  ---
23
+ # loopl 4B · v1
24
+
25
+ **loopl** is a Swift SDK and a free iOS app for agents that run *on the phone*: a local model, a small honest agent loop
26
+ (model → tools → model until it answers; errors go back to the model, approvals pause the loop) and the iPhone's own
27
+ abilities as tools — vision, voice, transcription, translation, torch, haptics, deep links, memory, HTTP. Site:
28
+ [loopl.dev](https://loopl.dev) · app: [TestFlight](https://testflight.apple.com/join/uUNjfzW9) · code: [github.com/cagataycali/loopl](https://github.com/cagataycali/loopl)
29
+ · every loopl repo: [the collection](https://huggingface.co/collections/cagataydev/loopl-on-device-agents-swift-6ac51395b13a9c41d4932eaf).
30
+
31
+ **This model** is [Qwen/Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B) LoRA (r=64) post-tuned by Cagatay Cali
32
+ ([@cagataycali](https://github.com/cagataycali)) on [cagataydev/loopl-train](https://huggingface.co/datasets/cagataydev/loopl-train): how an agent loop
33
+ works and how loopl's runtime behaves, tool calling in both dialects loopl speaks (the model's native template and
34
+ loopl's JSON prompt), recovering from tool errors instead of repeating the call, who it is and who built it, and honesty
35
+ about what it does not know. The **vision tower is the base's, frozen and kept** — the MLX export reads images like
36
+ Qwen3.5 does.
37
+
38
+ > **This repo is the merged bf16 checkpoint** (`Qwen3_5ForConditionalGeneration`, vision included). Ready-to-run exports: [mlx](https://huggingface.co/cagataydev/loopl-4b-4bit) · [gguf](https://huggingface.co/cagataydev/loopl-4b-GGUF) · [lora](https://huggingface.co/cagataydev/loopl-4b-lora).
39
+
40
+ ## Scores
41
+
42
+ | probe | this model | previous (v1) | base Qwen3.5 4-bit |
43
+ |---|---:|---:|---:|
44
+ | agent-SDK knowledge quiz (first 472 questions, exact-answer) | **111** | — | 83 |
45
+ | tool calls, native template dialect | **9/9** | — | 9/9 |
46
+ | tool calls, loopl JSON dialect | **9/9** | — | 9/9 |
47
+ | identity (5 classic probes, with system prompt) | **4/5** | — | 4/5 |
48
+
49
+ Scored by `train/eval.py` on the 4-bit MLX export (greedy). The quiz asks for exact file-level facts about an agent SDK's source — hard for every small model; the delta over base is the point. Tool probes count a well-formed call with the right arguments. `identity_nosys` is the one that matters in the app: the system prompt there is the user's to edit.
50
+
51
+ ## Use it today
52
+
53
+ **In the loopl app (iPhone).** Install from [TestFlight](https://testflight.apple.com/join/uUNjfzW9) → Settings › Hugging Face › sign in with a token that
54
+ can read this repo → Models › **Mine** → download. The app picks the MLX export, sees the vision tower and shows the photo
55
+ button; GGUF rows run on llama.cpp (text only). A public repo also appears under Models › Browse with no token.
56
+
57
+ **On a Mac with MLX** (vision included):
58
+
59
+ ```bash
60
+ pip install -U mlx-vlm
61
+ python -m mlx_vlm.generate --model cagataydev/loopl-4b-4bit \
62
+ --image photo.jpg --prompt "What is in this picture? Then tell me who built you." --max-tokens 200
63
+ ```
64
 
65
+ **With llama.cpp** (text only — the GGUF has no vision encoder):
66
 
67
+ ```bash
68
+ llama-cli -hf cagataydev/loopl-4b-GGUF:loopl-4b-Q4_K_M.gguf -p "Who built you, and what is 23 × 47?"
69
+ ```
70
+
71
+ **From Swift with the loopl SDK** (`https://github.com/cagataycali/loopl`, products `Loopl` + `LooplRuntimes`):
72
+
73
+ ```swift
74
+ import Loopl
75
+ import LooplRuntimes
76
+
77
+ let model = MLXModel() // or GGUFModel() for the -GGUF repo
78
+ try await model.load(spec, from: weightsDirectory) { _ in } // spec: the ModelSpec for cagataydev/loopl-4b-4bit; weights: the downloaded folder
79
+
80
+ let agent = Agent(model: model, tools: AppleTools.available)
81
+ for try await event in agent.stream("Torch on, then remember that I parked on level 3.") {
82
+ if case .text(let chunk) = event { print(chunk, terminator: "") }
83
+ }
84
+ ```
85
+
86
+ The bf16 weights (`cagataydev/loopl-4b`) load with `transformers` ≥ 5 as `Qwen3_5ForConditionalGeneration`; export your own
87
+ quantisation with `mlx_vlm.convert -q` (keeps vision) — `mlx_lm.convert` silently drops the tower.
88
+
89
+ ## Recipe
90
 
91
  | | |
92
  |---|---|
93
+ | base | [Qwen/Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B) (vision tower frozen, `visual.*` never trained) |
94
+ | data | [cagataydev/loopl-train](https://huggingface.co/datasets/cagataydev/loopl-train) @ `e5c209dd` · 5126 rendered rows / 8,133,959 tokens · both tool dialects · oversample `c=2` |
95
+ | method | LoRA r=64 α=128 on the language model · lr 0.0001 · batch 2×8 · max_len 4096 · 2.0 epochs, best-epoch checkpoint kept |
96
+ | eval loss | ep1 1.918, ep2 1.979 → best 1.918 (eval split of the same dataset revision) |
97
+ | compute | a100-large (Hugging Face Jobs), 6741 s train · job `6ac4784afbc85ba6823b09c6` |
98
  | stack | transformers 5.18.0 · trl 1.14.1 · peft 0.21.2 |
99
+ | exports | MLX 4-bit via `mlx_vlm.convert -q` (297 vision tensors of 1221, 3.03 GB) · GGUF Q4_K_M via llama.cpp `--no-mtp` (2.71 GB, text only) |
100
+
101
+ Script: [`train/loopl_sft.py`](https://github.com/cagataycali/loopl-train) — the same single file the loopl app launches when you
102
+ tap **Models › Train your own** on your own conversations. Assistant turns that *seed* a bad tool call carry `weight: 0`
103
+ so the model learns the recovery, not the mistake. Tokenizer files are normalised to the base's (`Qwen2Tokenizer`,
104
+ `chat_template.jinja` with tools) so Swift loaders accept them; `train/check_mlx_repo.py` gates every export on that
105
+ plus the vision triad (`vision_config` ⇔ `vision_tower.*` ⇔ `preprocessor_config.json`).
106
+
107
+ ## Limitations
108
+
109
+ - A 4B model: fluent and well-behaved in the loop, not an encyclopedia. It will get arithmetic and obscure
110
+ facts wrong; give it tools (`calculator`, `http`, `recall`) and it does better.
111
+ - Identity holds in most no-prompt probes (see the scores), not all; a one-line system prompt ("You are loopl…") makes it
112
+ consistent.
113
+ - The GGUF export is text-only. Vision needs the MLX export (or the bf16 weights).
114
+ - Trained on English plus a little Turkish; other languages are the base's.
115
+ - Knowledge about agent SDKs is file-level and dated to the dataset revision; it does not know your repo.
116
+
117
+ ## Data and privacy
118
+
119
+ Every training row is agent-synthesised from **public** sources (the owner's public GitHub repos and the agent-SDK source
120
+ they build on), critic-reviewed (score ≥ 4/5 kept) and filtered by a denylist for secrets, private names, phone numbers and
121
+ addresses — see the dataset card. No user conversations from the app are in this model.
122
+
123
+ ## License
124
 
125
+ Apache-2.0, inherited from the Qwen3.5 base. The fine-tune, exports and dataset are © Cagatay Cali, same license.