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")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("openai-community/gpt2") model = AutoModelForCausalLM.from_pretrained("openai-community/gpt2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- 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 README.md
#198 opened about 1 month ago
by
victime343
Update README.md
#197 opened about 1 month ago
by
victime343
Update README.md
#196 opened about 1 month ago
by
victime343
Update README.md
#194 opened about 1 month ago
by
victime343
Update README.md
#193 opened about 1 month ago
by
victime343
x
#191 opened about 2 months ago
by
qwrqwrqwrqr
G052 CAS write test on foreign repo - authorized HackerOne testing 1789470293
#187 opened 2 months ago
by
0xmoose0xmoose0xmoose
Update README.md
#184 opened 2 months ago
by
xrachelburns
Delete tokenizer.json
1
#174 opened 3 months ago
by
Pro-Creator-16
Delete tokenizer.json
#173 opened 3 months ago
by
Pro-Creator-16
Delete tokenizer.json
#172 opened 3 months ago
by
Pro-Creator-16
Delete tokenizer.json
#171 opened 3 months ago
by
Pro-Creator-16
IDOR PR test from 0xtest1231
#165 opened 4 months ago
by
0xtest1231
Update model config to fix architecture mismatch
1
#159 opened 6 months ago
by
thawndev
Update config
#158 opened 6 months ago
by
thawndev
Add README security notice
#157 opened 6 months ago
by
thawndev
Update README.md
#142 opened 9 months ago
by
Highgroundbkk
Create ,ass
#132 opened about 1 year ago
by
kakaj6354gmailcom
t
#130 opened about 1 year ago
by
jslopez456
Update README.md
#128 opened about 1 year ago
by
hambobo14
Update README.md
#118 opened over 1 year ago
by
KaliumPotas
Create Nicks Games Full
#115 opened almost 2 years ago
by
Vanderleiaovargas
Update tokenizer_config.json
#112 opened almost 2 years ago
by
Hungnh
Create prompt
1
#110 opened almost 2 years ago
by
stopkid4
Testing_MH
#108 opened about 2 years ago
by
SaloniMhatre14
Rename README.md to 123
#103 opened about 2 years ago
by
rajkumar321
Update README.md
#99 opened over 2 years ago
by
zakharrudy
Rename README.md to sustantability
#97 opened over 2 years ago
by
Eriroble
Update README.md
#95 opened over 2 years ago
by
spthiago
gpt2
#93 opened over 2 years ago
by
HengyuLong
Update README.md
#91 opened over 2 years ago
by
MohammadSaeidi
Update README.md
1
#89 opened over 2 years ago
by
Montastein
Update README.md
#83 opened over 2 years ago
by
ayjays132
Update README.md
#82 opened over 2 years ago
by
ayjays132
Adding Evaluation Results
#81 opened over 2 years ago
by
leaderboard-pr-bot
Adding ONNX file of this model
#76 opened almost 3 years ago
by
RaghulDevaraj
Add Core ML conversion
👍 1
1
#72 opened about 3 years ago
by
ashlirankin18
Add Core ML conversion
#55 opened over 3 years ago
by
tiharz
Add Core ML conversion
👍 2
#54 opened over 3 years ago
by
tiharz
Add Core ML conversion
#48 opened over 3 years ago
by
EinfachOlder
Update README.md
#27 opened almost 4 years ago
by
HotDog333
Update README.md
#25 opened almost 4 years ago
by
Chaly
Update README.md
#22 opened almost 4 years ago
by
Matrix369