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
Security Test - Please Ignore
#155 opened 20 days ago
by
FIRSTACCOUNT69
Install & run openai-community/gpt2 easily using llmpm
#152 opened 3 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
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 7 months ago
by
skaksjsowosj
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
error 429
1
#117 opened about 1 year ago
by
Elllena
Hi my name
#116 opened about 1 year ago
by
AdOnBoard1979
🚩 Report: Not working
#111 opened over 1 year ago
by
qq11024084
Model gpt2 return repeated sentences
1
#109 opened over 1 year ago
by
zeeskhan
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
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
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
solve memory issue in conv1D attention module of gpt2
#94 opened about 2 years ago
by
rariwa
GPT2 Reproduce results with lm-evaluation-harness
1
#90 opened about 2 years ago
by
david5819
AttributeError: 'GPT2LMHeadModel' object has no attribute 'bind'
2
#88 opened about 2 years ago
by
saxenaindresh681
model output
2
#86 opened about 2 years ago
by
foxsilverfox
Getting Error while using RetrievalQA.from_chain_type(llm=llm, chain_type="stuff", retriever=docsearch.as_retriever())
#85 opened about 2 years ago
by
Omkar-LLM
How to use this onnx model
4
#84 opened about 2 years ago
by
mkj69
openai-community/gpt2 throws error with SpaCy framework
3
#79 opened over 2 years ago
by
csesaswati
request: Add flash attention 2.0 support for GPT2LMHeadModel
1
#75 opened over 2 years ago
by
brresnic
Train to GPT-2 with own data
1
#73 opened over 2 years ago
by
JeisonJimenez
[AUTOMATED] Model Memory Requirements
#71 opened over 2 years ago
by
model-sizer-bot
License text is not available
1
#66 opened almost 3 years ago
by
Wovchena
Replication of Inference API
#63 opened almost 3 years ago
by
henningheyen
OSError: gpt2 does not appear to have a file named config.json. Checkout 'https://huggingface.co/gpt2/None' for available files.
9
#59 opened almost 3 years ago
by
MorphzZ
OutOfMemoryError: CUDA out of memory despite available GPU memory
#58 opened almost 3 years ago
by
humza-sami
how to output the scores of probabilities, rather than only output ids
#57 opened almost 3 years ago
by
tongliuphysics
Why do gpt-2 model response so different in computer run and chaquopy android run?
👍 1
#56 opened almost 3 years ago
by
gamingjam60
Fine-tuning a language model for question-answering
1
#50 opened almost 3 years ago
by
tbomez
Fine-tuning a language model to create an assistant
#49 opened almost 3 years ago
by
tbomez
PyTorch decode output
👍 1
9
#46 opened almost 3 years ago
by
LionKingMerlin
Cannot plot a loss curve for the text generation gpt2 model
#39 opened about 3 years ago
by
workpiece
model X
#32 opened over 3 years ago
by
vexxxccccccc
How to stream partial results?
#21 opened over 3 years ago
by
Justlearn
Sentence to product name generator
❤️ 1
2
#15 opened over 3 years ago
by
rsingh888
Simple knowledge
❤️ 2
#5 opened over 3 years ago
by
Iron-Horseman
Are linebreaks relevant for training/finetuning?
❤️👍 1
#4 opened over 3 years ago
by
xalex