Skip to content

Instantly share code, notes, and snippets.

@dwarkeshsp
Created October 21, 2025 00:04
Show Gist options
  • Save dwarkeshsp/7b456da6e219d2a0b0d45587d15c3421 to your computer and use it in GitHub Desktop.
Save dwarkeshsp/7b456da6e219d2a0b0d45587d15c3421 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
echo "=== NanoChat Weights Download Script ==="
echo ""
# Setup directories
export NANOCHAT_BASE_DIR="$HOME/.cache/nanochat"
TOKENIZER_DIR="$NANOCHAT_BASE_DIR/tokenizer"
CHECKPOINT_DIR="$NANOCHAT_BASE_DIR/chatsft_checkpoints/d20"
mkdir -p "$TOKENIZER_DIR"
mkdir -p "$CHECKPOINT_DIR"
# HuggingFace model repository
BASE_URL="https://huggingface.co/sdobson/nanochat/resolve/main"
# Download tokenizer files
echo "=== Downloading tokenizer files ==="
cd "$TOKENIZER_DIR"
[ -f "tokenizer.pkl" ] || wget "$BASE_URL/tokenizer.pkl"
[ -f "token_bytes.pt" ] || wget "$BASE_URL/token_bytes.pt"
# Download model checkpoint files (~2GB total)
echo ""
echo "=== Downloading model checkpoint files ==="
cd "$CHECKPOINT_DIR"
[ -f "meta_000650.json" ] || wget "$BASE_URL/meta_000650.json"
[ -f "model_000650.pt" ] || wget "$BASE_URL/model_000650.pt"
# Setup Python environment
echo ""
echo "=== Setting up Python environment ==="
cd "$(dirname "$0")"
# install uv (if not already installed)
command -v uv &> /dev/null || curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync
echo ""
echo "=== Download Complete! ==="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment