TheREZOR commited on
Commit
61c79ad
·
0 Parent(s):

TinyTalk release

Browse files
Files changed (11) hide show
  1. .gitattributes +35 -0
  2. LICENSE +27 -0
  3. NOTICE.md +54 -0
  4. README.md +122 -0
  5. config.json +52 -0
  6. generation_config.json +7 -0
  7. merges.txt +0 -0
  8. model.safetensors +3 -0
  9. tokenizer.json +0 -0
  10. tokenizer_config.json +13 -0
  11. vocab.json +0 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 REZOR
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ This license covers the source code in this repository. The generated model
26
+ artifacts (model_data.cpp, tok_data.cpp, embed/*.bin) additionally derive
27
+ from third-party works — see NOTICE.md for their licenses and attributions.
NOTICE.md ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Third-party components and attributions
2
+
3
+ The source code in this repository is MIT-licensed (see LICENSE). The
4
+ embedded model and tokenizer artifacts derive from the following works:
5
+
6
+ ## Base model — TinyStories-Instruct-3M
7
+
8
+ - Ronen Eldan & Yuanzhi Li, *TinyStories: How Small Can Language Models Be
9
+ and Still Speak Coherent English?* (arXiv:2305.07759).
10
+ - Weights: https://huggingface.co/roneneldan/TinyStories-Instruct-3M —
11
+ published without an explicit license tag. The companion TinyStories
12
+ dataset is CDLA-Sharing-1.0, which places no restrictions on results
13
+ (e.g. trained models). If the licensing of the base weights matters for
14
+ your use case, contact the model author.
15
+
16
+ ## Fine-tuning data
17
+
18
+ - **SODA** (https://huggingface.co/datasets/allenai/soda), CC BY 4.0.
19
+ Kim et al., *SODA: Million-scale Dialogue Distillation with Social
20
+ Commonsense Contextualization* (arXiv:2212.10465). The chat fine-tune
21
+ embedded in `model_data.cpp` was trained on a filtered subset.
22
+ - **TinyStoriesInstruct**
23
+ (https://huggingface.co/datasets/roneneldan/TinyStoriesInstruct),
24
+ CDLA-Sharing-1.0 (per the TinyStories dataset family).
25
+
26
+ ## Tokenizer
27
+
28
+ - GPT-2 byte-level BPE vocabulary and merges (`vocab.json` / `merges.txt`),
29
+ from OpenAI's GPT-2 release (https://github.com/openai/gpt-2), MIT
30
+ (Modified MIT License, Copyright (c) 2019 OpenAI). Embedded here in
31
+ pruned, re-encoded form inside `tok_data.cpp`.
32
+
33
+ ## Alternative model (not embedded by default)
34
+
35
+ - **Maykeye/TinyLLama-v0** (https://huggingface.co/Maykeye/TinyLLama-v0),
36
+ Apache-2.0. Supported by the engine via
37
+ `tools/convert_tinyllama_v0.py`.
38
+
39
+ ## Vendored keyboard driver (`main/keyboard/`)
40
+
41
+ - Ported from **M5Cardputer** v1.1.1
42
+ (https://github.com/m5stack/M5Cardputer), MIT,
43
+ Copyright (c) 2025 M5Stack Technology CO LTD. Arduino GPIO/interrupt
44
+ calls were replaced with ESP-IDF `driver/gpio` equivalents.
45
+ - Includes M5Stack's adaptation of the **Adafruit TCA8418** keypad driver
46
+ (https://github.com/adafruit/Adafruit_TCA8418), BSD, Copyright (c)
47
+ Limor Fried (Adafruit Industries).
48
+
49
+ ## Acknowledgements
50
+
51
+ - The inference engine follows the structure of Andrej Karpathy's
52
+ **llama2.c** (https://github.com/karpathy/llama2.c), MIT. The code here
53
+ is an independent implementation extended with Q4_0 quantization, a
54
+ GPT-Neo forward path, int8 KV cache, and a flash-walking tokenizer.
README.md ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ language:
4
+ - en
5
+ library_name: transformers
6
+ pipeline_tag: text-generation
7
+ base_model: roneneldan/TinyStories-Instruct-3M
8
+ datasets:
9
+ - allenai/soda
10
+ - roneneldan/TinyStoriesInstruct
11
+ tags:
12
+ - gpt-neo
13
+ - tinystories
14
+ - tiny
15
+ - embedded
16
+ - esp32
17
+ - microcontroller
18
+ - chat
19
+ - small-talk
20
+ ---
21
+
22
+ # TinyTalk — human-like small talk on a microcontroller
23
+
24
+ **TinyTalk** is a ~8.3M-parameter (≈1.6M non-embedding) **GPT-Neo** chatbot built
25
+ to do one thing: hold short, friendly, human-sounding small-talk conversations
26
+ on **low-end hardware that can't run a normal LLM** — think an **ESP32-S3**.
27
+
28
+ It is the model embedded in the [Cardputer AI](https://github.com/rezor/cardputer_ai)
29
+ firmware, where it runs **fully offline on the device** in ~2 MB of flash after
30
+ Q4_0 quantization. This repository hosts the full-precision PyTorch /
31
+ `safetensors` weights so the model can be used, fine-tuned, or re-quantized on
32
+ its own.
33
+
34
+ ## What it's for
35
+
36
+ Most chat models assume a datacenter GPU. TinyTalk asks the opposite question:
37
+ *how small can a model be and still feel like talking to someone?* It trades
38
+ away knowledge, reasoning, and long context to fit on a microcontroller, keeping
39
+ only the ability to make warm, coherent small talk:
40
+
41
+ ```
42
+ User: hey, how are you?
43
+ Bot: I am good! I played outside today. It was so much fun!
44
+ User: nice! what did you play?
45
+ Bot: I played with my ball. Do you want to play too?
46
+ ```
47
+
48
+ Good fits: an offline conversational toy or companion on an ESP32 / handheld;
49
+ a teaching example of an end-to-end on-device LLM; a tiny base to fine-tune for
50
+ embedded chat. **Not** a fit: anything needing facts, instructions, reasoning,
51
+ or safety guarantees.
52
+
53
+ ## What it is, technically
54
+
55
+ - **Architecture:** GPT-Neo (`GPTNeoForCausalLM`) — 8 layers, hidden size 128,
56
+ 16 heads, alternating global/local attention (window 256), learned position
57
+ embeddings, tied input/output embeddings, GPT-2 byte-level BPE tokenizer
58
+ (vocab 50257).
59
+ - **Base:** [`roneneldan/TinyStories-Instruct-3M`](https://huggingface.co/roneneldan/TinyStories-Instruct-3M).
60
+ - **Fine-tune:** ~70K filtered, simple-English dialogues from
61
+ [`allenai/SODA`](https://huggingface.co/datasets/allenai/soda), reformatted as
62
+ `User:`/`Bot:` turns, mixed with a slice of
63
+ [`TinyStoriesInstruct`](https://huggingface.co/datasets/roneneldan/TinyStoriesInstruct).
64
+ Loss is masked to the bot replies / story bodies, so the model never trains on
65
+ producing the user's turns.
66
+
67
+ ## Prompt format
68
+
69
+ Trained on this exact format, with `<|endoftext|>` (token 50256) between
70
+ exchanges:
71
+
72
+ ```
73
+ User: <message>
74
+ Bot: <reply><|endoftext|>
75
+ User: <message>
76
+ Bot:
77
+ ```
78
+
79
+ Feed `User: <message>\nBot: ` and generate until `<|endoftext|>`.
80
+
81
+ ## Usage
82
+
83
+ ```python
84
+ from transformers import AutoModelForCausalLM, AutoTokenizer
85
+
86
+ tok = AutoTokenizer.from_pretrained("TheREZOR/TinyTalk")
87
+ model = AutoModelForCausalLM.from_pretrained("TheREZOR/TinyTalk")
88
+
89
+ prompt = "User: hi, what's your name?\nBot:"
90
+ ids = tok(prompt, return_tensors="pt").input_ids
91
+ out = model.generate(
92
+ ids, max_new_tokens=40, do_sample=True, temperature=0.7, top_k=40,
93
+ eos_token_id=tok.eos_token_id,
94
+ )
95
+ print(tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True))
96
+ ```
97
+
98
+ ## Honest limitations
99
+
100
+ - **Kindergarten English only.** Short, simple sentences.
101
+ - **No world knowledge.** Factual questions get friendly confabulation.
102
+ - **Short memory.** Trained/served with a tiny context (~80 tokens on device,
103
+ 256 max). Not instruction-following, not safe for any production use.
104
+ - A toy/educational model — interesting because it fits on a microcontroller,
105
+ not because it is good.
106
+
107
+ ## License & attribution
108
+
109
+ Released under **CC BY 4.0**, the binding term inherited from the SODA training
110
+ data. You must retain the following attributions:
111
+
112
+ - **Base model:** TinyStories-Instruct-3M — Ronen Eldan & Yuanzhi Li,
113
+ *TinyStories: How Small Can Language Models Be and Still Speak Coherent
114
+ English?* (arXiv:2305.07759). Published without an explicit license tag; the
115
+ TinyStories dataset family is CDLA-Sharing-1.0, which places no restriction on
116
+ trained models.
117
+ - **Fine-tune data:** SODA (CC BY 4.0) — Kim et al., *SODA: Million-scale
118
+ Dialogue Distillation with Social Commonsense Contextualization*
119
+ (arXiv:2212.10465); and TinyStoriesInstruct (CDLA-Sharing-1.0).
120
+ - **Tokenizer:** GPT-2 byte-level BPE — OpenAI GPT-2 (MIT).
121
+
122
+ See `NOTICE.md` for the full provenance.
config.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation_function": "gelu_new",
3
+ "architectures": [
4
+ "GPTNeoForCausalLM"
5
+ ],
6
+ "attention_dropout": 0,
7
+ "attention_layers": [
8
+ "global",
9
+ "local",
10
+ "global",
11
+ "local",
12
+ "global",
13
+ "local",
14
+ "global",
15
+ "local"
16
+ ],
17
+ "attention_types": [
18
+ [
19
+ [
20
+ "global",
21
+ "local"
22
+ ],
23
+ 4
24
+ ]
25
+ ],
26
+ "bos_token_id": 50256,
27
+ "classifier_dropout": 0.1,
28
+ "dtype": "float32",
29
+ "embed_dropout": 0,
30
+ "eos_token_id": 50256,
31
+ "gradient_checkpointing": false,
32
+ "hidden_size": 128,
33
+ "initializer_range": 0.02,
34
+ "intermediate_size": null,
35
+ "layer_norm_epsilon": 1e-05,
36
+ "max_position_embeddings": 2048,
37
+ "model_type": "gpt_neo",
38
+ "num_heads": 16,
39
+ "num_layers": 8,
40
+ "pad_token_id": null,
41
+ "resid_dropout": 0,
42
+ "summary_activation": null,
43
+ "summary_first_dropout": 0.1,
44
+ "summary_proj_to_labels": true,
45
+ "summary_type": "cls_index",
46
+ "summary_use_proj": true,
47
+ "tie_word_embeddings": true,
48
+ "transformers_version": "5.11.0",
49
+ "use_cache": true,
50
+ "vocab_size": 50257,
51
+ "window_size": 256
52
+ }
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 50256,
4
+ "eos_token_id": 50256,
5
+ "transformers_version": "5.11.0",
6
+ "use_cache": true
7
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d7510ceac1d4f2a7d00b6f2da92cdce38706faa60a96c60884819d00ef58af77
3
+ size 33124616
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": "<|endoftext|>",
5
+ "eos_token": "<|endoftext|>",
6
+ "errors": "replace",
7
+ "is_local": true,
8
+ "local_files_only": false,
9
+ "model_max_length": 2048,
10
+ "pad_token": null,
11
+ "tokenizer_class": "GPT2Tokenizer",
12
+ "unk_token": "<|endoftext|>"
13
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff