Text Generation
Transformers
Safetensors
English
llama
causal-lm
tinystories
from-scratch
text-generation-inference
Instructions to use superMohammad/GenerativeAICourse-llama-75m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
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") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use superMohammad/GenerativeAICourse-llama-75m with vLLM:
Install from pip and serve model
# 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 }'Use Docker
docker model run hf.co/superMohammad/GenerativeAICourse-llama-75m
- SGLang
How to use superMohammad/GenerativeAICourse-llama-75m 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 "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 }'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 "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 Model Runner
How to use superMohammad/GenerativeAICourse-llama-75m with Docker Model Runner:
docker model run hf.co/superMohammad/GenerativeAICourse-llama-75m
|
Download README.md from superMohammad/GenerativeAICourse-llama-75m: direct link, hf CLI and curl.
- Browser
- Download file 2.74 kB
-
https://huggingface.co/superMohammad/GenerativeAICourse-llama-75m/resolve/main/README.md
- Command line
-
hf download hf://superMohammad/GenerativeAICourse-llama-75m/README.md
-
curl -L -o README.md https://huggingface.co/superMohammad/GenerativeAICourse-llama-75m/resolve/main/README.md
2.74 kB
metadata
language: en
library_name: transformers
pipeline_tag: text-generation
datasets:
- roneneldan/TinyStories
tags:
- llama
- causal-lm
- tinystories
- from-scratch
This work was done by Mohammad Almalke & Abdullrahman Almuharib
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.
Quick start
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))
Model
| 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 |
Training
| 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).
Results
| 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.
- Before training:
bo bo bo bo bo bo ... - After training: The robot was very happy and wanted to read it. So, the robot went to the library to find the book. But when he got there, he saw that the book was not there. The robot was sad and scared...
Limitations
- Trained only on synthetic children's stories, so it has no general knowledge and can't follow instructions.
- It often repeats itself and loses track of characters in long generations.
- English only, with a 512-token context.