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
-
Adds the tokenizer configuration file (#11)
Verified signature- Adds tokenizer_config.json file (224ef41937cdc7356116ead4957486726c164585)2290a62
-
Add Core ML conversion (#10)
- Add Core ML conversion (da7a025bb8bec96ea621071459891f8510e087ee)38cc92e
-
Adding generation config file(s)
f241065 -
Delete generation_config.json
a748e05 -
Delete {pipeline}_generation_config.json
32007bf -
Adding generation config file(s)
9e4cf98
-
Adding `safetensors` variant of this model (#7)
- Adding `safetensors` variant of this model (4244ff61fb228ec942af0d72c89fedc9bc5faa31) Co-authored-by: Nicolas Patry <Narsil@users.noreply.huggingface.co>ee0b29d
-
Add CoreML model (#6)
- Add CoreML model from `swift-coreml-transformers` (ce12f280c1983b3a6adbda16509f60df72d23bfc)c3772e6
-
Fix emissions metadata (#5)
- Fix emissions metadata (a4c384883991d625e3d61ac5a1cd2d2a6f36f4d0) Co-authored-by: Marissa Gerchick <Marissa@users.noreply.huggingface.co>ca98be8
-
Limit use of collapsible sections; fix emissions info (#3)
- Limit use of collapsible sections; fix emissions info (3deddb68871f490464a4d826c79d843a5df0cba5) - Small section rearranging (2d7a5d85877caa19abc0cee1117efc0c62d5dcb1) Co-authored-by: Marissa Gerchick <Marissa@users.noreply.huggingface.co>b754fe8
-
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