ONNX Model Zoo

Clausss/gpt-2-70m-ONNX

By Clausss · ↓ 2 · ♥ 0 · Updated 2025-11-17

What's in this repo

This page lists the files in Clausss/gpt-2-70m-ONNX, including model.onnx, model_bnb4.onnx, model_fp16.onnx and more.

  • 8 ONNX models (.onnx files)
  • 18 files, including 8 .onnx, 7 .json, 1 .md, 1 .txt
  • Last updated 2025-11-17

ONNX files

File Size Download
onnx/model.onnx — Download
onnx/model_bnb4.onnx — Download
onnx/model_fp16.onnx — Download
onnx/model_int8.onnx — Download
onnx/model_q4.onnx — Download
onnx/model_q4f16.onnx — Download
onnx/model_quantized.onnx — Download
onnx/model_uint8.onnx — Download

How to use

These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.

README

gpt-2-70m (ONNX)

This is an ONNX version of codelion/gpt-2-70m. It was automatically converted and uploaded using this Hugging Face Space.

Usage with Transformers.js

See the pipeline documentation for text-generation: https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.TextGenerationPipeline


GPT-2 70M - Optimal Dataset Mixing

A 70M parameter GPT-2 model trained on 1 billion tokens using an optimized 50-30-20 dataset mixing strategy.

Model Description

This model demonstrates the effectiveness of careful dataset composition for efficient language model pretraining. Despite using 10x less training data than GPT-2 (1B vs 10B tokens), it achieves competitive performance by leveraging an optimal mixture of high-quality data sources.

Architecture: GPT-2

  • Parameters: 70M (64.09M trainable)
  • Layers: 12
  • Hidden Size: 512
  • Attention Heads: 8
  • Context Length: 1024 tokens
  • Vocabulary Size: 50,257

Training Data

The model was trained on 1 billion tokens with the following composition:

  • 50% - FinePDFs (500M tokens): High-quality PDF content
  • 30% - DCLM Baseline (300M tokens): Filtered web content
  • 20% - FineWeb-Edu (200M tokens): Educational web content

This 50-30-20 mixing ratio was identified through systematic experimentation as optimal for balanced performance across multiple domains.

Training Details

  • Total Tokens: 1,000,000,000
  • Batch Size: 24 (effective: 120 with gradient accumulation)
  • Learning Rate: 5e-4 → 5e-5 (cosine decay)
  • Warmup Steps: 162 (2% of total)
  • Precision: BFloat16
  • Optimizer: AdamW
  • Final Loss: 2.92

Benchmark Results

Performance Comparison

Benchmark Our Model Random GPT-2 vs Random vs GPT-2
MMLU (5-shot) 24.11% 25.00% 26.00% -0.89% -1.89%
HellaSwag (0-shot) 27.03% 25.00% 30.00% +2.03% -2.97%
ARC-Challenge (0-shot) 21.67% 25.00% 24.00% -3.33% -2.33%
PIQA (0-shot) 57.29% 50.00% 63.00% +7.29% -5.71%
WinoGrande (0-shot) 51.46% 50.00% 51.00% +1.46% +0.46%
TruthfulQA MC2 (0-shot) 47.31% 25.00% 40.00% +22.31% +7.31%
Average 38.15% 33.33% 39.00% +4.81% -0.85%

Key Findings

  • Performance Gap: Only 0.85% behind GPT-2 baseline (39.00%)
  • Efficiency: Achieves 84.9% of GPT-2's performance improvement over random guessing
  • Data Efficiency: Competitive results with 10x less training data
  • TruthfulQA Excellence: +7.31% above GPT-2 baseline, demonstrating superior factual accuracy

Usage

from transformers import AutoTokenizer, AutoModelForCausalLM

# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("codelion/gpt-2-70m")
model = AutoModelForCausalLM.from_pretrained("codelion/gpt-2-70m")

# Generate text with better sampling parameters
inputs = tokenizer("The future of AI is", return_tensors="pt")
outputs = model.generate(
    **inputs,
    max_length=50,
    do_sample=True,           # Enable sampling
    temperature=0.8,          # Control randomness
    top_p=0.9,               # Nucleus sampling
    pad_token_id=tokenizer.eos_token_id
)
print(tokenizer.decode(outputs[0]))

Key Insights

  1. Data Quality > Quantity: The 50-30-20 mixing strategy demonstrates that careful dataset composition can achieve strong performance with significantly reduced compute
  2. Factual Accuracy: The model excels at truthfulness (TruthfulQA), likely due to high-quality FinePDF content (50%)
  3. Practical Commonsense: Strong performance on PIQA and WinoGrande shows effective real-world reasoning
  4. Knowledge Gaps: Below-random performance on MMLU and ARC-Challenge indicates insufficient academic/scientific knowledge for this scale

Limitations

  • Academic Knowledge: Limited performance on academic benchmarks (MMLU, ARC-Challenge)
  • Training Scale: 1B tokens is insufficient for comprehensive world knowledge
  • Parameter Count: 70M parameters may limit capacity for complex reasoning

Citation

If you use this model/dataset, please cite:

@article{sharma2025billion,
  title={The 1 Billion Token Challenge: Finding the Perfect Pre-training Mix},
  author={Sharma, Asankhaya},
  year={2025},
  url={https://huggingface.co/blog/codelion/optimal-dataset-mixing/}
}

For more details, see the blog post.

Model Card Authors

codelion

Model Card Contact

For questions or issues, please open an issue on the model repository.

Model info

text-generation transformers.js
transformers.js onnx gpt2 text-generation dataset-mixing pretraining en dataset:codelion/finepdfs-1B dataset:codelion/dclm-baseline-1B dataset:codelion/fineweb-edu-1B base_model:codelion/gpt-2-70m base_model:quantized:codelion/gpt-2-70m
↓ 2 ♥ 0

Created: 2025-11-17

Updated: 2025-11-17

View on Hugging Face

Files (18)

.gitattributes
README.md
config.json
generation_config.json
merges.txt
onnx/model.onnx ONNX
onnx/model_bnb4.onnx ONNX
onnx/model_fp16.onnx ONNX
onnx/model_int8.onnx ONNX
onnx/model_q4.onnx ONNX
onnx/model_q4f16.onnx ONNX
onnx/model_quantized.onnx ONNX
onnx/model_uint8.onnx ONNX
quantize_config.json
special_tokens_map.json
tokenizer.json
tokenizer_config.json
vocab.json

Related models