Text Generation
Transformers
Safetensors
English
nano-proofread
grammar-correction
proofreading
homophones
tiny
byte-level
from-scratch
Instructions to use vukrosic/nano-proofread with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use vukrosic/nano-proofread with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="vukrosic/nano-proofread")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("vukrosic/nano-proofread", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use vukrosic/nano-proofread with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "vukrosic/nano-proofread" # 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-proofread", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/vukrosic/nano-proofread
- SGLang
How to use vukrosic/nano-proofread 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-proofread" \ --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-proofread", "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-proofread" \ --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-proofread", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use vukrosic/nano-proofread with Docker Model Runner:
docker model run hf.co/vukrosic/nano-proofread
| """Tests that gate the science: identity examples exist, most inputs carry an error, | |
| corrected phrases are clean (no doubled words), determinism, the context-free script | |
| provably fails on a real fraction (the must-beat-a-script filter), and a regression | |
| test that the PUBLISHED weights still fix the demo phrases. | |
| pytest test_nano_proofread.py -q | |
| """ | |
| from __future__ import annotations | |
| import os | |
| from data_proofread import naive_fix, proofread_pairs | |
| def test_identity_examples_exist(): | |
| pairs = proofread_pairs(7, 4000) | |
| ident = sum(1 for i, t in pairs if i[:-4] == t) | |
| assert 0.08 <= ident / len(pairs) <= 0.25 | |
| def test_most_inputs_have_an_error(): | |
| pairs = proofread_pairs(3, 4000) | |
| changed = sum(1 for i, t in pairs if i[:-4] != t) | |
| assert changed / len(pairs) > 0.7 | |
| def test_targets_are_clean(): | |
| for _, tgt in proofread_pairs(5, 2000): | |
| toks = tgt.split() | |
| assert all(toks[i] != toks[i + 1] for i in range(len(toks) - 1)), tgt | |
| def test_deterministic(): | |
| assert proofread_pairs(0, 300) == proofread_pairs(0, 300) | |
| def test_context_free_script_cannot_be_exact(): | |
| """The best context-free script must get a real fraction of examples wrong, | |
| because the homophone confusions are context-dependent.""" | |
| pairs = proofread_pairs(11, 4000) | |
| wrong = sum(1 for inp, tgt in pairs if naive_fix(inp[:-4]) != tgt) | |
| assert wrong > 0.15 * len(pairs) | |
| def test_published_weights_reproduce(): | |
| if not (os.path.exists("model.safetensors") and os.path.exists("config.json")): | |
| import pytest | |
| pytest.skip("weights not present in this checkout") | |
| from modeling_nano_proofread import load, proofread | |
| m = load() | |
| for phrase, gold in [ | |
| ("their going to win", "they're going to win"), | |
| ("its raining again", "it's raining again"), | |
| ("the the cat sat", "the cat sat"), | |
| ("we went they're", "we went there"), | |
| ("this is bigger then that", "this is bigger than that"), | |
| ("they're house is big", "their house is big"), | |
| ("she is happy today", "she is happy today"), # already correct -> unchanged | |
| ]: | |
| assert proofread(m, phrase) == gold, (phrase, proofread(m, phrase)) | |