Upload model files
Browse files- README.md +62 -0
- model.safetensors +3 -0
- model_config.json +9 -0
- model_info.json +9 -0
- tokenizer.json +0 -0
README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
library_name: pytorch
|
| 4 |
+
tags:
|
| 5 |
+
- text-generation
|
| 6 |
+
- gpt
|
| 7 |
+
- from-scratch
|
| 8 |
+
- tinystories
|
| 9 |
+
datasets:
|
| 10 |
+
- roneneldan/TinyStories
|
| 11 |
+
language:
|
| 12 |
+
- en
|
| 13 |
+
metrics:
|
| 14 |
+
- perplexity
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# Tiny GPT (5.8M parameters)
|
| 18 |
+
|
| 19 |
+
A small GPT-2-style decoder-only transformer, written from scratch in PyTorch (no `transformers` classes), trained on a
|
| 20 |
+
laptop CPU on a subset of [TinyStories](https://huggingface.co/datasets/roneneldan/TinyStories). It continues short children's stories.
|
| 21 |
+
Code, training logs and the full write-up are in the GitHub repository.
|
| 22 |
+
|
| 23 |
+
## Model details
|
| 24 |
+
| | |
|
| 25 |
+
|---|---|
|
| 26 |
+
| Architecture | pre-norm GPT, 6 layers, d_model 256, 8 heads, context 256, learned positions, tied embeddings |
|
| 27 |
+
| Parameters | 5,853,184 |
|
| 28 |
+
| Tokenizer | byte-level BPE, vocabulary 4096, trained on the training split only (`tokenizer.json`) |
|
| 29 |
+
| Files | `model.safetensors`, `model_config.json` (our `ModelConfig`), `tokenizer.json`, `model_info.json` |
|
| 30 |
+
|
| 31 |
+
## Training
|
| 32 |
+
- **Data:** first 300,000 stories (60.8M tokens) of TinyStories V2 (GPT-4 generated); validation on 5,000 held-out stories.
|
| 33 |
+
- **Run:** 9,500 steps x 8,192 tokens = 77.8M tokens (about 1.28 passes over the data), AdamW, peak lr 1e-3 with warmup and cosine decay, 12 CPU threads, 7.9 hours of running time on one laptop (Intel Core Ultra 9 185H).
|
| 34 |
+
|
| 35 |
+
## Evaluation
|
| 36 |
+
| Model | Validation loss | Perplexity |
|
| 37 |
+
|---|---|---|
|
| 38 |
+
| Uniform guess | 8.32 | 4096 |
|
| 39 |
+
| Unigram counts | 5.88 | 357 |
|
| 40 |
+
| Bigram counts | 3.65 | 38.4 |
|
| 41 |
+
| **This model** | **1.688** | **5.41** |
|
| 42 |
+
|
| 43 |
+
Perplexity is per BPE token with this 4096-token tokenizer, on TinyStories text, so it is not comparable to numbers from other tokenizers or datasets.
|
| 44 |
+
|
| 45 |
+
## Intended use
|
| 46 |
+
Learning, demos and experiments with small language models; generating simple children's-story-style text.
|
| 47 |
+
|
| 48 |
+
## Limitations and risks
|
| 49 |
+
- **Narrow domain.** It only knows the simple vocabulary and plots of TinyStories. It cannot follow instructions, answer questions or hold a conversation.
|
| 50 |
+
- **Quality.** Stories are fluent at sentence level but repeat phrases, lose objects and plot threads, and sometimes contradict themselves. Samples in the repository's `docs/RESULTS.md` include failures, not just good examples.
|
| 51 |
+
- **Synthetic data.** The training stories were written by a large language model, so the model inherits that model's stylistic and social biases (names, gender roles, settings). It has not been evaluated for bias or safety.
|
| 52 |
+
- **Not for** factual content, advice, or anything where wrong or biased text could cause harm.
|
| 53 |
+
|
| 54 |
+
## Data and licence
|
| 55 |
+
Code and weights in this repository are released under the MIT licence. The training data, TinyStories by Ronen Eldan and Yuanzhi Li, is
|
| 56 |
+
licensed CDLA-Sharing-1.0 on the dataset card; please credit it and check the dataset card for current terms.
|
| 57 |
+
|
| 58 |
+
## Usage
|
| 59 |
+
```bash
|
| 60 |
+
git clone <github repo> && cd tiny-gpt && make setup
|
| 61 |
+
TINYGPT_HF_REPO=<this repo id> TINYGPT_MODEL_DIR=./model uv run uvicorn tinygpt.serving.app:create_app --factory
|
| 62 |
+
```
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6d9615059a7d499ad645f2f310fef70f91388a4804714becb008c72d90cb86ec
|
| 3 |
+
size 23419560
|
model_config.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"vocab_size": 4096,
|
| 3 |
+
"context_length": 256,
|
| 4 |
+
"d_model": 256,
|
| 5 |
+
"n_layer": 6,
|
| 6 |
+
"n_head": 8,
|
| 7 |
+
"dropout": 0.1,
|
| 8 |
+
"attention_impl": "sdpa"
|
| 9 |
+
}
|
model_info.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"run": "overnight_long",
|
| 3 |
+
"checkpoint": "best",
|
| 4 |
+
"training_steps": 9500,
|
| 5 |
+
"training_tokens": 77824000,
|
| 6 |
+
"val_loss": 1.6877,
|
| 7 |
+
"val_perplexity": 5.407,
|
| 8 |
+
"tokenizer_sha256": "f229f2e9cc79e0a4823e76f892ccabe9794bcd0ae7efc08a5ffbb57868a39229"
|
| 9 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|