Text Generation
Transformers
PyTorch
English
gpt2
language-model
transformer
tiny-shakespeare
text-generation-inference
Instructions to use Pavloria/mini-language-model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Pavloria/mini-language-model with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Pavloria/mini-language-model")# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("Pavloria/mini-language-model") model = AutoModel.from_pretrained("Pavloria/mini-language-model") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Pavloria/mini-language-model with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Pavloria/mini-language-model" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Pavloria/mini-language-model", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Pavloria/mini-language-model
- SGLang
How to use Pavloria/mini-language-model with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Pavloria/mini-language-model" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Pavloria/mini-language-model", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Pavloria/mini-language-model" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Pavloria/mini-language-model", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Pavloria/mini-language-model with Docker Model Runner:
docker model run hf.co/Pavloria/mini-language-model
Update README.md
Browse filesAdded full model documentation and metadata
README.md
CHANGED
|
@@ -13,4 +13,38 @@ pipeline_tag: text-generation
|
|
| 13 |
|
| 14 |
# Mini Language Model
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# Mini Language Model
|
| 15 |
|
| 16 |
+
## 🧠 Model Description
|
| 17 |
+
This is a toy decoder-only language model based on a TransformerDecoder architecture. It was trained from scratch on the [Tiny Shakespeare dataset](https://huggingface.co/datasets/tiny_shakespeare) using PyTorch.
|
| 18 |
+
|
| 19 |
+
The goal was to explore autoregressive language modeling using minimal resources and libraries like torch.nn and transformers.
|
| 20 |
+
|
| 21 |
+
## 🏋️ Training Details
|
| 22 |
+
- **Architecture**: TransformerDecoder
|
| 23 |
+
- **Tokenizer**: GPT2Tokenizer from Hugging Face
|
| 24 |
+
- **Vocabulary Size**: 50257 (from GPT-2)
|
| 25 |
+
- **Sequence Length**: 64 tokens
|
| 26 |
+
- **Batch Size**: 8
|
| 27 |
+
- **Epochs**: 5
|
| 28 |
+
- **Learning Rate**: 1e-3
|
| 29 |
+
- **Number of Parameters**: ~900k
|
| 30 |
+
- **Hardware**: Trained on CPU (Google Colab)
|
| 31 |
+
|
| 32 |
+
## 📊 Evaluation
|
| 33 |
+
The model was evaluated on a 10% validation split. It shows consistent training and validation loss decrease, though it is not expected to produce coherent long text due to the small training size.
|
| 34 |
+
|
| 35 |
+
## 📂 Intended Use
|
| 36 |
+
This model is intended for educational purposes only. It is **not suitable for production use**.
|
| 37 |
+
|
| 38 |
+
## 🚫 Limitations
|
| 39 |
+
- Only trained on a tiny dataset
|
| 40 |
+
- Small architecture, limited capacity
|
| 41 |
+
- Limited ability to generalize or generate meaningful long text
|
| 42 |
+
|
| 43 |
+
## 💬 Example Usage (Python)
|
| 44 |
+
python
|
| 45 |
+
from transformers import GPT2Tokenizer
|
| 46 |
+
from model import MiniDecoderModel # Assuming you restore the class
|
| 47 |
+
|
| 48 |
+
tokenizer = GPT2Tokenizer.from_pretrained("Pavloria/mini-language-model")
|
| 49 |
+
model = MiniDecoderModel(...) # Load your config
|
| 50 |
+
model.load_state_dict(torch.load("pytorch_model.bin"))
|