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 8 days ago
by
thawndev
Update config
#158 opened 8 days ago
by
thawndev
Add README security notice
#157 opened 8 days ago
by
thawndev
Security Test - Please Ignore
#155 opened 12 days ago
by
FIRSTACCOUNT69
Install & run openai-community/gpt2 easily using llmpm
#152 opened 2 months ago
by
sarthak-saxena
Read token scope test
#148 opened 3 months ago
by
FIRSTACCOUNT69
Security Test
1
#147 opened 3 months ago
by
FIRSTACCOUNT69
Security Test - Please Ignore
#146 opened 3 months ago
by
FIRSTACCOUNT69
Update README.md
#142 opened 3 months ago
by
Highgroundbkk
Gemini PTD Ambassador: Entropy Audit
#140 opened 4 months ago
by
lomax3
SECURITY REPORT: Recursive Collapse Limit Found at Gen 20
#139 opened 5 months ago
by
Mhh1430
Empty Description Test
#138 opened 5 months ago
by
121tester
Changed Title via Mercury Framework Test
1
#137 opened 5 months ago
by
121tester
Test Discussion
#136 opened 5 months ago
by
121tester
trans
#133 opened 6 months ago
by
skaksjsowosj
Create ,ass
#132 opened 6 months ago
by
kakaj6354gmailcom
t
#130 opened 7 months ago
by
jslopez456
Update README.md
#128 opened 8 months ago
by
hambobo14
Sorry but whats the api_url?
#124 opened 10 months ago
by
Zwalker559
The parameter, max_length, seems to be manipulated to some random value which is different with input, when tried to use for text-generation with pipeline.
3
#123 opened 10 months ago
by
adover134
Mistral-Nemo-Instruct-2407 in ONNX?!?
#119 opened 12 months ago
by
techAInewb
Update README.md
#118 opened about 1 year ago
by
KaliumPotas
error 429
1
#117 opened about 1 year ago
by
Elllena
Hi my name
#116 opened about 1 year ago
by
AdOnBoard1979
Create Nicks Games Full
#115 opened over 1 year ago
by
Vanderleiaovargas
Update tokenizer_config.json
#112 opened over 1 year ago
by
Hungnh
🚩 Report: Not working
#111 opened over 1 year ago
by
qq11024084
Create prompt
1
#110 opened over 1 year ago
by
stopkid4
Model gpt2 return repeated sentences
1
#109 opened over 1 year ago
by
zeeskhan
Testing_MH
#108 opened over 1 year ago
by
SaloniMhatre14
Can't load tokenizer for 'gpt2'.
1
#107 opened over 1 year ago
by
momomos
🚩 Report: Not working
#106 opened over 1 year ago
by
QTRrrrrrr
Interview request: genAI evaluation & documentation
#104 opened over 1 year ago
by
evatang
Rename README.md to 123
#103 opened almost 2 years ago
by
rajkumar321
Fine-tuning question about openai-community/gpt2
#102 opened almost 2 years ago
by
the-zooid
How to Perform Inference with GPT-2 Mini Model in Flutter Using ONNX Runtime
🔥👀 2
4
#101 opened almost 2 years ago
by
junssashu
gpt2 output error
1
#100 opened almost 2 years ago
by
ztpz
Update README.md
#99 opened almost 2 years ago
by
zakharrudy
OSError: gpt2 does not appear to have a file named config.json. Checkout 'https://huggingface.co/gpt2/None' for available files.
1
#98 opened almost 2 years ago
by
Iust1n2
Rename README.md to sustantability
#97 opened almost 2 years ago
by
Eriroble
Update README.md
#95 opened almost 2 years ago
by
spthiago
solve memory issue in conv1D attention module of gpt2
#94 opened almost 2 years ago
by
rariwa
gpt2
#93 opened almost 2 years ago
by
HengyuLong
Update README.md
#91 opened about 2 years ago
by
MohammadSaeidi