Instructions to use pinkelephantlimited/1b-gpt2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pinkelephantlimited/1b-gpt2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="pinkelephantlimited/1b-gpt2")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("pinkelephantlimited/1b-gpt2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use pinkelephantlimited/1b-gpt2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "pinkelephantlimited/1b-gpt2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pinkelephantlimited/1b-gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/pinkelephantlimited/1b-gpt2
- SGLang
How to use pinkelephantlimited/1b-gpt2 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 "pinkelephantlimited/1b-gpt2" \ --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": "pinkelephantlimited/1b-gpt2", "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 "pinkelephantlimited/1b-gpt2" \ --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": "pinkelephantlimited/1b-gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use pinkelephantlimited/1b-gpt2 with Docker Model Runner:
docker model run hf.co/pinkelephantlimited/1b-gpt2
1B GPT-2 β Code & Math Language Model (Trained From Scratch)
A 1.19B-parameter causal language model trained entirely from scratch (random initialization, zero pretrained weights) on a weighted mix of code (70%) and mathematical text (30%). Built on the GPT-2 architecture (MIT license, OpenAI). Final training loss 3.057, best eval loss 3.571 at step 2000.
Why This Model
- Truly from scratch β no pretrained weights, no inherited bias; fully your own model.
- Code + Math focus β trained on clean code corpora and OpenWebMath, so it understands both programming syntax and mathematical reasoning.
- Small and fast β ~1.19B params, hundreds of tokens/sec on a modern GPU; ~3 GB VRAM for inference.
- Production-safe licensing β MIT: free to use, modify, and monetize.
Model Details
| Attribute | Value |
|---|---|
| Architecture | GPT-2 (causal LM, MIT) |
| Parameters | 1.19B |
| Layers / Hidden / Heads | 36 / 1600 / 25 |
| Context length | 1024 tokens |
| Vocab size | 50,257 (GPT-2 BPE) |
| Training steps | 2,000 (from scratch) |
| Total tokens | ~65.5M (32,768 tokens/step) |
| Batch | 4 per device Γ 8 gradient accumulation = 32 Γ 1024 seq |
| Optimizer | AdamW Β· lr 3e-4 cosine Β· warmup 500 Β· wd 0.01 |
| Precision | bf16 + gradient checkpointing |
| Final train loss | 3.057 |
| Best eval loss | 3.571 (step 2000) |
| Hardware | NVIDIA Blackwell B6000 (96 GB) Β· molab |
| License | MIT β free for commercial use |
Training Data β Full Dataset List
| Dataset | Content | Share | Streams | Used |
|---|---|---|---|---|
codeparrot/codeparrot-clean-subset |
Deduplicated clean code (Python, Java, JS, C++, Goβ¦) | 70% | Steps 0β1800 | Yes |
open-web-math/open-web-math |
Mathematical text from the web | 30% | Steps 0β2000 | Yes |
- Streamed with 10,000-sample shuffle buffer, seed 42.
- Tokenized on the fly (GPT-2 BPE, truncation to 1024), into a 50M-token RAM buffer.
- Chunked into 1024-token blocks; the last 500 blocks held out for evaluation (never seen during training).
- Note: the Codeparrot code stream became unreachable on the HF Hub partway through the project, so the final 200 steps (1800β2000) continued on OpenWebMath alone.
Training Loss Curve
Eval loss by step
| Step | Eval loss |
|---|---|
| 250 | 5.797 |
| 500 | 5.163 |
| 750 | 4.674 |
| 1000 | 4.257 |
| 1250 | 3.868 |
| 1500 | 3.678 |
| 1750 | 3.582 |
| 2000 | 3.571 |
Quickstart
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "pinkelephantlimited/1b-gpt2"
tokenizer = AutoTokenizer.from_pretrained(model_id, subfolder="final")
model = AutoModelForCausalLM.from_pretrained(
model_id, subfolder="final", torch_dtype=torch.bfloat16
).cuda().eval()
prompt = "def is_prime(n):\n "
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
out = model.generate(
**inputs, max_new_tokens=80, do_sample=True, temperature=0.7,
top_k=50, pad_token_id=tokenizer.eos_token_id,
)
print(tokenizer.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
Tip:
from_pretrained(..., device_map="auto")works too β only ~3 GB VRAM for inference.
Capabilities
- Code completion and function bodies (Python and other C-family languages)
- Mathematical and reasoning-style text generation
- General English text generation
Limitations
- Text only β cannot process images, PDFs, or Word documents directly; extract text first.
- Small model β not competitive with frontier LLMs on complex reasoning.
- Not instruction-tuned β use a prompting style, or fine-tune for chat.
- 1024-token context window.
- Trained on only ~65.5M tokens β a research-scale dataset; fine-tuning is recommended for production quality.
Reproducibility
- Seed 42 (data shuffle + training RNG)
- All training checkpoints (steps 200β2000) preserved in
checkpoints/ - Full log history in each checkpoint's
trainer_state.json - Final weights, tokenizer, and config in
final/
Base: GPT-2 (MIT) Β· Trained: molab (Blackwell B6000) Β· License: MIT
