CoolFace
Apppublic

build-small-hackathon/MiniCPM5-1B-Agent

sourceHugging Faceupdated 3mo agoView on Hugging Face
3likes
README.md133 linesDownload Raw Back to root
1---2title: MiniCPM5-1B-Agent3emoji: ๐Ÿ› ๏ธ4colorFrom: gray5colorTo: yellow6sdk: docker7app_port: 78608pinned: true9# Build Small Hackathon tags: official tracks/sponsors/badges + descriptive build facts (for reviewers).10tags:11  - best-minicpm-build   # sponsor: full fine-tune of MiniCPM5-1B (core entry)12  - backyard-ai          # track: local, self-hosted AI on CPU13  - best-use-of-codex    # sponsor: code + Codex-attributed commits on GitHub14  - best-use-of-modal    # sponsor: GGUF evaluated on Modal (see "How it was built")15  - off-brand            # badge: custom UI well past the default Gradio look16  - best-agent           # badge: the write -> run -> read -> debug -> verify loop17  - best-demo            # badge: GIF + video demo18  - tiny-titan           # badge: a 1B doing the real agentic loop19  - bonus-quest-champion # badge: most bonus criteria across the board20  - judges-wildcard      # badge: auto-considered for every entry21  - well-tuned           # full fine-tune of MiniCPM5-1B, published on the Hub22  - llama-champion       # served on the llama.cpp runtime23  - off-the-grid         # runs fully local on a CPU, no cloud model APIs24  - track:backyard25  - track:wood26  - sponsor:openbmb27  - sponsor:openai28  - sponsor:modal29  - achievement:offgrid30  - achievement:welltuned31  - achievement:offbrand32  - achievement:llama33  - achievement:sharing34---35 36# ๐Ÿ› ๏ธ MiniCPM5-1B-Agent37 38**A tiny agentic coding agent that runs the whole write โ†’ run โ†’ read โ†’ debug โ†’ verify loop on a free CPU.**39 40Social [media post link](https://discord.com/channels/879548962464493619/1514734596930142218); demo video:41<table><tr>42<td><img src="minicpm5-1b-agent-demo.gif" alt="MiniCPM5-1B-Agent demo GIF" width="480"></td>43<td><video src="https://huggingface.co/spaces/build-small-hackathon/MiniCPM5-1B-Agent/resolve/main/long_demo_build-small-hackathon_MiniCPM5-1B-Agent_16x.mp4" controls width="480"></video></td>44</tr></table>45 46A full fine-tune of [`openbmb/MiniCPM5-1B`](https://huggingface.co/openbmb/MiniCPM5-1B) (1B params), served as a47Q8_0 GGUF on llama.cpp, no GPU. Give it a task; it reasons in `<think>`, then uses `bash` / `write` / `read` /48`edit` in a sandbox to build, run, and fix code, and renders the result (charts, images, live HTML) inline in49the chat. Multi-turn: files and history persist across messages. It is also exposed as an **MCP tool**50(`run_coding_task` at `/gradio_api/mcp/`).51 52 53## What it is54 55Most coding agents are 70B+ behind a cloud API. This is the opposite: a **1B** model doing the *real* agentic56loop on a **2-vCPU CPU Space**, no GPU. It writes a file, runs it, reads the output, debugs, and shows you the57artifact, the same loop a big agent runs, shrunk to something you could host in your own backyard.58 59## How it was built60 61- Modal platform was used to evaluate the model via inference.62- **Data (`train_v4`, 45,762 rows):** the proven v2 backbone (retail-filtered teacher mixes + real-usage agent63  traces) kept whole, plus ~3,538 curated additions, gated to a small served tool vocab and solution-aware64  MinHash-deduped. Bundled on the model repo under `dataset/`.65- **SFT:** full fine-tune (not LoRA, the long agentic mix needs the capacity) of the abliterated base, 1 epoch,66  24k context, fits in ~15-18 GB VRAM (direct Liger fused cross-entropy + mem-efficient SDPA).67- **DPO (on-policy):** run the SFT model over the training prompts and capture its OWN behaviour. *chosen* = a68  valid `<function>` tool call; *rejected* = its real miss (rambling in `<think>` / answering with no call).69  ~649 pairs. This rewards ACTING over stalling.70- **Serving:** Q8_0 GGUF on llama.cpp; a two-phase decode bounds the `<think>` separately from the action so the71  model acts instead of looping; produced files render inline (charts, images, sandboxed live-HTML iframes).72 73## Try it74 75- "Write a Python script that makes a bar chart of 30, 45, 25 (A, B, C), save chart.png, then run it." โ†’ writes + runs it; the PNG renders inline.76- "Write an HTML page quote.html with a button that shows a random quote each click (hard-coded, no internet)." โ†’ writes the file; renders live in a sandboxed iframe.77 78It is a tiny 1B on a free CPU: expect **~4 min per simple turn**, longer for multi-step tasks (the demo video79shows it working end-to-end, so it can be judged even if a live run is slow).80 81 82<details><summary><b>Output examples</b></summary>83 84Real single-turn outputs from the Q8_0 GGUF, generated on Modal (CPU):85 86**Prompt:** Write a Python function `fib(n)` that returns the nth Fibonacci number iteratively. Print fib(10).87 88```python89def fib(n):90    if n == 0:91        return 092    elif n == 1:93        return 194    a, b = 0, 195    for _ in range(2, n + 1):96        a, b = b, a + b97    return b98 99print(fib(10))100```101 102**Prompt:** Convert an integer (1-3999) to a Roman numeral; demonstrate on 1994.103 104```python105def int_to_roman(num):106    if not 1 <= num <= 3999:107        raise ValueError("Number must be between 1 and 3999")108    roman_map = [(1000,'M'),(900,'CM'),(500,'D'),(400,'CD'),(100,'C'),(90,'XC'),109                 (50,'L'),(40,'XL'),(10,'X'),(9,'IX'),(5,'V'),(4,'IV'),(1,'I')]110    result = []111    for value, symbol in roman_map:112        while num >= value:113            result.append(symbol); num -= value114    return ''.join(result)115 116print(int_to_roman(1994))  # -> MCMXCIV117```118 119**Prompt:** How many $40 games can I buy with $200, and how much is left over?120 121> You can buy **5 games** with $200, and have **$0 left over**.122> Number of games = 200 / 40 = 5; remaining = 200 - (5 x 40) = $0.123 124</details>125 126## Model, dataset & full reproduction127 128โ†’ **[Luminia/MiniCPM5-1B-Agent-GGUF](https://huggingface.co/Luminia/MiniCPM5-1B-Agent-GGUF)** (model card =129the full data mix, SFT/DPO recipe, eval, and exact reproduce commands; v4 dataset bundled under `dataset/`).130 131๐Ÿ’ป **Code on GitHub:** [Katehuuh/MiniCPM5-1B-Agent](https://github.com/Katehuuh/MiniCPM5-1B-Agent) (the Space + the full training pipeline; code reviewed with OpenAI Codex).132 133*Built for the Build Small Hackathon ยท OpenBMB + OpenAI Codex tracks.*