{"id":51175338,"url":"https://github.com/tsuberim/merlin","last_synced_at":"2026-06-27T03:05:27.200Z","repository":{"id":350041768,"uuid":"1205057179","full_name":"tsuberim/merlin","owner":"tsuberim","description":"Merlin — efficient small language model built from scratch for Apple Silicon (Mac + iPhone) — PyTorch training, MLX inference, custom Metal kernels","archived":false,"fork":false,"pushed_at":"2026-04-08T19:09:00.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-08T21:13:07.503Z","etag":null,"topics":["apple-silicon","inference","language-model","llm","metal","mlx","on-device-ai","pytorch","quantization","tinystories"],"latest_commit_sha":null,"homepage":"https://tsuberim.github.io/merlin/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tsuberim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-08T15:37:54.000Z","updated_at":"2026-04-08T19:10:05.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/tsuberim/merlin","commit_stats":null,"previous_names":["tsuberim/mllm","tsuberim/merlin"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/tsuberim/merlin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsuberim%2Fmerlin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsuberim%2Fmerlin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsuberim%2Fmerlin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsuberim%2Fmerlin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsuberim","download_url":"https://codeload.github.com/tsuberim/merlin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsuberim%2Fmerlin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34839936,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-27T02:00:06.362Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apple-silicon","inference","language-model","llm","metal","mlx","on-device-ai","pytorch","quantization","tinystories"],"created_at":"2026-06-27T03:05:23.447Z","updated_at":"2026-06-27T03:05:27.188Z","avatar_url":"https://github.com/tsuberim.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1\u003e\u003cimg src=\"docs/logo.png\" alt=\"\" width=\"48\" style=\"vertical-align:middle; margin-right:10px; image-rendering:pixelated;\"\u003e \u0026nbsp;Merlin — Specialized Agentic Coding Model\u003c/h1\u003e\n\nA 3B language model built from scratch **exclusively** for agentic coding — not a general assistant, not a fine-tuned GPT. Every training token, every design decision, every protocol token is optimized for one job: executing code tasks fast, locally, and at scale.\n\nRuns on any MacBook. No API key. Your code never leaves your machine.\n\n→ **[tsuberim.github.io/merlin](https://tsuberim.github.io/merlin/)**\n\n## The Idea\n\nLLM agents spend most of their tokens on execution, not reasoning — grep a file, run a test, rename a function. Today that all hits a frontier model at $1–10/M tokens.\n\nMerlin is the brute-force execution layer beneath a smarter orchestrator. A frontier model (Claude, GPT-4) plans; Merlin executes — locally, in parallel, at zero marginal cost.\n\n| Mode | Workers | Cost |\n|---|---|---|\n| Local | 1, on your MacBook | $0 — always |\n| Hosted | 100–1000 via GPU batching | pay-per-task |\n\n## Design\n\n| Choice | What | Why |\n|---|---|---|\n| Pre-trained from scratch | 100B tokens — code, bash, agentic traces, commits | No proprietary distillation; weights are commercially clean |\n| Custom tokenizer | 32K BPE + 18 agent protocol special tokens | Tool-call protocol is first-class, not bolted on |\n| 6K context window | Sized for one large Python file + agent overhead | Not a general-purpose model |\n| RL post-training | GRPO on verifiable bash/filesystem rewards | Ground truth without a judge model |\n| MLX int4 inference | ~1.5 GB weights, \u003e500 tok/s on M3 | Fits any M-series Mac |\n\n## Agent Protocol\n\n18 special tokens define the tool-call format — the model learns to emit and parse tool calls natively:\n\n```\n\u003c|task|\u003e Read src/main.py and return the function names.\n\u003c|think|\u003e I need to read the file first.\u003c|/think|\u003e\n\u003c|tool_call|\u003e\u003c|tool_name|\u003eread_file\u003c|tool_args|\u003e{\"path\": \"src/main.py\"}\u003c|/tool_call|\u003e\n\u003c|tool_result|\u003edef train(): ...\\ndef evaluate(): ...\u003c|/tool_result|\u003e\n\u003c|answer|\u003e train, evaluate\n```\n\n## Architecture\n\nGPT-style decoder-only. RMSNorm, SwiGLU, GQA (n_kv_head=8), no bias, weight tying, pre-norm.\n\n| Config | Params | n_embd | n_head | n_layer | block_size |\n|---|---|---|---|---|---|\n| tiny | ~1.6M | 32 | 2 | 2 | 64 |\n| medium | ~21M | 256 | 8 | 8 | 512 |\n| base (330M) | ~330M | 1024 | 16 | 16 | 2048 |\n| **3b** | **~3.17B** | **3072** | **24** | **20** | **4096** |\n\n## Corpus\n\n~100B tokens across 7 sources. Two-phase curriculum: 80B general mix → 20B upweighted traces + instruction data.\n\n| Source | Share |\n|---|---|\n| Stack v2 — Python | ~38% |\n| Stack v2 — Bash / Markdown | ~8% |\n| Agentic traces (synthetic) | ~15% |\n| GitHub commits + issues | ~11% |\n| Stack Overflow | ~10% |\n| Math + instruction mix | ~12% |\n| tldr pages | \u003c1% |\n\nv0 corpus (1.19B tokens): [tsuberim/merlin-corpus-v0](https://huggingface.co/datasets/tsuberim/merlin-corpus-v0)\nTokenizer: [tsuberim/merlin-tokenizer-v0](https://huggingface.co/tsuberim/merlin-tokenizer-v0)\n\n## Status\n\n| Milestone | Status |\n|---|---|\n| Agentic protocol + eval harness (49 tasks, 47% on 3B baseline) | ✅ Done |\n| Custom BPE tokenizer (32K vocab, 20 special tokens) | ✅ Done |\n| Data pipeline (download → tokenize → pack) | ✅ Done |\n| v0 corpus on HuggingFace (1.19B tokens) | ✅ Done |\n| E2E training loop, 330M model on H100 | ✅ Done |\n| SFT infrastructure | ✅ Done |\n| Repo scanning pipeline (clone + pytest → passing repos) | 🔄 In progress |\n| Agentic trace generation (target: 200K traces) | ⏸ Planned |\n| Full 100B token corpus | ⏸ Planned |\n| 3B pre-training run | ⏸ Planned |\n| RL post-training (GRPO on verifiable rewards) | ⏸ Planned |\n| MLX int4 3B model release | ⏸ Planned |\n\n## Stack\n\n| Role | Tool |\n|---|---|\n| Training | PyTorch + CUDA (NVIDIA H100) |\n| Inference | MLX (Apple Silicon / Metal) |\n| Cloud compute | Modal |\n| Tokenizer | HuggingFace tokenizers (BPE, Rust) |\n| Trace generation | vLLM + Qwen2.5-Coder-32B |\n| Observability | W\u0026B |\n| Datasets + models | HuggingFace Hub |\n\n## Setup\n\n```sh\npython3 -m venv .venv \u0026\u0026 source .venv/bin/activate\npip install -r requirements.txt\n```\n\n## License\n\n[CC BY-NC 4.0](LICENSE) — free for non-commercial use. Commercial use requires a separate license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsuberim%2Fmerlin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsuberim%2Fmerlin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsuberim%2Fmerlin/lists"}