TinyGPT v2 Conversation
A tiny language model with a tiny brain, a big dream, and absolutely no idea what a GPU bill costs.
Meet TinyGPT v2 Conversation β a small, experimental conversational language model built and trained from scratch in PyTorch.
It is not trying to be the next giant assistant. It is a little learning project: a compact GPT-style model trained to continue short User: / Bot: conversations. Think of it as a pocket-sized language-model experiment.
What can it do?
TinyGPT v2 Conversation is intended for:
- Generating short conversational replies.
- Continuing simple
User:/Bot:dialogue examples. - Demonstrating how a small GPT-style Transformer can be built and trained in PyTorch.
- Serving as an approachable starting point for experimenting with tokenization, attention, and language-model training.
What should you not expect?
This is a very small model with a character-level vocabulary and a short context window. It is not a general-purpose assistant and should not be relied on for:
- Factual question answering or research.
- Complex reasoning, coding, or mathematics.
- Long conversations or remembering information across sessions.
- Medical, legal, financial, or other high-stakes advice.
- Consistent, polished, or always sensible answers.
It may produce repetitive, odd, incomplete, or nonsensical text. That's part of experimenting with a tiny model β not a feature to trust with your taxes.
TinyGPT at a glance
| Property | Value |
|---|---|
| Model family | GPT-style decoder-only Transformer |
| Framework | PyTorch |
| Parameters | 1,022,592 |
| Transformer layers | 5 |
| Attention heads | 4 |
| Embedding dimension | 128 |
| Context length | 128 characters/tokens |
| Tokenization | Character-level |
| Character vocabulary | 56 characters + 1 end-of-reply token |
| Dropout | 0.1 |
| Training steps | Up to 3,000 |
| Optimizer | AdamW |
| Peak learning rate | 0.002 |
| Training batch size | 64 |
The model uses causal self-attention, LayerNorm, residual connections, GELU MLP blocks, and tied token-embedding/output weights.
How the little brain is put together
flowchart TD
A["Conversation text<br/>User: ... / Bot: ..."] --> B["Character tokenizer<br/>56 characters + EOS"]
B --> C["Token + position embeddings<br/>128 dimensions"]
C --> D["Transformer block 1"]
D --> E["Transformer block 2"]
E --> F["Transformer block 3"]
F --> G["Transformer block 4"]
G --> H["Transformer block 5"]
H --> I["Final LayerNorm"]
I --> J["Language-model output head"]
J --> K["Next-character generation"]
TinyGPT predicts text one character at a time. Its tokenizer is deliberately simple: it maps each character in its vocabulary to an integer. The model learns to predict the next character, with the training loss focused on the bot's answer rather than the prompt.
Training data
The model was trained using Neural-Labs/tiny-llm-dataset, a small synthetic conversational greetings dataset published by Neural Labs on Hugging Face.
According to the dataset card, it contains:
- 12,000 short synthetic conversation exchanges.
- Approximately 697,000 characters.
- 56 distinct characters.
- English greeting-style topics such as saying hello, asking how someone is, names, thanks, and goodbyes.
- Synthetic text generated from hand-written phrase lists, with small variations in capitalization and punctuation; the card states that it contains no scraped, copied, or personal data.
- Dataset license: MIT.
The dataset uses the same two-line conversation format expected by this project:
User: good morning
Bot: Good morning! Have a lovely day.
User: who made you
Bot: Neural Labs made me. They trained me on a small list of greetings.
The training notebook loads this data from a local file named train.txt. During preprocessing, the notebook:
- Normalizes Windows line endings.
- Splits the file into conversation blocks.
- Removes exact duplicate blocks.
- Shuffles the examples using a fixed seed.
- Keeps examples that fit within the model's 128-token context window.
- Reserves 5% of the examples for validation.
- Applies the training loss to the bot-answer portion of each example.
Attribution: Neural Labs β Tiny LLM Greetings Dataset. The dataset card lists the dataset license as MIT. The dataset file itself is not included in this model repository; the model was trained from the local train.txt copy.
Training setup
The notebook trains for up to 3,000 steps using:
- AdamW optimizer.
- Peak learning rate of
0.002. - 100 warmup steps followed by a cosine learning-rate schedule.
- Batch size of 64.
- Dropout of 0.1.
- Gradient clipping at 1.0.
- A 5% validation split.
The notebook saves the checkpoint when validation loss improves. The published checkpoint contains the model weights and the character list used by the tokenizer.
Use TinyGPT
1. Install the dependency
pip install torch
Or install from the included requirements file:
pip install -r requirements.txt
2. Download the model files
Keep these files in the same folder:
tinygpt_v2_conversation/
βββ README.md
βββ tinygpt_v2_conversation.pt
βββ inference.py
βββ requirements.txt
3. Start chatting
python inference.py --checkpoint tinygpt_v2_conversation.pt
The inference script is a simple command-line interface. Type quit or exit to stop.
Repository files
tinygpt_v2_conversation.ptβ trained model checkpoint (weights and character vocabulary).inference.pyβ script for loading the checkpoint and chatting with the model.requirements.txtβ Python dependency.training.ipynbβ optional training notebook, if included.
The training notebook is shared for transparency and learning. You do not need it to run the already-trained checkpoint.
Limitations and responsible use
TinyGPT v2 Conversation is an experimental educational model. Its outputs can be inaccurate, biased, nonsensical, or unsuitable. Do not use it as the sole basis for important decisions, and do not treat generated text as verified information.
A small note from the creator
This project is about learning by building: starting with a blank model, writing the training code, preparing the data, and seeing what a little Transformer can learn.
TinyGPT is tiny on purpose. Every parameter has a job. Most of them are just trying their best.
Have fun experimenting! β¨