Text Generation
Transformers
PyTorch
TensorFlow
JAX
LiteRT
Rust
ONNX
Safetensors
English
gpt2
exbert
text-generation-inference
Instructions to use openai-community/gpt2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openai-community/gpt2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="openai-community/gpt2")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("openai-community/gpt2") model = AutoModelForCausalLM.from_pretrained("openai-community/gpt2") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use openai-community/gpt2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openai-community/gpt2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openai-community/gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/openai-community/gpt2
- SGLang
How to use openai-community/gpt2 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 "openai-community/gpt2" \ --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": "openai-community/gpt2", "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 "openai-community/gpt2" \ --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": "openai-community/gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use openai-community/gpt2 with Docker Model Runner:
docker model run hf.co/openai-community/gpt2
Update model config to fix architecture mismatch
#159 opened 12 days ago
by
thawndev
Update config
#158 opened 12 days ago
by
thawndev
Add README security notice
#157 opened 12 days ago
by
thawndev
Update README.md
#142 opened 3 months ago
by
Highgroundbkk
Create ,ass
#132 opened 7 months ago
by
kakaj6354gmailcom
t
#130 opened 7 months ago
by
jslopez456
Update README.md
#128 opened 9 months ago
by
hambobo14
Update README.md
#118 opened about 1 year ago
by
KaliumPotas
Create Nicks Games Full
#115 opened over 1 year ago
by
Vanderleiaovargas
Update tokenizer_config.json
#112 opened over 1 year ago
by
Hungnh
Create prompt
1
#110 opened over 1 year ago
by
stopkid4
Testing_MH
#108 opened over 1 year ago
by
SaloniMhatre14
Rename README.md to 123
#103 opened almost 2 years ago
by
rajkumar321
Update README.md
#99 opened almost 2 years ago
by
zakharrudy
Rename README.md to sustantability
#97 opened almost 2 years ago
by
Eriroble
Update README.md
#95 opened almost 2 years ago
by
spthiago
gpt2
#93 opened about 2 years ago
by
HengyuLong
Update README.md
#91 opened about 2 years ago
by
MohammadSaeidi
Update README.md
1
#89 opened about 2 years ago
by
Montastein
Update README.md
#83 opened about 2 years ago
by
ayjays132
Update README.md
#82 opened about 2 years ago
by
ayjays132
Adding Evaluation Results
#81 opened about 2 years ago
by
leaderboard-pr-bot
Adding ONNX file of this model
#76 opened over 2 years ago
by
RaghulDevaraj
Add Core ML conversion
๐ 1
1
#72 opened over 2 years ago
by
ashlirankin18
Add Core ML conversion
#55 opened almost 3 years ago
by
tiharz
Add Core ML conversion
๐ 2
#54 opened almost 3 years ago
by
tiharz
Add Core ML conversion
#48 opened almost 3 years ago
by
EinfachOlder
Update README.md
#27 opened over 3 years ago
by
HotDog333
Update README.md
#25 opened over 3 years ago
by
Chaly
Update README.md
#22 opened over 3 years ago
by
Matrix369
Add evaluation results on the mathemakitten--winobias_antistereotype_test config and test split of mathemakitten/winobias_antistereotype_test
1
#10 opened over 3 years ago
by
autoevaluator
Add evaluation results on the constructive config and test split of phpthinh/exampletx
๐ 2
1
#9 opened over 3 years ago
by
autoevaluator
Add evaluation results on the toxic config and test split of phpthinh/exampletx
#8 opened over 3 years ago
by
autoevaluator