roneneldan/TinyStories
Viewer • Updated • 2.14M • 216k • 1.31k
How to use superMohammad/GenerativeAICourse-llama-75m with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="superMohammad/GenerativeAICourse-llama-75m") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("superMohammad/GenerativeAICourse-llama-75m")
model = AutoModelForCausalLM.from_pretrained("superMohammad/GenerativeAICourse-llama-75m", device_map="auto")How to use superMohammad/GenerativeAICourse-llama-75m with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "superMohammad/GenerativeAICourse-llama-75m"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "superMohammad/GenerativeAICourse-llama-75m",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/superMohammad/GenerativeAICourse-llama-75m
How to use superMohammad/GenerativeAICourse-llama-75m with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "superMohammad/GenerativeAICourse-llama-75m" \
--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": "superMohammad/GenerativeAICourse-llama-75m",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "superMohammad/GenerativeAICourse-llama-75m" \
--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": "superMohammad/GenerativeAICourse-llama-75m",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use superMohammad/GenerativeAICourse-llama-75m with Docker Model Runner:
docker model run hf.co/superMohammad/GenerativeAICourse-llama-75m
A 75M-parameter Llama-style language model trained from scratch on TinyStories for a Generative AI course lab on scaling laws. It writes short, simple children's stories in English.
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "superMohammad/GenerativeAICourse-llama-75m"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo)
prompt = "Once upon a time, a little robot found a book."
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
output = model.generate(**inputs, max_new_tokens=80, do_sample=False)
print(tokenizer.decode(output[0], skip_special_tokens=True))
| Architecture | LlamaForCausalLM |
| Parameters | 74,998,272 |
| Layers | 24 |
| Hidden size | 512 |
| MLP size | 1408 (SiLU) |
| Attention heads | 8 query / 4 key-value (GQA), head dim 64 |
| Context length | 512 tokens |
| Vocabulary | 8,192 (byte-level BPE trained on the training split) |
| Embeddings | tied input/output |
| Data | 300,000 TinyStories documents, split 270k / 15k / 15k (train / val / test) |
| Tokens seen | 524,288,000 (1,000 updates × 32 sequences × 32 accumulation × 512 tokens) |
| Optimizer | AdamW, β = (0.9, 0.95), weight decay 0.1, grad clip 1.0 |
| Learning rate | 3e-4, 100 warmup steps, cosine decay to 0 |
| Precision | mixed precision (FP16 autocast) on a single GPU |
| Seed | 42 |
The run used about 35% of the Chinchilla-style budget of 20 tokens per parameter (≈1.5B tokens).
| Split | Loss | Perplexity |
|---|---|---|
| Validation (before training) | 9.033 | 8374 |
| Validation | 1.901 | 6.69 |
| Test | 1.899 | 6.68 |
The repository also contains experiment.json (the full run record) and loss_curve.png.
Prompt: Once upon a time, a little robot found a book.
bo bo bo bo bo bo ...