# Run a tiny local model on your Mac CPU

> Run the TinyStories 15M model with a pinned llama2.c runtime on macOS. Verify the download checksum, compile with Apple clang, and generate text on the CPU.

Canonical: https://thelocalbench.com/how-to/tiny-model-cpu · The Local Bench (thelocalbench.com), data as of 2026-10-13, CC BY 4.0

- Difficulty: Beginner
- Time: about 15 minutes
- Cost: $0 (free software and model; uses your existing Mac)
- Hardware: Apple silicon Mac; 200 MB free disk space after developer tools are installed
- OS: macOS
- Prerequisites: Terminal; Apple Command Line Tools already installed (clang --version must succeed); Internet access for the initial downloads
- Parts: llama2.c (CPU runtime pinned to commit 350e04fe35433e6d2941dce5a1f53308f87058eb); TinyStories 15M (60,816,028-byte model; a story generator, not a chat assistant)
- Status: Tested by us. The download, compile and generation commands below completed on an Apple silicon Mac on 2026-10-13. This tests local text generation only, not chat quality, GPU offload or a browser interface.
- Tested on: macOS 26.2, ARM64, Apple clang 17.0.0, 2026-10-13: Downloaded the pinned runtime and tokenizer, verified the model checksum, compiled and generated 128 tokens on CPU with exit code 0. No GPU or model API used.
- Last tested: 2026-10-13
- Reviewed: 2026-10-13

## Not yet tested by us

- Installing Apple Command Line Tools on a fresh Mac
- Intel Macs, Linux and Windows
- Any GPU, chat interface or production workload

## Step 1: Check your compiler

Open Terminal and run:

```sh
clang --version
```

Our run reported Apple clang 17.0.0. If this opens an installation prompt, install Apple's Command Line Tools first, then rerun the check. That fresh installation is outside our tested scope.



## Step 2: Download into a new folder

Run each command in order. If any command fails, stop before the next one. `mkdir` must create a new folder; choose another name if it already exists.

```sh
mkdir tiny-local-demo
cd tiny-local-demo
curl -fL https://raw.githubusercontent.com/karpathy/llama2.c/350e04fe35433e6d2941dce5a1f53308f87058eb/run.c -o run.c
curl -fL https://raw.githubusercontent.com/karpathy/llama2.c/350e04fe35433e6d2941dce5a1f53308f87058eb/tokenizer.bin -o tokenizer.bin
curl -fL https://huggingface.co/karpathy/tinyllamas/resolve/main/stories15M.bin -o stories15M.bin
```

The source and tokenizer are pinned to a specific revision. Check the model before running it:

```sh
printf '%s\n' 'cd590644d963867a2b6e5a1107f51fad663c41d79c149fbecbbb1f95fa81f49a  stories15M.bin' | shasum -a 256 -c -
```

```text
# Expected output
stories15M.bin: OK
```

If the checksum differs, stop. Do not replace the expected checksum with the downloaded file's value.



## Step 3: Compile and generate

```sh
clang -O3 -o run run.c -lm
./run stories15M.bin -t 0 -n 128 -i 'Once upon a time'
```

The prompt is continued into a story. Our run began:

```text
# Expected output
Once upon a time, there was a little girl named Lily. She loved to play outside in the sunshine.
```

The program also prints `achieved tok/s`. That confirms generation completed; the value depends on your machine. The 128-token limit can stop mid-sentence. All inference uses the downloaded files on your CPU. You can rerun the second command without an internet connection.

> **Tip: A small success, deliberately**
>
This 15-million-parameter model generates simple stories. It is not instruction-tuned, does not answer questions reliably, and is not included in our fit or recommendation catalogue. Its job here is to prove that your machine can generate text locally.




## Step 4: Choose your next setup

For a chat interface and a larger model, continue to [Ollama and Open WebUI](/how-to/first-local-model-ollama-open-webui). That workflow is sourced but has not been tested end to end on our bench. For hardware planning, use the [configurator](/configurator) with a model from its supported catalogue; the tiny demo is not a speed benchmark for those models.

This demo creates no background service. Keep the folder to rerun it, or remove the `tiny-local-demo` folder in Finder when finished.





## Troubleshooting

### clang is missing
Install Apple's Command Line Tools using the linked Apple instructions, then open a new Terminal and repeat step 1.


### The program cannot open a file
Run `pwd` and `ls`. Your current folder must contain `run`, `stories15M.bin` and `tokenizer.bin`. Return to the folder created in step 2 before trying again.


### The story is nonsense
The model is tiny and only demonstrates generation. A successful process exit and generated text validate this setup; factual accuracy is not part of the test. The sun remains unavailable for ball games.

## Sources

- [llama2.c: source and usage](https://github.com/karpathy/llama2.c/tree/350e04fe35433e6d2941dce5a1f53308f87058eb)
- [TinyStories model files](https://huggingface.co/karpathy/tinyllamas)
- [Apple: installing command-line tools](https://developer.apple.com/documentation/xcode/installing-the-command-line-tools/)
