alexwengg commited on
Commit
0d980ef
·
verified ·
1 Parent(s): d1cae06

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +76 -0
README.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Qwen/Qwen3-0.6B
4
+ base_model_relation: finetune
5
+ pipeline_tag: text-generation
6
+ language:
7
+ - en
8
+ tags:
9
+ - coreml
10
+ - apple-neural-engine
11
+ - on-device
12
+ - qwen3
13
+ - social-reply
14
+ library_name: coreml
15
+ ---
16
+
17
+ # short-reply-0.6b-coreml
18
+
19
+ A sub-1B model that reads one social post and drafts one short reply (≤ 12 words), packaged for Core ML.
20
+ Qwen3-0.6B, LoRA-tuned by distilling a 1.7B reply model on 4,615 generated posts, then merged. One 724 MB
21
+ package with two functions over shared weights:
22
+
23
+ | Function | Shape | Runs on | p50 (M5 Pro, macOS 27, from Swift) |
24
+ |---|---|---|---:|
25
+ | `prefill` | 160 tokens, fixed | Neural Engine (1,920 / 1,921 ops) | 28 ms |
26
+ | `decode` | 1 token, 512-slot KV cache in `MLState` | GPU | 24 ms / token |
27
+
28
+ A reply takes about 190 ms. Weights are 8-bit palettized (k-means, per-grouped-channel, group 32); the shared
29
+ embedding / `lm_head` weight stays fp16 (a palettized embedding table costs +13 ms per token on the gather).
30
+ Linear int8 weights run on the ANE but return garbage there; palettized weights work.
31
+
32
+ ## Quality
33
+
34
+ On 100 held-out real posts, 89 replies are identical to the PyTorch checkpoint; a blind LLM-judge A/B against the
35
+ project's 1.7B model scores 88 vs 93 (all of relevant / tone / grounded / ≤ 12 words), the same as the PyTorch
36
+ 0.6B. About 1 in 8 drafts is generic or slightly off. Replies are drafts for a person to review, not for posting
37
+ automatically. Training used only generated and hand-written posts; no real social posts were used for training.
38
+
39
+ ## Files
40
+
41
+ - `short_reply_0_6b.mlpackage` — multifunction Core ML package (`prefill`, `decode`), token-id inputs (embedding
42
+ lookup and RoPE tables are inside the graph).
43
+ - `tokenizer.json` — Qwen3 byte-level BPE.
44
+ - `config.json` — host settings: prefill length 160, cache 512, pad / stop ids, max new tokens 32, and the system
45
+ prompt the model was trained with.
46
+
47
+ ## Use
48
+
49
+ Swift host and a menu-bar demo (select a post, press a key, the reply is pasted into the reply box):
50
+ [FluidInference/FluidUse](https://github.com/FluidInference/FluidUse) — `ShortReplyManager` and `ShortReplyDemo`.
51
+
52
+ Prompt (Qwen3 chat template, thinking disabled):
53
+
54
+ ```
55
+ <|im_start|>system
56
+ {config.systemPrompt}<|im_end|>
57
+ <|im_start|>user
58
+ Post: {post}
59
+ Reply:<|im_end|>
60
+ <|im_start|>assistant
61
+ <think>
62
+
63
+ </think>
64
+
65
+ ```
66
+
67
+ Left-pad the token ids to 160 with `padID`, mask padded columns, run `prefill`, copy its `keys` / `values`
68
+ (`[28, 8, 160, 128]` fp16) into the decoder state (`k_cache_i` / `v_cache_i`, `[1, 8, 512, 128]`), then call
69
+ `decode` with one token at a time (`input_ids`, `attention_mask` `[1, 1, 1, 512]`, `cache_position`) until
70
+ `<|im_end|>` or 32 tokens. Greedy decoding reproduces the benchmarked replies.
71
+
72
+ ## Provenance
73
+
74
+ Base: [Qwen/Qwen3-0.6B](https://huggingface.co/Qwen/Qwen3-0.6B) (Apache-2.0). Conversion: coremltools 9.0,
75
+ `minimum_deployment_target` macOS 15 / iOS 18. Conversion code and training records: FluidUse
76
+ `Experiments/ShortReplyLM` and mobius `models/llm/short-reply-0.6b/coreml`.