Text Generation
Transformers
PyTorch
TensorFlow
JAX
LiteRT
Rust
Core ML
Safetensors
English
gpt2
exbert
Eval Results (legacy)
text-generation-inference
Instructions to use distilbert/distilgpt2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use distilbert/distilgpt2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="distilbert/distilgpt2")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("distilbert/distilgpt2") model = AutoModelForCausalLM.from_pretrained("distilbert/distilgpt2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use distilbert/distilgpt2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "distilbert/distilgpt2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "distilbert/distilgpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/distilbert/distilgpt2
- SGLang
How to use distilbert/distilgpt2 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 "distilbert/distilgpt2" \ --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": "distilbert/distilgpt2", "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 "distilbert/distilgpt2" \ --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": "distilbert/distilgpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use distilbert/distilgpt2 with Docker Model Runner:
docker model run hf.co/distilbert/distilgpt2
Commit History
-
Add emissions estimate to metadata
d88f305 -
New model card for distilgpt2 (#1)
- New model card for distilgpt2 (842d97f3802cc8d0d2a4a7d0afc2406571e8d284) Co-authored-by: Gerchick <Marissa@users.noreply.huggingface.co>737e343
-
upload flax model
96699c9 -
allow flax
2ddd647 -
allow flax
92838a2
-
Migrate model card from transformers-repo
Read announcement at https://discuss.huggingface.co/t/announcement-all-model-cards-will-be-migrated-to-hf-co-model-repos/2755 Original file history: https://github.com/huggingface/transformers/commits/master/model_cards/distilgpt2-README.md9851938
-
For clarity, delete deprecated modelcard.json
We now use the README.md model card instead Approved-by: Julien Chaumond <julien@huggingface.co>58ada35
-
Update tokenizer.json
b6d23df
-
Update config.json
e87a92b
-
Update rust_model.ot
17ef8ca -
Update config.json
b09826e
-
Update config.json
51ab088
-
Update modelcard.json
baa9aea
-
Update 64.tflite
2677794
-
Update pytorch_model.bin
36840f1 -
Update tf_model.h5
b70d85d
-
Update config.json
0799984 -
Update merges.txt
0c7d1e1 -
Update config.json
09daaa0 -
Update vocab.json
db73fa3 -
initial commit
1b04b2c