Instructions to use vukrosic/nano-spell with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use vukrosic/nano-spell with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="vukrosic/nano-spell")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("vukrosic/nano-spell", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use vukrosic/nano-spell with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "vukrosic/nano-spell" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vukrosic/nano-spell", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/vukrosic/nano-spell
- SGLang
How to use vukrosic/nano-spell 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 "vukrosic/nano-spell" \ --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": "vukrosic/nano-spell", "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 "vukrosic/nano-spell" \ --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": "vukrosic/nano-spell", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use vukrosic/nano-spell with Docker Model Runner:
docker model run hf.co/vukrosic/nano-spell
nano-spell
Corrects a misspelled word to its intended word โ recieve โ receive, teh โ
the, freind โ friend, thier โ their. Which real word a typo most likely
meant lives only in a frequency-weighted lexicon, so the obvious script (nearest
dictionary word by edit distance) guesses wrong whenever the typo lands as close to
another word. A ~1M-parameter (1,016,960) byte-level transformer, trained 100% on
code-generated data.
- Code, benchmark, tests, technical report: https://github.com/vukrosic/nano-spell
- Runs on CPU in milliseconds. No tokenizer file โ raw UTF-8 bytes.
Benchmark (held-out, seed 987654321, N=4000)
| model | identity | nearest-naive | nearest-freq | |
|---|---|---|---|---|
| overall | 86.8% | 16.8% | 68.0% | 73.7% |
| hard slice (naive wrong, N=1280) | 68.7% | โ | 0.0% | 29.8% |
Unlike pure lexicon-recovery tasks (where a frequency dictionary ties the model), nano-spell beats both scripts, including the frequency dictionary. On the hard slice โ the typos a nearest-dictionary lookup gets wrong โ the model recovers 68.7% where the frequency dictionary manages only 29.8%. A clean must-beat-a-script result with no asterisk. Out-of-vocab words: 14% โ the prior is the ~480-word training vocabulary; reported, not hidden.
Usage
pip install torch safetensors numpy
# grab modeling_nano_spell.py + config.json from the GitHub repo
from modeling_nano_spell import load, correct
m = load("model.safetensors", "config.json")
correct(m, "recieve") # -> "receive"
correct(m, "teh") # -> "the"
correct(m, "world") # -> "world" (already correct, left alone)
How it was trained
Code-generated data: sample a real word from a fixed, frequency-ordered ~480-word vocabulary (Zipf-weighted), inject 1โ2 realistic typos (delete / insert / keyboard-neighbour / transpose / double), ~15% identity. Label correct by construction. SFT, prompt masked. ~1M-param byte-level transformer (RMSNorm, RoPE, GQA, SwiGLU), 12k steps, AdamW, cosine LR. Full recipe and reproduction in the GitHub repo.
MIT. Built by Vuk Rosiฤ.
- Downloads last month
- 1