Instructions to use dnakov/nanochat-d20 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use dnakov/nanochat-d20 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="dnakov/nanochat-d20")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("dnakov/nanochat-d20") model = AutoModelForCausalLM.from_pretrained("dnakov/nanochat-d20", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use dnakov/nanochat-d20 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "dnakov/nanochat-d20" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "dnakov/nanochat-d20", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/dnakov/nanochat-d20
- SGLang
How to use dnakov/nanochat-d20 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 "dnakov/nanochat-d20" \ --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": "dnakov/nanochat-d20", "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 "dnakov/nanochat-d20" \ --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": "dnakov/nanochat-d20", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use dnakov/nanochat-d20 with Docker Model Runner:
docker model run hf.co/dnakov/nanochat-d20
Upload folder using huggingface_hub
Browse files- README.md +11 -2
- tiktoken/tokenizer.model +3 -0
- tokenizer.json +0 -0
README.md
CHANGED
|
@@ -23,13 +23,13 @@ Nanochat is a small language model from Andrej Karpathy, converted to HuggingFac
|
|
| 23 |
|
| 24 |
## Usage
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
```python
|
| 29 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 30 |
|
| 31 |
model = AutoModelForCausalLM.from_pretrained("<model-path>", trust_remote_code=True)
|
| 32 |
-
tokenizer = AutoTokenizer.from_pretrained("<model-path>"
|
| 33 |
|
| 34 |
prompt = "Once upon a time"
|
| 35 |
inputs = tokenizer(prompt, return_tensors="pt")
|
|
@@ -37,6 +37,15 @@ outputs = model.generate(**inputs, max_new_tokens=50)
|
|
| 37 |
print(tokenizer.decode(outputs[0]))
|
| 38 |
```
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
## Citation
|
| 41 |
|
| 42 |
Original model by Andrej Karpathy: https://github.com/karpathy/nanochat
|
|
|
|
| 23 |
|
| 24 |
## Usage
|
| 25 |
|
| 26 |
+
### With Transformers (PyTorch)
|
| 27 |
|
| 28 |
```python
|
| 29 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 30 |
|
| 31 |
model = AutoModelForCausalLM.from_pretrained("<model-path>", trust_remote_code=True)
|
| 32 |
+
tokenizer = AutoTokenizer.from_pretrained("<model-path>")
|
| 33 |
|
| 34 |
prompt = "Once upon a time"
|
| 35 |
inputs = tokenizer(prompt, return_tensors="pt")
|
|
|
|
| 37 |
print(tokenizer.decode(outputs[0]))
|
| 38 |
```
|
| 39 |
|
| 40 |
+
### Converting to MLX
|
| 41 |
+
|
| 42 |
+
To use with Apple's MLX framework:
|
| 43 |
+
|
| 44 |
+
```bash
|
| 45 |
+
mlx_lm.convert --hf-path <model-path> --mlx-path nanochat-mlx --trust-remote-code
|
| 46 |
+
mlx_lm.generate --model nanochat-mlx --prompt "Once upon a time"
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
## Citation
|
| 50 |
|
| 51 |
Original model by Andrej Karpathy: https://github.com/karpathy/nanochat
|
tiktoken/tokenizer.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:22b70a034f8864b798f8349672ee348cbc519406fc71af52ee54f0eb83b1eece
|
| 3 |
+
size 1139659
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|