Instructions to use shibatch/tiny1m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use shibatch/tiny1m with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("shibatch/tiny1m", dtype="auto") - llama-cpp-python
How to use shibatch/tiny1m with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="shibatch/tiny1m", filename="tiny1m.BF16.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use shibatch/tiny1m with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf shibatch/tiny1m:Q4_K_M # Run inference directly in the terminal: llama-cli -hf shibatch/tiny1m:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf shibatch/tiny1m:Q4_K_M # Run inference directly in the terminal: llama-cli -hf shibatch/tiny1m:Q4_K_M
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 shibatch/tiny1m:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf shibatch/tiny1m:Q4_K_M
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 shibatch/tiny1m:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf shibatch/tiny1m:Q4_K_M
Use Docker
docker model run hf.co/shibatch/tiny1m:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use shibatch/tiny1m with Ollama:
ollama run hf.co/shibatch/tiny1m:Q4_K_M
- Unsloth Studio
How to use shibatch/tiny1m 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 shibatch/tiny1m 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 shibatch/tiny1m to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for shibatch/tiny1m to start chatting
- Docker Model Runner
How to use shibatch/tiny1m with Docker Model Runner:
docker model run hf.co/shibatch/tiny1m:Q4_K_M
- Lemonade
How to use shibatch/tiny1m with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull shibatch/tiny1m:Q4_K_M
Run and chat with the model
lemonade run user.tiny1m-Q4_K_M
List all available models
lemonade list
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,3 +1,128 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
base_model: karpathy/tinyllamas
|
| 4 |
+
tags:
|
| 5 |
+
- llama2
|
| 6 |
+
- gguf
|
| 7 |
+
- safetensors
|
| 8 |
+
- transformers
|
| 9 |
+
- tinyllamas
|
| 10 |
+
- validation
|
| 11 |
+
- test-suite
|
| 12 |
---
|
| 13 |
+
|
| 14 |
+
# TinyStories Llama2 1M (tiny1m) GGUF & HF Validation Suite
|
| 15 |
+
|
| 16 |
+
This repository provides ultra-lightweight Llama2 model files across various formats (both **GGUF** and **Hugging Face / Safetensors**), trained on the TinyStories dataset and optimized for compatibility with Andrej Karpathy's `llama2.c` and `llama.cpp`.
|
| 17 |
+
|
| 18 |
+
### Why this repository exists
|
| 19 |
+
When developing a custom LLM inference engine from scratch (C/C++, Vulkan, WebAssembly, etc.) or testing custom hardware kernels, debugging with a full-sized model is slow. This suite offers a true **1M parameter scale model** (~1MB to ~4MB depending on the quantization format), allowing developers to validate their loaders, serialization, quantization kernels, and inference logic step-by-step with maximum efficiency.
|
| 20 |
+
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
## 📂 Repository Structure & File Descriptions
|
| 24 |
+
|
| 25 |
+
### 1. GGUF Formats (Root Directory `./`)
|
| 26 |
+
A comprehensive validation suite converted for `llama.cpp` and compatible engines. Every compiled quantization variant available in the root directory is explicitly covered below:
|
| 27 |
+
|
| 28 |
+
| Filename(s) / Wildcard Pattern | Type | Size | Purpose / Validation Target |
|
| 29 |
+
| :--- | :--- | :--- | :--- |
|
| 30 |
+
| **`tiny1m.F32.gguf`** | `F32` | ~4.0 MB | **Baseline Test.** Validates GGUF parsing, tensor layout, matrix multiplication, RoPE, and Attention logic without dequantization overhead. |
|
| 31 |
+
| **`tiny1m.F16.gguf`**<br>**`tiny1m.BF16.gguf`** | `F16`<br>`BF16` | ~2.0 MB | **Half-Precision Test.** Validates 16-bit floating point loading, type casting, and inference stability. |
|
| 32 |
+
| **`tiny1m.Q8_0.gguf`** | `Q8_0` | ~1.1 MB | **Quantization Level 1.** Validates block-based uniform scaling with 32 elements. |
|
| 33 |
+
| **`tiny1m.Q4_0.gguf`**<br>**`tiny1m.Q4_1.gguf`** | `Q4_0`<br>`Q4_1` | ~0.7 MB | **Quantization Level 2.** Validates classic 4-bit linear quantization and bit-unpacking logic. |
|
| 34 |
+
| **`tiny1m.Q2_K.gguf`** | `Q2_K` | ~0.5 MB | **Standard K-Quant (2-bit).** Validates 2-bit super-block quantization parsing. |
|
| 35 |
+
| **`tiny1m.Q3_K_*.gguf`**<br>↳ *`tiny1m.Q3_K_S.gguf`*<br>↳ *`tiny1m.Q3_K_M.gguf`*<br>↳ *`tiny1m.Q3_K_L.gguf`* | `Q3_K` | ~0.6 MB | **Standard K-Quant (3-bit).** Validates Small, Medium, and Large sub-variants of 3-bit multi-block structures. |
|
| 36 |
+
| **`tiny1m.Q4_K_*.gguf`**<br>↳ *`tiny1m.Q4_K_S.gguf`*<br>↳ *`tiny1m.Q4_K_M.gguf`* | `Q4_K` | ~0.7 MB | **Standard K-Quant (4-bit).** Validates Small and Medium sub-variants of modern 4-bit super-block structural parsing. |
|
| 37 |
+
| **`tiny1m.Q5_K_*.gguf`**<br>↳ *`tiny1m.Q5_K_S.gguf`*<br>↳ *`tiny1m.Q5_K_M.gguf`* | `Q5_K` | ~0.8 MB | **Standard K-Quant (5-bit).** Validates Small and Medium sub-variants of 5-bit mixed precision super-blocks. |
|
| 38 |
+
| **`tiny1m.Q6_K.gguf`** | `Q6_K` | ~0.9 MB | **Standard K-Quant (6-bit).** Validates 6-bit high-fidelity super-block quantization. |
|
| 39 |
+
| **`tiny1m.IQ3_*.gguf`**<br>↳ *`tiny1m.IQ3_XXS.gguf`*<br>↳ *`tiny1m.IQ3_S.gguf`* | `I-Quants` | ~0.5 MB | **Importance Quants (3-bit).** Non-linear 3-bit importance quantization targeting lookup table (codebook) decoding logic. |
|
| 40 |
+
| **`tiny1m.IQ4_*.gguf`**<br>↳ *`tiny1m.IQ4_NL.gguf`*<br>↳ *`tiny1m.IQ4_XS.gguf`* | `I-Quants` | ~0.6 MB | **Importance Quants (4-bit).** Non-linear 4-bit importance quantization variants (Non-Linear and Extra Small). |
|
| 41 |
+
| **`tiny1m.TQ1_0.gguf`**<br>**`tiny1m.TQ2_0.gguf`** | `Ternary` | ~0.4 MB | **Experimental.** Ternary (-1, 0, 1) state quantization for cutting-edge engine testing. |
|
| 42 |
+
|
| 43 |
+
### 2. Llama2.c & Base Tokenizer Assets (Root Directory `./`)
|
| 44 |
+
Files optimized for execution within the native `llama2.c` ecosystem:
|
| 45 |
+
* **`model.bin`**: A single flat binary file containing all network weights, custom layout arrays, and pre-computed RoPE frequencies structured specifically for `run.c`.
|
| 46 |
+
* **`tokenizer.bin`**: The structural binary version of the 512-vocab tokenizer compiled for rapid streaming and direct parsing by `run.c`.
|
| 47 |
+
* **`tokenizer.model`**: The master SentencePiece tokenizer model file (512 vocabulary size, identical to the `stories260k` standard) kept at the root for upstream conversion tools and local reference.
|
| 48 |
+
|
| 49 |
+
### 3. Hugging Face Native Format (`./hf/`)
|
| 50 |
+
This directory contains the standard files required to load the model using the PyTorch `transformers` library:
|
| 51 |
+
* **`hf/model.safetensors`**: The raw, unquantized model weights stored securely in Safetensors format.
|
| 52 |
+
* **`hf/config.json`**: The architectural configuration file defining hyperparameters (layers, heads, dimensions).
|
| 53 |
+
* **`hf/generation_config.json`**: Default parameters optimized for text generation (temperature, top_p, etc.).
|
| 54 |
+
* **`hf/tokenizer.model`**: A redundant copy of the 512-vocab SentencePiece tokenizer model placed inside the directory for seamless Hugging Face API resolution.
|
| 55 |
+
|
| 56 |
+
---
|
| 57 |
+
|
| 58 |
+
## 🚀 Quick Start & Usage Examples
|
| 59 |
+
|
| 60 |
+
### A. Running GGUF via llama.cpp
|
| 61 |
+
To verify your local setup or compare tokens using the official native utilities:
|
| 62 |
+
```bash
|
| 63 |
+
./llama-cli -m tiny1m.Q4_K_M.gguf -p "Tom and Jerry are " -n 64 --temp 0.0
|
| 64 |
+
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
### B. Running via llama2.c (Native Binary)
|
| 68 |
+
|
| 69 |
+
The `model.bin` is fully compatible with the 512-vocab `tokenizer.bin` derived from the `stories260k` asset pipeline.
|
| 70 |
+
|
| 71 |
+
> ⚠️ **Important Note for `llama2.c/run`:** When passing a prompt to the `run` binary, you must use the **`-i`** option. Do not use `-p`, as `-p` is reserved for the Top-p sampling threshold in `llama2.c`, which will cause the prompt to be ignored.
|
| 72 |
+
|
| 73 |
+
```bash
|
| 74 |
+
./run model.bin -z tokenizer.bin -i "Tom and Jerry are " -n 64
|
| 75 |
+
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
### C. Loading Hugging Face Formats via Python
|
| 79 |
+
|
| 80 |
+
You can import the Hugging Face variant directly into Python using the `transformers` library.
|
| 81 |
+
|
| 82 |
+
```python
|
| 83 |
+
import torch
|
| 84 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 85 |
+
|
| 86 |
+
repo_id = "your-username/your-repo-name"
|
| 87 |
+
|
| 88 |
+
# The library automatically looks into the hf/ folder using the subfolder argument
|
| 89 |
+
tokenizer = AutoTokenizer.from_pretrained(repo_id, subfolder="hf")
|
| 90 |
+
model = AutoModelForCausalLM.from_pretrained(repo_id, subfolder="hf")
|
| 91 |
+
|
| 92 |
+
prompt = "Tom and Jerry are "
|
| 93 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 94 |
+
|
| 95 |
+
with torch.no_grad():
|
| 96 |
+
outputs = model.generate(
|
| 97 |
+
**inputs,
|
| 98 |
+
max_new_tokens=64,
|
| 99 |
+
do_sample=False,
|
| 100 |
+
pad_token_id=tokenizer.eos_token_id
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 104 |
+
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
---
|
| 108 |
+
|
| 109 |
+
## 📝 Model Specifications
|
| 110 |
+
|
| 111 |
+
The network architecture features an unshared output layer (`lm_head`) to keep memory structures consistent with standard Llama 2 definitions. Thanks to the highly optimized 512 vocabulary size, the token embedding and output layers remain extremely lightweight.
|
| 112 |
+
|
| 113 |
+
* **Architecture:** Llama 2 (Scaled-down variant)
|
| 114 |
+
* **Dataset:** TinyStories
|
| 115 |
+
* **Total Parameters:** ~1M (Exactly 896,256 parameters)
|
| 116 |
+
* **Vocabulary Size:** 512 (Uses the `stories260k` compatible 512-vocab tokenizer layout)
|
| 117 |
+
* **Hidden Size (`hidden_size`):** 128
|
| 118 |
+
* **Number of Hidden Layers (`num_hidden_layers`):** 4
|
| 119 |
+
* **Number of Attention Heads (`num_heads`):** 2
|
| 120 |
+
* **Number of Key-Value Heads (`num_kv_heads`):** 2
|
| 121 |
+
* **Intermediate Size (`intermediate_size`):** 352
|
| 122 |
+
* **Max Position Embeddings (`max_position_embeddings`):** 256
|
| 123 |
+
|
| 124 |
+
## 📜 Acknowledgments & License
|
| 125 |
+
|
| 126 |
+
* **Original Implementation:** Inspired by Andrej Karpathy's `llama2.c` project.
|
| 127 |
+
* **Dataset:** TinyStories dataset.
|
| 128 |
+
* **License:** **MIT License**. You are free to use, modify, and distribute these assets for any purpose.
|