Instructions to use ulmentflam/gpt2-124m-fineweb-mojo with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ulmentflam/gpt2-124m-fineweb-mojo with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ulmentflam/gpt2-124m-fineweb-mojo")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ulmentflam/gpt2-124m-fineweb-mojo") model = AutoModelForCausalLM.from_pretrained("ulmentflam/gpt2-124m-fineweb-mojo") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ulmentflam/gpt2-124m-fineweb-mojo with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ulmentflam/gpt2-124m-fineweb-mojo" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ulmentflam/gpt2-124m-fineweb-mojo", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ulmentflam/gpt2-124m-fineweb-mojo
- SGLang
How to use ulmentflam/gpt2-124m-fineweb-mojo 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 "ulmentflam/gpt2-124m-fineweb-mojo" \ --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": "ulmentflam/gpt2-124m-fineweb-mojo", "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 "ulmentflam/gpt2-124m-fineweb-mojo" \ --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": "ulmentflam/gpt2-124m-fineweb-mojo", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ulmentflam/gpt2-124m-fineweb-mojo with Docker Model Runner:
docker model run hf.co/ulmentflam/gpt2-124m-fineweb-mojo
GPT-2 124M, trained from scratch on FineWeb (llm.mojo)
A GPT-2 124M (d12: 12 layers, 12 heads, 768 channels) language model trained
from scratch (random initialization, no GPT-2 weight warm-start) for one
full epoch on the FineWeb
classic 10B-token sample, using
llm.mojo — a Mojo/MAX port of
Andrej Karpathy's llm.c.
This repo exists primarily as a training-run artifact / reproducibility reference for the llm.mojo project, not as a state-of-the-art model. At this scale and data budget, GPT-2 124M produces locally-coherent but not highly capable text.
Architecture
| Params | 124M |
| Layers | 12 |
| Heads | 12 |
| Channels | 768 |
| Context length | 1024 |
| Vocab | 50257 (GPT-2 BPE), padded to 50304 internally |
| Precision (training) | bf16 |
Architecture and tokenizer are unmodified GPT-2 (GPT2LMHeadModel /
GPT2Tokenizer from gpt2).
Training
- Initialization: random (from scratch, no pretrained warm-start)
- Data:
HuggingFaceFW/fineweb,sample-10BTconfig (FineWeb "classic" 10B-token sample), tokenized with the GPT-2 BPE tokenizer - Epochs: 1 full epoch = 19,552 steps
- Effective batch size: 524,288 tokens/step
- LR schedule: cosine decay, 6e-4 peak
- Precision: bf16
- Final validation loss: 3.2807
- Hardware: single NVIDIA GB10
- Training code: github.com/ulmentflam/llm.mojo
This run hit two unrelated hardware crashes on the training box during the
run; both were recovered from checkpoint without loss of training progress.
See docs/ai/ in
the training repo for the full incident writeup (in progress at time of
publishing this checkpoint).
Files in this repo
- Root (this directory): a standard Hugging Face
transformersGPT2LMHeadModelexport (safetensors, bf16 weights) — use this for everyday inference withtransformers. llm_mojo_raw_checkpoint/model_19552.bin: the original raw llm.mojo checkpoint (llm.c-compatible binary format, 249MB), for reproducibility with the original llm.c / llm.mojo training and inference toolchains. This is the exact byte-for-byte checkpoint produced by the training run — the safetensors export above is derived from it, not the other way around.
About the raw checkpoint's magic number
llm.mojo checkpoints use their own format magic number (20240520, see
MODEL_MAGIC in
llmm/checkpointing.mojo)
to distinguish them from upstream llm.c's own checkpoints (magic
20240326), even though the 256-int32 header layout and parameter blob
order are otherwise byte-identical. If you want to run
third_party/llm.c/dev/eval/export_hf.py (upstream llm.c's own HF
converter) directly against model_19552.bin, you'll need a magic-patched
copy first — the llm.mojo repo provides
scripts/export_to_hf.py
to do exactly that (and nothing else): it makes a temporary patched copy,
never touches the source file, and is what produced the safetensors export
published in this repo. This is intentional, documented behavior, not a
format inconsistency.
Usage
from transformers import GPT2LMHeadModel, GPT2Tokenizer
model = GPT2LMHeadModel.from_pretrained("ulmentflam/gpt2-124m-fineweb-mojo")
tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
inputs = tokenizer("The quick brown fox", return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=40, do_sample=False)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
AutoModelForCausalLM / AutoTokenizer work equally well since this is a
standard GPT-2 architecture:
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("ulmentflam/gpt2-124m-fineweb-mojo")
tokenizer = AutoTokenizer.from_pretrained("gpt2")
To load the raw llm.mojo/llm.c-format checkpoint instead (e.g. for
continued training or evaluation with the original toolchains), download
llm_mojo_raw_checkpoint/model_19552.bin and follow the
llm.mojo or
llm.c instructions for loading a
model_*.bin checkpoint.
Dataset license and attribution
Training data is the sample-10BT config of
HuggingFaceFW/fineweb,
licensed under ODC-BY 1.0 (Open Data Commons Attribution License). Per
that dataset's card: the underlying content is derived from CommonCrawl web
crawl archives, and use of the dataset should credit both the FineWeb
project and CommonCrawl as the original source, and remains subject to
CommonCrawl's own terms of use for the underlying crawled content.
Model license
This model's weights are released under the same ODC-BY terms as the training data, given the model is a direct statistical function of it.
Citation / acknowledgments
- Downloads last month
- 270