NotShrirang commited on
Commit
4afe81b
ยท
verified ยท
1 Parent(s): ef60013

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +115 -1
README.md CHANGED
@@ -8,4 +8,118 @@ pipeline_tag: text-generation
8
  tags:
9
  - Stories
10
  - tinygpt
11
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  tags:
9
  - Stories
10
  - tinygpt
11
+ ---
12
+
13
+ # TinyGPT ๐Ÿค–
14
+
15
+ TinyGPT is a compact 50M parameter GPT model trained on a dataset of tiny stories, designed to generate coherent and creative text based on user input. โœจ
16
+
17
+ ## Features:
18
+
19
+
20
+ ## Overview ๐Ÿ”
21
+
22
+ TinyGPT is a lightweight GPT implementation trained on a dataset of short stories. With 50M parameters, it strikes a balance between computational efficiency and generative capability. The model was trained using a transformer architecture with self-attention mechanisms to capture contextual relationships in text.
23
+
24
+ ## Model Architecture ๐Ÿ—๏ธ
25
+
26
+ TinyGPT uses a standard GPT decoder-only transformer architecture with:
27
+
28
+ - 8 transformer blocks ๐Ÿงฑ
29
+ - 8 attention heads ๐Ÿ‘๏ธ
30
+ - 512 embedding dimensions ๐Ÿ“Š
31
+ - Vocabulary size of 50,304 tokens ๐Ÿ“š
32
+ - Context window of 512 tokens ๐ŸชŸ
33
+
34
+ ## Dataset ๐Ÿ“–
35
+
36
+ The model was trained on the TinyStories dataset, a collection of short stories designed for training language models. This dataset provides simple narratives that help the model learn coherent story generation while maintaining a smaller size compared to larger language models.
37
+
38
+ ## Installation ๐Ÿ’ฟ
39
+
40
+ To install TinyGPT, follow these steps:
41
+
42
+ ```bash
43
+ # Clone the repository
44
+ git clone https://github.com/NotShrirang/tinygpt.git
45
+
46
+ # Navigate to the project directory
47
+ cd tinygpt
48
+
49
+ # Install the required packages
50
+ pip install -r requirements.txt
51
+
52
+ # Download the model weights
53
+ mkdir -p tinygpt/weights
54
+ ```
55
+
56
+ ## Usage ๐Ÿš€
57
+
58
+ ### Streamlit Interface ๐Ÿ–ฅ๏ธ
59
+
60
+ The easiest way to interact with TinyGPT is through its Streamlit interface:
61
+
62
+ ```bash
63
+ streamlit run main.py
64
+ ```
65
+
66
+ This will launch a web application where you can input text and see the model's generated responses.
67
+
68
+ ## Training โš™๏ธ
69
+
70
+ TinyGPT was trained using PyTorch on the TinyStories dataset. The training process involved:
71
+
72
+ 1. Tokenizing the input text
73
+ 2. Creating sliding windows of fixed block size
74
+ 3. Training the model with cross-entropy loss
75
+ 4. Applying learning rate scheduling with warmup and cosine decay
76
+
77
+ <img src="https://github.com/user-attachments/assets/fd318849-d83b-4e44-aa3e-3119897cd4ae" alt="Loss Curve" width="70%"/>
78
+
79
+
80
+ For details on the training process, see the training notebook in the `notebooks/` directory.
81
+
82
+ ## Sample Outputs ๐Ÿ“
83
+
84
+ ### Example 1
85
+ ```text
86
+ Prompt: One day, a dragon
87
+
88
+ Output:
89
+ One day, a dragon named Bobo was walking in the forest when he saw a little bunny. The bunny was sad because he had no friends. Bobo wanted to help the bunny, so he asked the bunny to give him a hug. The bunny said yes, and the bunny gave the bunny a hug.
90
+
91
+ Bobo was very happy and thanked the bunny. He named the bunny, and they became good friends. The bunny was always grateful for Bobo's help. They became good friends, and they always shared their toys and treats!
92
+ ```
93
+
94
+ ```
95
+ Prompt: A dog named
96
+
97
+ Output:
98
+ A dog named Max went for a walk. He saw a big tree and wanted to climb it. Max was very excited and started to climb the tree. He was very careful and did not fall.
99
+
100
+ Max saw a little girl named Sue. Sue was sad because she lost her toy. Max wanted to help Sue. He said, "Don't worry, Sue. I will help you find your toy."
101
+
102
+ Max and Sue looked for the toy together. They looked under the tree, behind the tree, and behind the tree. Finally, they found the toy under a big tree. Max was so happy and said, "Thank you, Sue! You are a good friend."
103
+
104
+ Sue and Max played with the toy all day. They were very happy and had a fun day!
105
+ ```
106
+
107
+ ## Inference ๐Ÿ”ฎ
108
+
109
+ During inference, TinyGPT uses several techniques to produce high-quality text:
110
+
111
+ - Temperature scaling for controlling randomness
112
+ - Top-k and top-p sampling for focus and diversity
113
+ - Efficient token generation one at a time
114
+
115
+ ## License ๐Ÿ“œ
116
+
117
+ This project is licensed under the MIT License - see the LICENSE file for details.
118
+
119
+ ## Contributing ๐Ÿ‘ฅ
120
+
121
+ Contributions are welcome! Feel free to submit pull requests, create issues, or suggest improvements to the model or codebase.
122
+
123
+ ## Support โค๏ธ
124
+
125
+ If you find TinyGPT useful, please consider starring the repository โญ