Instructions to use nyuuzyou/BadApple-LLaMA-nano with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nyuuzyou/BadApple-LLaMA-nano with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nyuuzyou/BadApple-LLaMA-nano")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("nyuuzyou/BadApple-LLaMA-nano") model = AutoModelForCausalLM.from_pretrained("nyuuzyou/BadApple-LLaMA-nano") - llama-cpp-python
How to use nyuuzyou/BadApple-LLaMA-nano with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="nyuuzyou/BadApple-LLaMA-nano", filename="badapple.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use nyuuzyou/BadApple-LLaMA-nano with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf nyuuzyou/BadApple-LLaMA-nano # Run inference directly in the terminal: llama-cli -hf nyuuzyou/BadApple-LLaMA-nano
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf nyuuzyou/BadApple-LLaMA-nano # Run inference directly in the terminal: llama-cli -hf nyuuzyou/BadApple-LLaMA-nano
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf nyuuzyou/BadApple-LLaMA-nano # Run inference directly in the terminal: ./llama-cli -hf nyuuzyou/BadApple-LLaMA-nano
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf nyuuzyou/BadApple-LLaMA-nano # Run inference directly in the terminal: ./build/bin/llama-cli -hf nyuuzyou/BadApple-LLaMA-nano
Use Docker
docker model run hf.co/nyuuzyou/BadApple-LLaMA-nano
- LM Studio
- Jan
- vLLM
How to use nyuuzyou/BadApple-LLaMA-nano with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nyuuzyou/BadApple-LLaMA-nano" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nyuuzyou/BadApple-LLaMA-nano", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/nyuuzyou/BadApple-LLaMA-nano
- SGLang
How to use nyuuzyou/BadApple-LLaMA-nano with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "nyuuzyou/BadApple-LLaMA-nano" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nyuuzyou/BadApple-LLaMA-nano", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "nyuuzyou/BadApple-LLaMA-nano" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nyuuzyou/BadApple-LLaMA-nano", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Ollama
How to use nyuuzyou/BadApple-LLaMA-nano with Ollama:
ollama run hf.co/nyuuzyou/BadApple-LLaMA-nano
- Unsloth Studio new
How to use nyuuzyou/BadApple-LLaMA-nano with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for nyuuzyou/BadApple-LLaMA-nano to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for nyuuzyou/BadApple-LLaMA-nano to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for nyuuzyou/BadApple-LLaMA-nano to start chatting
- Docker Model Runner
How to use nyuuzyou/BadApple-LLaMA-nano with Docker Model Runner:
docker model run hf.co/nyuuzyou/BadApple-LLaMA-nano
- Lemonade
How to use nyuuzyou/BadApple-LLaMA-nano with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull nyuuzyou/BadApple-LLaMA-nano
Run and chat with the model
lemonade run user.BadApple-LLaMA-nano-{{QUANT_TAG}}List all available models
lemonade list
BadApple-LLaMA-nano
A 3.5M-parameter LLaMA that memorized every frame of the Bad Apple!! music video as ASCII art (1,745 frames, ~8,760 tokens each). Give it a frame number, get 58 rows of . and @ characters back. 99.78% average accuracy across 1,745 frames.
Background
This started as a joke. The first version used a custom architecture and tokenizer where each frame was a single token. It hit 100% accuracy in a few minutes of CPU training. Too easy, not interesting.
The next goal: do the same thing but make it llama.cpp-compatible. That meant working within LLaMA's architecture, using a real tokenizer, and generating frames character by character across ~8,760 tokens. Same thing, but harder constraints.
Architecture
| Base | LLaMA (decoder-only transformer) |
| Parameters | 3,499,641 |
| Hidden dim | 256 |
| FFN dim | 512 |
| Layers | 4 |
| Attention heads | 4 |
| Head dim | 64 |
| Context length | 8,860 tokens |
| Vocab | 1,753 (4 special + 4 character + 1,745 frame tokens) |
| Precision | float32 |
| Weights size | 13.4 MB (safetensors) / 13.5 MB (GGUF) |
The vocabulary consists of <pad>, <bos>, <eos>, <unk>, four character tokens (\n, ., @, ), and one token per frame number ("0" through "1744"). Each frame is ~8,760 tokens. The model generates a full frame conditioned on a two-token prompt: <bos> followed by the frame number token.
Accuracy
Best checkpoint: epoch 3,380 (loss 0.000888). Evaluated on 71 frames (every 25th + last):
| Metric | Value |
|---|---|
| Average accuracy | 99.78% |
| Minimum accuracy | 94.19% |
| Perfect frames (100%) | 53/71 |
| Frames above 90% | 71/71 |
| Inference speed (7950X, GGUF) | |
| Inference speed (7950X, PyTorch) |
Files
| File | Description |
|---|---|
model.safetensors |
Model weights (float32) |
config.json |
Architecture config |
tokenizer.json |
Full vocabulary and merges |
tokenizer_config.json |
Tokenizer metadata |
badapple.gguf |
GGUF for llama.cpp |
inference.py |
Generate frames (GGUF or PyTorch) |
train.py |
Train from scratch (standalone, no cloud deps) |
test_accuracy.py |
Measure accuracy against ground truth |
convert_gguf.py |
Convert safetensors to GGUF |
Quickstart
inference.py
inference.py uses llama-cpp-python (GGUF) when available, falls back to pure PyTorch.
# Fast path (~3s/frame) — install llama-cpp-python
pip install llama-cpp-python
python inference.py 42 # generate frame 42
python inference.py --play # play animation in terminal
# PyTorch-only (~27s/frame)
pip install torch safetensors
python inference.py --backend torch 42
llama.cpp CLI
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp && cmake -B build && cmake --build build -j && cd ..
./llama.cpp/build/bin/llama-completion -m badapple.gguf -p '<bos>42' -n 9000 --temp 0 --special --no-display-prompt -c 9100
Training from scratch
Requires badapple.txt (15.4 MB, 1,745 frames delimited by nekomark).
pip install torch safetensors
python train.py --data badapple.txt --epochs 4000
On an L4 GPU this takes around 20 hours. The cosine warm-restart schedule (T_0=200, T_mult=2) reaches sub-0.001 loss by epoch ~3,000.
Testing accuracy
python test_accuracy.py --data badapple.txt --step 25
Converting to GGUF
pip install gguf safetensors numpy
python convert_gguf.py --model-dir . --output badapple.gguf
Training details
| Optimizer | AdamW (lr=3e-4, weight_decay=0.01) |
| Schedule | CosineAnnealingWarmRestarts (T_0=200 epochs, T_mult=2) |
| Batch size | 1 (full frames, ~8,760 tokens each) |
| Mixed precision | AMP float16 on CUDA, float32 on CPU |
| Gradient clipping | max_norm=1.0 |
| Epochs trained | 3,380 |
| Best training loss | 0.000852 |
| Hardware | NVIDIA L4 on Modal ($0.80/hr) |
Each training sample is: <bos> <frame_N> [character tokens...] <eos>. The model learns next-token prediction over the full sequence. Padding tokens (id 0) are excluded from the loss.
How it works
The ASCII dataset encodes each of the 1,745 frames from the Bad Apple!! shadow art video as a 58-row, ~150-column grid using . (background) and @ (foreground). Each frame token acts as a content-addressable key: the model maps the two-token prefix <bos> <frame_N> to the full ~8,760-character frame.
At temperature 0, generation is deterministic. The model outputs the memorized frame character by character and stops at <eos>.
For provably deterministic playback via llama.cpp, the GGUF file uses GPT-2 BPE with generated merges so that multi-digit frame numbers (e.g., "1350") tokenize to a single token.
Dataset
The training data is badapple.txt from kisekied/BadAppleStringAnimation. It contains 1,745 frames of the Bad Apple!! music video converted to ASCII art. Each frame is delimited by nekomark.
License
Creative Commons 0 (CC0). The training dataset (badapple.txt) is from kisekied/BadAppleStringAnimation.
- Downloads last month
- 63