File size: 2,780 Bytes
1c59381
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---

license: mit
language:
- en
pipeline_tag: text-generation
tags:
- from-scratch
- tiny
- story-generation
datasets:
- roneneldan/TinyStories
---


# Vrel

A small language model built from scratch by Crisp Tech. Our own tokenizer, layers, attention, optimizer and
training loop, trained from random numbers on one RTX 4060. No pretrained weights and no outside model code.

Vrel is tiny (14 to 28 million parameters). It continues text in the style it learned and nothing more: it cannot
answer questions, follow instructions or hold a conversation. It is here to show, with real numbers, how a language
model is built and how it learns.

Code: [github.com/crisptech/vrel](https://github.com/crisptech/vrel) ·
Run it: [Lyss](https://github.com/crisptech/lyss), our terminal studio

## Versions

Each folder is a complete, self-contained model: weights (8-bit), tokenizer, `model.json` and the Vrel code that runs it.

| Folder | Parameters | Trained on | Validation loss | Perplexity |
|---|---|---|---|---|
| [`0.3.0/`](0.3.0) | 14.0M | TinyStories, learning from Vrel 0.2 as a teacher | 1.303 | 3.7 |
| [`0.2.0/`](0.2.0) | 27.8M | TinyStories (2.7M short stories) | 1.278 | 3.6 |
| [`0.1.0/`](0.1.0) | 13.9M | 67 public-domain novels from Project Gutenberg | 3.637 | 38.0 |

Scores for 0.2 and 0.3 are on 27,630 held-out stories (5.58M tokens); the bigram baseline scores 3.514
(perplexity 33.6). Lower is better: perplexity is roughly how many words the model is torn between.

Vrel 0.3 against 0.2: half the size, nearly the same score, and faster (148 against 139 tokens/s on an RTX 4060,
170 against 126 on 4 CPU threads).

## Use it

With Lyss (needs Python and PyTorch):

```bash

pipx install git+https://github.com/crisptech/lyss

hf download crisptechdev/vrel --local-dir vrel   # all three versions, 55 MB

```

Copy the version folders you want (say `0.3.0`) into Lyss's models folder (`lyss --help` shows where), then run `lyss`.

From Python, without Lyss:

```python

import sys

sys.path.insert(0, "vrel/0.3.0")

from vrel.generate import load



model = load("vrel/0.3.0")

print(model.generate("Once upon a time", max_tokens=200, seed=1))

```

A Vrel 0.3 story (seed 3):

> **The dog found a box in the park.** He wanted to see what was inside. He barked and ran around the box, trying
> to open it. But he couldn't get it out. Then, he saw a ball. He wanted to play with it.

## Licenses

Code and weights: MIT, Crisp Tech. Vrel 0.2 and 0.3 were trained on TinyStories (Ronen Eldan and Yuanzhi Li,
2023), released under CDLA-Sharing-1.0; those stories were written by GPT-4, and Vrel learns only from the text,
never from another model's weights. Vrel 0.1's books are public domain in the US.