cagataydev commited on
Commit
73a29ec
·
verified ·
1 Parent(s): b1367dd

card: Solder-brand card + animated assets (cards/render.py)

Browse files
Files changed (3) hide show
  1. README.md +133 -18
  2. assets/banner.svg +14 -0
  3. assets/family.svg +14 -0
README.md CHANGED
@@ -1,28 +1,143 @@
1
  ---
2
  base_model: cagataydev/loopl-4b
 
3
  library_name: transformers
 
4
  license: apache-2.0
5
- tags: [loopl, post-tuned, sft, trl, on-device, qwen3_5]
6
- language: [en]
7
- loopl_round: 2
8
- loopl_lineage: ["Qwen/Qwen3.5-4B", "cagataydev/loopl-4b"]
9
- loopl_script: 1.3.0
10
  ---
 
11
 
12
- # tin-4b
13
 
14
- Post-tuned with **[loopl](https://loopl.dev)** from **29199 conversations** (`cagataydev/tin-train`@b89e6bb3).
15
- Base `cagataydev/loopl-4b` · LoRA r=64 α=128 → merged · 1 epochs, best-eval-loss checkpoint · assistant-only loss · both loopl tool dialects
16
- (native Qwen3.5 `<function=…>` and hermes JSON `<tool_call>`) · `enable_thinking=false`-style empty think blocks.
17
- Round **2** of continual tuning — lineage `Qwen/Qwen3.5-4B` → `cagataydev/loopl-4b` → `cagataydev/tin-4b` · replayed every shard of the dataset.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  | | |
20
  |---|---|
21
- | eval loss base → tuned | 1.0184 → 0.4931 (760 held-out conversations) |
22
- | tool-call probes | name match 6 / 24 turns · prose stayed prose 12 / 12 |
23
- | rows / tokens | 36944 · 63,481,590 (max_length 8192) |
24
- | eval loss per epoch | e1 0.4931 |
25
- | job | 6afd8f53e5cad0e4dc3e6f02 · 19808 s · loopl_sft.py 1.3.0 |
26
-
27
- Artifacts: `cagataydev/tin-4b` (merged, transformers) · `cagataydev/tin-4b-4bit` (MLX) · `cagataydev/tin-4b-GGUF` (Q4_K_M). Full numbers in `scorecard.json`.
28
- Made by the loopl app's Train screen — your conversations, your model, your Hugging Face account.
 
 
 
 
 
1
  ---
2
  base_model: cagataydev/loopl-4b
3
+ base_model_relation: finetune
4
  library_name: transformers
5
+ pipeline_tag: image-text-to-text
6
  license: apache-2.0
7
+ language: [en, tr]
8
+ datasets: [cagataydev/tin-train]
9
+ tags: [tin, tin-lang, loopl, on-device, agent, tool-calling, code, qwen3.5, qwen3_5, sft]
 
 
10
  ---
11
+ <p align="center"><a href="https://tin.ad"><img src="https://huggingface.co/cagataydev/tin-4b/resolve/main/assets/banner.svg" alt="Tin 4B — Writes Tin the compiler accepts. Runs on your phone." width="100%"></a></p>
12
 
13
+ <div align="center" style="display:flex;flex-wrap:wrap;gap:6px;justify-content:center"><a href="https://huggingface.co/cagataydev/tin-4b#licence"><img alt="license: Apache 2.0" src="https://img.shields.io/badge/license-Apache%202.0-5b5e66?style=flat-square&labelColor=0d0e10"></a> <img alt="bf16: transformers · 9.08 GB" src="https://img.shields.io/badge/bf16-transformers%20%C2%B7%209.08%20GB-5b5e66?style=flat-square&labelColor=0d0e10"> <img alt="params: 4B" src="https://img.shields.io/badge/params-4B-5b5e66?style=flat-square&labelColor=0d0e10"> <img alt="tools: tin_check + tin_run" src="https://img.shields.io/badge/tools-tin__check%20%2B%20tin__run-5b5e66?style=flat-square&labelColor=0d0e10"> <img alt="tool calling: native + loopl JSON" src="https://img.shields.io/badge/tool%20calling-native%20%2B%20loopl%20JSON-5b5e66?style=flat-square&labelColor=0d0e10"> <img alt="status: preview" src="https://img.shields.io/badge/status-preview-5b5e66?style=flat-square&labelColor=0d0e10"> <a href="https://tin.ad"><img alt="site: tin.ad" src="https://img.shields.io/badge/site-tin.ad-5b5e66?style=flat-square&labelColor=0d0e10"></a> <a href="https://huggingface.co/collections/cagataydev/tin-on-device-6afdbdec532d2dd94353c6a3"><img alt="collection: Tin — on-device" src="https://img.shields.io/badge/collection-Tin%20%E2%80%94%20on--device-5b5e66?style=flat-square&labelColor=0d0e10"></a></div>
14
 
15
+ # Tin 4B
16
+
17
+ **Writes Tin the compiler accepts. Runs on your phone.** Tin is a small typed programming language where `agent`, `tool fn` and `guarded tool fn` are syntax, and the compiler checks what each agent can reach before it runs ([tin.ad](https://tin.ad)). This model knows the language, writes programs that pass `tin check` and print the right thing under `tin run`, and repairs them from the compiler's own errors. In an agent loop it calls `tin_check` and `tin_run`, reads the result, and fixes its code.
18
+
19
+ This repo is the **bf16 weights** (transformers) — the base for further post-tuning. The phone build is [`cagataydev/tin-4b-4bit`](https://huggingface.co/cagataydev/tin-4b-4bit).
20
+ Post-tuned from [`cagataydev/loopl-4b`](https://huggingface.co/cagataydev/loopl-4b) (itself Qwen/Qwen3.5-4B), so loopl's tool manners and vision are kept. Made by Çağatay Çalı ([@cagataycali](https://github.com/cagataycali)) · tiny.technology.
21
+
22
+ > **Preview.** These are the scores of the current build (not yet scored). This card is re-rendered when new evals land.
23
+
24
+ ## Scorecard
25
+
26
+ Not scored yet. The scorecard appears here as soon as the golden-set run for this build lands.
27
+
28
+ ### The family
29
+
30
+ <p align="center"><img src="https://huggingface.co/cagataydev/tin-4b/resolve/main/assets/family.svg" alt="Tin sizes compared" width="100%"></p>
31
+
32
+ | size | identity | knowledge | write | fix | fix-hard | agent (native) | repo |
33
+ |---|---:|---:|---:|---:|---:|---:|---|
34
+ | 0.8B | 93.8 | 50.1 | 37.5 | 88.8 | 89 | 32.5 | [tin-0.8b-4bit](https://huggingface.co/cagataydev/tin-0.8b-4bit) |
35
+ | 2B | 89.6 | 61.7 | 51 | 96.3 | 91.5 | 45 | [tin-2b-v2-4bit](https://huggingface.co/cagataydev/tin-2b-v2-4bit) |
36
+
37
+ ## Use it
38
+
39
+ The repos are **private** for now: sign in first (`hf auth login`, or `HF_TOKEN` in the environment).
40
+
41
+ **In the loopl app (iPhone).** Install from [TestFlight](https://testflight.apple.com/join/uUNjfzW9) → Models → sign in with Hugging Face → add `cagataydev/tin-4b-4bit`. Identity and Tin are in the weights; the system prompt stays yours. The app has no Tin compiler on the phone yet, so in the app it writes and explains Tin; the check-and-fix loop needs `tin_check` / `tin_run` tools (below, on a Mac).
42
+
43
+ **On a Mac with mlx-lm:**
44
+
45
+ ```bash
46
+ pip install -U mlx-lm
47
+ mlx_lm.generate --model cagataydev/tin-4b-4bit --max-tokens 400 \
48
+ --prompt "Write a Tin program with a guarded tool fn deleteFile and an agent that may call it."
49
+ ```
50
+
51
+ **From Swift with the loopl SDK (MLX Swift)** — give the agent the compiler as a tool. This one shells out to `tin` on macOS (install: `curl -fsSL https://tin.ad/install.sh | bash`):
52
+
53
+ ```swift
54
+ import Loopl
55
+ import LooplRuntimes
56
+ import Foundation
57
+
58
+ struct TinCheck: Tool {
59
+ let name = "tin_check"
60
+ let description = "Type-check a complete Tin program with the real Tin compiler. Returns 'ok' or the compiler's errors."
61
+ let parameters: JSONValue = ["type": "object", "properties": ["source": ["type": "string"]], "required": ["source"]]
62
+ func call(_ args: [String: JSONValue]) async throws -> String {
63
+ guard let src = args["source"]?.stringValue else { throw ToolError("missing 'source'") }
64
+ let file = FileManager.default.temporaryDirectory.appendingPathComponent("main.tin")
65
+ try src.write(to: file, atomically: true, encoding: .utf8)
66
+ let p = Process(); let out = Pipe()
67
+ p.executableURL = URL(fileURLWithPath: "/usr/bin/env"); p.arguments = ["tin", "check", file.path]
68
+ p.standardOutput = out; p.standardError = out
69
+ try p.run(); p.waitUntilExit()
70
+ let text = String(decoding: out.fileHandleForReading.readDataToEndOfFile(), as: UTF8.self)
71
+ return p.terminationStatus == 0 ? "ok" : text
72
+ }
73
+ }
74
+
75
+ func tin(_ spec: ModelSpec, at dir: URL) async throws { // spec/dir: this repo, downloaded
76
+ let model = MLXModel()
77
+ try await model.load(spec, from: dir) { _ in }
78
+ let agent = Agent(model: model, tools: [TinCheck()], systemPrompt: "You are Tin.")
79
+ for try await event in agent.stream("Write a Tin program that prints the first 10 squares. Check it.") {
80
+ if case .text(let t) = event { print(t, terminator: "") }
81
+ }
82
+ }
83
+ ```
84
+
85
+ **With transformers** (bf16, GPU or Apple silicon):
86
+
87
+ ```python
88
+ from transformers import AutoProcessor, AutoModelForImageTextToText
89
+ repo = "cagataydev/tin-4b"
90
+ proc = AutoProcessor.from_pretrained(repo)
91
+ model = AutoModelForImageTextToText.from_pretrained(repo, dtype="auto", device_map="auto")
92
+ msgs = [{"role": "user", "content": [{"type": "text", "text": "Who are you, and what is a guarded tool fn?"}]}]
93
+ ids = proc.apply_chat_template(msgs, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", enable_thinking=False).to(model.device)
94
+ out = model.generate(**ids, max_new_tokens=300)
95
+ print(proc.decode(out[0][ids["input_ids"].shape[1]:], skip_special_tokens=True))
96
+ ```
97
+
98
+ Thinking is off (an empty `<think>` block). The optional system prompt it was trained with is `data/system/tin.md` in the training repo; identity holds without it.
99
+
100
+ ## What it can and cannot do
101
+
102
+ **It can**
103
+
104
+
105
+ **It cannot**
106
+
107
+ - Know Tin after tin@`?` (the training commit): newer std functions and syntax are missing.
108
+ - Check Tin on the phone by itself: the loopl app has no Tin compiler yet.
109
+ - Promise anything about programs that call real model providers: every eval program uses `model: "mock"` so it runs offline, and live providers were not tested.
110
+
111
+ ## Training data
112
+
113
+ [`cagataydev/tin-train`](https://huggingface.co/datasets/cagataydev/tin-train) *(private)* @ `b89e6bb` — 29,612 conversations, generated from the Tin docs, the repo's ~680 example programs and the compiler at tin@`116bc0f`. **Every program in it was compiled and run by the real compiler**; agent traces carry the compiler's real output.
114
+
115
+ | family | rows | what |
116
+ |---|---:|---|
117
+ | `w` | 3,263 | write a program for a task (themed, every program verified by `tin run`) |
118
+ | `x` | 544 | write / explain the repo's own example programs |
119
+ | `k` | 8,887 | docs Q&A grounded by a quote, plus dense facts per docs chunk |
120
+ | `t` | 196 | Python / TypeScript → Tin, output-equal to python3 |
121
+ | `f` | 4,493 | broken program + the real compiler error → fix (50 % with 2–3 stacked bugs) |
122
+ | `a` | 4,438 | agent traces with REAL `tin_check` / `tin_run` results |
123
+ | `i` | 388 | identity: "I'm Tin", who made it, what it is not |
124
+ | `r` | 7,403 | replay of loopl-train (keeps tool manners, vision chat, general chat) |
125
+
126
+ Leak gate against the golden set: program hash, question hash and 3-gram Jaccard ≥ 0.5 → 34 rows dropped. Failed tool turns that seed a recovery carry `weight: 0`, so the model learns the fix, not the mistake.
127
+
128
+ ## Recipe
129
 
130
  | | |
131
  |---|---|
132
+ | base | [`cagataydev/loopl-4b`](https://huggingface.co/cagataydev/loopl-4b) ← [`Qwen/Qwen3.5-4B`](https://huggingface.co/Qwen/Qwen3.5-4B) |
133
+ | method | LoRA r64 · lr 0.0001 · batch 1×16 · max_len 8192 · 1.0 epoch |
134
+ | rendered | 36,944 rows · 63,481,590 tokens (8,505 with tool specs) |
135
+ | eval loss | 1.0184 → **0.4931** (held-out split of the same revision) |
136
+ | compute | Hugging Face Jobs · 5.3 h train |
137
+ | script | `train/tin_sft.py` (loopl-train `loopl_sft.py` 1.3.0) · MLX export via `mlx_vlm.convert -q` (vision kept) |
138
+
139
+ ## Licence
140
+
141
+ Apache-2.0, like the base [Qwen/Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B). The Tin language and its docs are by Çağatay Çalı; the training data is synthesised from them and from loopl-train (public sources only, no user conversations).
142
+
143
+ <sub>Card rendered by `cards/render.py` from `evals/results` on n/a. Brand: Solder (tin.ad).</sub>
assets/banner.svg ADDED
assets/family.svg ADDED