broskicodes commited on
Commit
1724f13
1 Parent(s): 2b13532

Update README with usage instructions

Browse files
Files changed (1) hide show
  1. README.md +27 -2
README.md CHANGED
@@ -18,12 +18,37 @@ The model has 4M parameters (Safetensors seems to have inflated this to 13M, I w
18
 
19
  The model is a decoder only transformer model with 4 decoder layers and 2 attention heads. The model was trained for 3 epochs on only ~50MB of text and can already produce semi-coherent stories.
20
 
21
- The code used to train the model can be found on my [github](https://github.com/broskicodes/slms). For now, this is also the only way to train and obtain the tokenizer necessary for encoding and decoding text. Check it out if you are interested.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  ## Sample
24
  Here is a short sample generated by the model.
25
 
26
- `Once upon a time, there was a little girl called Daisy. Daisy wanted to go to the park with her mommy. She packed some yummy food and chirpies and carried them . Daisy was so excited for her mommy to try. The puppy and Mommy brought a big spoon to make souping. Daisy loved swimming and jun ate until she was disappointed. They began to start playing in the garden. They gathered around and ate and boot into the bread . As Daisy got hungry on the grass, she found some magic. She read more to see what was Luckily, Daisy was very impressed. When the lady opened the pot, something tickling to another. It was a rare. Daisy was so happy that she gave the tunately. Daisy was no longer scared. She knew she had to tell Mommy at the store. She took her to the soup and opened the tasty hot chocolate. When Daisy gave it to Daisy and princessed around a special spoon every day.`
27
 
28
  No, the story doesn't fully make sense. But most of the words are valid English and the characters and overarching plot are consistent. This is progress :)
29
 
 
18
 
19
  The model is a decoder only transformer model with 4 decoder layers and 2 attention heads. The model was trained for 3 epochs on only ~50MB of text and can already produce semi-coherent stories.
20
 
21
+ The code used to train the model can be found on my [github](https://github.com/broskicodes/slms).
22
+
23
+ ## Usage
24
+ 1. Import the relevant HuggingFace Auto classes and load model and tokenizer:
25
+
26
+ ```
27
+ from transformers import AutoModelForCausalLM, AutoTokenizer
28
+
29
+ model = AutoModelForCausalLM.from_pretrained("broskicodes/simple-stories-4M", trust_remote_code=True)
30
+ tokenizer = AutoTokenizer.from_pretrained("broskicodes/simple-stories-4M", trust_remote_code=True)
31
+ ```
32
+ 2. Tokenize your input sequence and call the `model.generate` function
33
+
34
+ ```
35
+ inputs = tokenizer("Once upon a time,", return_tensors="pt", return_attention_mask=False)
36
+ outputs = model.model.generate(**inputs, 250)
37
+ ```
38
+
39
+ Note that we are calling `model.model.generate` not just `model.generate`
40
+
41
+ 3. Decode the output and print the text
42
+
43
+ ```
44
+ text = tokenizer.batch_decode(outputs)[0]
45
+ print(text)
46
+ ```
47
 
48
  ## Sample
49
  Here is a short sample generated by the model.
50
 
51
+ ```Once upon a time, there was a little girl called Daisy. Daisy wanted to go to the park with her mommy. She packed some yummy food and chirpies and carried them . Daisy was so excited for her mommy to try. The puppy and Mommy brought a big spoon to make souping. Daisy loved swimming and jun ate until she was disappointed. They began to start playing in the garden. They gathered around and ate and boot into the bread . As Daisy got hungry on the grass, she found some magic. She read more to see what was Luckily, Daisy was very impressed. When the lady opened the pot, something tickling to another. It was a rare. Daisy was so happy that she gave the tunately. Daisy was no longer scared. She knew she had to tell Mommy at the store. She took her to the soup and opened the tasty hot chocolate. When Daisy gave it to Daisy and princessed around a special spoon every day.```
52
 
53
  No, the story doesn't fully make sense. But most of the words are valid English and the characters and overarching plot are consistent. This is progress :)
54