Text Generation
Transformers
Safetensors
English
gpt2
causal-lm
trained-from-scratch
text-generation-inference
Instructions to use yorukot/gpt2-traning with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yorukot/gpt2-traning with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yorukot/gpt2-traning")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("yorukot/gpt2-traning") model = AutoModelForCausalLM.from_pretrained("yorukot/gpt2-traning", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yorukot/gpt2-traning with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yorukot/gpt2-traning" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yorukot/gpt2-traning", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/yorukot/gpt2-traning
- SGLang
How to use yorukot/gpt2-traning 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 "yorukot/gpt2-traning" \ --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": "yorukot/gpt2-traning", "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 "yorukot/gpt2-traning" \ --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": "yorukot/gpt2-traning", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use yorukot/gpt2-traning with Docker Model Runner:
docker model run hf.co/yorukot/gpt2-traning
GPT-2 trained on C4 — Lab 4, AD
This is the lab4-yoru-AD-488712 checkpoint, trained from scratch on English C4.
It has the lowest local validation loss of our runs so far. The reported score is a
local evaluation, not an official online-judge result.
Model
- Stock Hugging Face
GPT2LMHeadModel: 12 layers, 12 attention heads, hidden width 768, context length 1,024, vocabulary 50,257, tied input/output embeddings. - 124,439,808 unique parameters, saved in FP32.
- GPT-2 tokenizer. No pretrained model weights were used.
Training
- Data: C4
entrain, tokenized with the GPT-2 tokenizer without BOS/EOS. Documents were truncated to 1,024 tokens and best-fit packed into 1,024-token rows, with positions restarting at 0 for each document. - Attention was restricted to each document during training (varlen flash attention). This is a training-time kernel only; the saved model is plain GPT-2.
- Exact deduplication. The first 100,000 documents of
validation.shuffle(seed=42)(the lab's test set) were excluded. - AdamW (fused): learning rate 1.8e-3, betas (0.9, 0.95), eps 1e-8, weight decay 0.1 on matrices only, gradient clipping 1.0, dropout 0, random seed 42.
- Schedule: 150 warmup steps, full learning rate for the first half of the training time, then linear decay to 0.
- Batch: 256 rows × 1,024 tokens = 262,144 token slots per step (including padding). 6,010 steps, about 1.58B token slots.
- The vocabulary was padded to 50,304 during training and sliced back to 50,257 before saving.
- Two NVIDIA H200 GPUs, BF16 autocast,
torch.compile, 29 minutes of training. PyTorch 2.14.0, Transformers 5.17.0.
Evaluation
The evaluation set is the 10,000 C4 en validation documents that follow the lab's
100,000 test documents in validation.shuffle(seed=42). It is scored like the lab's
judge:
- Each document is scored on its own, from position 0, with no BOS.
- Each document is truncated to 1,024 tokens.
- The score is total loss divided by the number of scored tokens.
| Split | Documents | Loss | Perplexity |
|---|---|---|---|
| Local validation | 10,000 | 3.3149 | 27.52 |
Load the checkpoint
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "yorukot/gpt2-traning"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
This is a base language model for an educational experiment, without instruction tuning. Its web training data can produce inaccurate or biased text.
- Downloads last month
- 1,124
Dataset used to train yorukot/gpt2-traning
Viewer • Updated • 10.4B • 855k • 682