Text Generation
Transformers
Safetensors
English
gpt2
tiny-lm
educational
text-generation-inference
lillycham commited on
Commit
d938f5a
·
verified ·
1 Parent(s): ee12db3

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language: en
4
+ library_name: transformers
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - gpt2
8
+ - tiny-lm
9
+ - educational
10
+ datasets:
11
+ - HuggingFaceFW/fineweb-edu
12
+ - SimpleStories/SimpleStories
13
+ - databricks/databricks-dolly-15k
14
+ ---
15
+
16
+ # tiny-lm-web-98m
17
+
18
+ A 98M-parameter GPT-2 small shaped model, trained from scratch on web text. It is from Part 3 of
19
+ [tiny-lm](https://github.com/lillycham/tiny-lm), a project that builds a language model step by
20
+ step and then looks inside it.
21
+
22
+ | | |
23
+ |---|---|
24
+ | Size | 12 layers, width 768, 12 heads, 98.4M parameters |
25
+ | Context | 1,024 tokens |
26
+ | Tokeniser | byte-level BPE, 16,384 tokens, trained on FineWeb-Edu |
27
+ | Training | 2.70B tokens of FineWeb-Edu, 203 minutes on one RTX 5090 |
28
+ | Validation loss | 2.983 nats per token, 1.03 bits per character |
29
+
30
+ For comparison, OpenAI's GPT-2 small is about 1.04 bits per character on the same text.
31
+
32
+ There are two models in this repository:
33
+
34
+ - **The root** is the base model. It continues text.
35
+ - **`chat/`** is the base model after a 150M-token anneal (25% SimpleStories), then supervised
36
+ fine-tuning on Dolly 15k, then fine-tuning on `System:` lines (rules such as "Answer in one
37
+ sentence", and names for the model and the user).
38
+
39
+ The weights are a standard `GPT2LMHeadModel`. The q, k and v biases that GPT-2 has are zero,
40
+ because the model was trained without them.
41
+
42
+ ```python
43
+ import torch
44
+ from transformers import AutoModelForCausalLM, AutoTokenizer
45
+
46
+ repo = "lillycham/tiny-lm-web-98m"
47
+ tok = AutoTokenizer.from_pretrained(repo)
48
+ model = AutoModelForCausalLM.from_pretrained(repo)
49
+
50
+ ids = tok("The water cycle is", return_tensors="pt").input_ids
51
+ ids = torch.cat([torch.tensor([[tok.eos_token_id]]), ids], dim=1) # text starts after <|endoftext|>
52
+ out = model.generate(ids, max_new_tokens=100, do_sample=True, temperature=0.8)
53
+ print(tok.decode(out[0, 1:]))
54
+ ```
55
+
56
+ The chat model uses this format, and ends its answer with `<|endoftext|>`. Load it with
57
+ `subfolder="chat"`. The `System:` line is optional.
58
+
59
+ ```
60
+ System: Answer in one sentence.
61
+ User: Why is the sky blue?
62
+ Assistant:
63
+ ```
64
+
65
+ ## Limits
66
+
67
+ The text is fluent, but most facts are invented. The chat model answers in the right form (a list,
68
+ verse or one line) but does not know much. It does not yet take answers from a paragraph in its
69
+ context. Do not use it for anything that needs true answers.
70
+
71
+ ## Data and licence
72
+
73
+ Trained on [FineWeb-Edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) (ODC-By),
74
+ [SimpleStories](https://huggingface.co/datasets/SimpleStories/SimpleStories) (MIT) and, for the chat
75
+ model, [Dolly 15k](https://huggingface.co/datasets/databricks/databricks-dolly-15k) (CC BY-SA 3.0).
76
+ The code and weights are MIT.
chat/config.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "GPT2LMHeadModel"
4
+ ],
5
+ "model_type": "gpt2",
6
+ "vocab_size": 16384,
7
+ "n_positions": 1024,
8
+ "n_ctx": 1024,
9
+ "n_embd": 768,
10
+ "n_layer": 12,
11
+ "n_head": 12,
12
+ "n_inner": 3072,
13
+ "activation_function": "gelu_new",
14
+ "layer_norm_epsilon": 1e-05,
15
+ "resid_pdrop": 0.0,
16
+ "embd_pdrop": 0.0,
17
+ "attn_pdrop": 0.0,
18
+ "initializer_range": 0.02,
19
+ "tie_word_embeddings": true,
20
+ "bos_token_id": 16383,
21
+ "eos_token_id": 16383
22
+ }
chat/generation_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 16383,
3
+ "eos_token_id": 16383
4
+ }
chat/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:008a70080d37bf9b6b82d3cd30f55c2cca29c949c544262aabdb53770506f7de
3
+ size 393716352
chat/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
chat/tokenizer_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "tokenizer_class": "PreTrainedTokenizerFast",
3
+ "model_max_length": 1024,
4
+ "bos_token": "<|endoftext|>",
5
+ "eos_token": "<|endoftext|>",
6
+ "clean_up_tokenization_spaces": false
7
+ }
config.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "GPT2LMHeadModel"
4
+ ],
5
+ "model_type": "gpt2",
6
+ "vocab_size": 16384,
7
+ "n_positions": 1024,
8
+ "n_ctx": 1024,
9
+ "n_embd": 768,
10
+ "n_layer": 12,
11
+ "n_head": 12,
12
+ "n_inner": 3072,
13
+ "activation_function": "gelu_new",
14
+ "layer_norm_epsilon": 1e-05,
15
+ "resid_pdrop": 0.0,
16
+ "embd_pdrop": 0.0,
17
+ "attn_pdrop": 0.0,
18
+ "initializer_range": 0.02,
19
+ "tie_word_embeddings": true,
20
+ "bos_token_id": 16383,
21
+ "eos_token_id": 16383
22
+ }
generation_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 16383,
3
+ "eos_token_id": 16383
4
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:072ed8f16adff3733bb9fc55eb57a3c0cbb7c79f69cf02b31f578d774d8fb781
3
+ size 393716352
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "tokenizer_class": "PreTrainedTokenizerFast",
3
+ "model_max_length": 1024,
4
+ "bos_token": "<|endoftext|>",
5
+ "eos_token": "<|endoftext|>",
6
+ "clean_up_tokenization_spaces": false
7
+ }