|
Download GUIDE.md from QLNI/shadow-assistant-data: direct link, hf CLI and curl.
- Browser
- Download file 6.54 kB
-
https://huggingface.co/datasets/QLNI/shadow-assistant-data/resolve/main/GUIDE.md
- Command line
-
hf download hf://datasets/QLNI/shadow-assistant-data/GUIDE.md
-
curl -L -o GUIDE.md https://huggingface.co/datasets/QLNI/shadow-assistant-data/resolve/main/GUIDE.md
6.54 kB
| # Guide: how SHADOW Assistant is built, and why | |
| This guide explains the design behind the data in this repository: what the model is, how each kind of data is used, | |
| and the reason for every major choice. For where files are, see the [README](README.md). | |
| ## The model in one picture | |
| ``` | |
| text ── tokenizer ───────────┐ | |
| photo / video ── eye ────────┤ every input becomes 512-bit codes by one fixed rule | |
| sound ── ear ────────────────┘ │ | |
| input adapter | |
| │ | |
| body: 24 ternary layers = 21 RNN layers (fixed-size state) + 3 global attention layers | |
| Engram: 4B n-gram memory rows on disk, text only | |
| │ | |
| readout over the same frozen codes + a word-frequency prior | |
| │ | |
| token | |
| ``` | |
| About 135M parameters in the body (about 30 MB at ternary), a 4B-row Engram (about 2 GB at int4, read from disk), and | |
| an eye and ear (EmbeddingGemma 2's vision and audio towers at int8) that load only when a picture or sound arrives. | |
| ## The decisions, and why | |
| **One frozen code space for everything.** Every token, picture patch and sound frame becomes a 512-bit code from | |
| EmbeddingGemma 2's space, and the token table is never trained. Our paper ([Embeddings Are Overpriced?](https://arxiv.org/abs/2610.22428)) | |
| showed a frozen table with a learned frequency prior beats a learned table. Because the space never moves, words, | |
| pictures and sound stay aligned for good: no connector is needed between them, a model trained on text alone can | |
| already read picture codes it has never seen, and new words can be added later. The table is 16.8 MB. | |
| **A ternary body.** Weights are -1, 0 or +1 (BitNet b1.58), activations int8. The body is about 30 MB and fast on any | |
| CPU, and in our tests it learns as well as needed at this size. | |
| **An Engram.** A large table of 2- and 3-token memories, hashed, read from disk a few rows per token. It stores facts | |
| and phrases cheaply, so the small body can spend itself on reasoning. It reads text only, never picture or sound codes. | |
| **Mostly RNN layers, three attention layers.** 21 RNN layers keep a fixed-size state whatever the length, and only 3 | |
| global attention layers keep keys and values. Writing speed on a laptop CPU barely drops with context (551 tokens a | |
| second empty, 440 at 12k, 141 at 128k), the memory for the window stays small, and the RNN state (26 KB) can be saved | |
| to resume a conversation instantly. | |
| **Train exactly as it runs.** Keys and values are stored at int4 on the CPU, so training uses int4 too. What the model | |
| learns is exactly what it runs. | |
| **Memory in four parts.** A small model cannot hold a long conversation or a library in its weights, so SHADOW splits | |
| memory by job: | |
| - **The gist.** The 21 RNN layers each carry a fixed-size state that is updated with every token. Together it is | |
| about 26 KB, the same after ten words or a whole book: a running summary of who, what and why. It is not exact, but | |
| it never grows, and saving it to disk lets a conversation resume in milliseconds without reading anything again. | |
| - **The window.** The 3 global attention layers see the last 32k tokens exactly, with keys and values stored at int4. | |
| This is where precise wording, numbers and recent turns live. | |
| - **The archive and the index.** When text leaves the window it is written to disk once, in 64-token blocks: the token | |
| ids plus the int4 keys and values of the 3 attention layers (about 0.8 KB per token). When a question arrives, a | |
| word-match search over the archive finds candidate blocks, and a small trained index reranks them by meaning. The | |
| best 2,048 tokens are loaded straight back into the attention layers, placed just before the question with the best | |
| block last, so the model reads them as if they had just been said. The gist is not touched by a fetch. The index | |
| learns from where the attention layers actually look, and from practice: during training, facts are placed early in | |
| long documents and asked about later, after they have left the window. In a test on a model trained on 0.85B tokens, | |
| fetching lifted recall of facts read about 1,400 tokens earlier from 9% to 63% of digits. | |
| - **The Engram.** About 4B small rows, each tied to a hashed 2- or 3-token phrase, read from disk a few per token. It | |
| stores common facts and phrasing cheaply, so the small body can spend itself on reasoning. It reads text only. | |
| Each part is taught by different data: long documents teach the gist and the window, archive practice teaches the | |
| index, and all the text fills the Engram. | |
| **All senses trained together.** Text, pictures, video and sound go into one body in one run, rather than attaching | |
| vision to a finished text model. Caption text (about 10B tokens) describes physical, everyday scenes, which is exactly | |
| what small models lack. | |
| **Australia.** About 34B tokens of Australian text (web, law, Parliament, biography, Wikipedia), Australian speech, | |
| Australian photos of plants and animals, and Australian everyday conversations, on top of a strong global base. | |
| **Context.** Trained natively to 32k tokens; we have about 6.6B tokens in documents of 32k or more. Extension to 128k | |
| uses YaRN at run time and will be published with its test results. | |
| **Tuning after pretraining.** Tuning teaches the model to answer, not what to know, so it always comes after | |
| pretraining. The picture, video and sound tuning mix follows SmolVLM's published findings: a separate text share, very | |
| little chain-of-thought, and loss on answers only. | |
| **Clean evaluation.** Benchmark test data is kept out or listed (see the README). Every published number comes from a | |
| measurement. | |
| ## How the data is used in training | |
| | stage | data | | |
| |---|---| | |
| | Pretraining | all text, pictures, video and audio (without held-out shards and skip-listed items), windows growing from 2k to 32k | | |
| | End of pretraining (anneal) | the 32k stage: about 40% long documents, 60% anneal maths, code and the best text | | |
| | Tuning | text sets, then pictures, video, sound and text together, then the Australian conversations | | |
| ## Sizes and speeds quoted here | |
| All measured: CPU speeds on an Intel Xeon W-11955M laptop (8 threads) with our kernels at the real sizes; recall from | |
| a full-size test run on 0.85B tokens. Quality numbers for the trained model will be published with it. | |