Text Generation
Transformers
PyTorch
TensorFlow
JAX
Rust
ONNX
Safetensors
English
gpt2
text-generation-inference
Instructions to use openai-community/gpt2-medium with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openai-community/gpt2-medium with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="openai-community/gpt2-medium")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("openai-community/gpt2-medium") model = AutoModelForCausalLM.from_pretrained("openai-community/gpt2-medium", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use openai-community/gpt2-medium with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openai-community/gpt2-medium" # 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-medium", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/openai-community/gpt2-medium
- SGLang
How to use openai-community/gpt2-medium 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-medium" \ --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-medium", "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-medium" \ --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-medium", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use openai-community/gpt2-medium with Docker Model Runner:
docker model run hf.co/openai-community/gpt2-medium
Commit History
-
Adds the tokenizer configuration file (#13)
Verified signature- Adds tokenizer_config.json file (46d27d4bef13a36eebe5b89bbb1bd2d072a379d0)6dcaa7a
-
Adding ONNX file of this model (#9)
- Adding ONNX file of this model (27b27873f195001365fb7b45c770f6e987540a56)f65d496
-
Adding `safetensors` variant of this model (#5)
- Adding `safetensors` variant of this model (324159f8fc4af768042b85cb32f0117fdf90482f) Co-authored-by: Nicolas Patry <Narsil@users.noreply.huggingface.co>425b0cc
-
Adding generation config file(s)
a8543b8
-
Remove explicit table of contents (#2)
- Remove explicit table of contents (1a9de3041869f969852c7f9148cd1f69219dfe38) Co-authored-by: Christopher Akiki <cakiki@users.noreply.huggingface.co>e852c90
-
Add model card (#1)
- Add model card (b8456e5f84d5d477ccc1414868fdb8f55d16218a) - fix code examples (19c9a69f0710edec6a14c4e523a63e2c72512e6c) - fix typo (3de2d0d799d0e9c30bd86f2caf62542c0c0fa84b) - fix typo (0bc8fecec66c4a06e47136d6911a3a7c57e622db) Co-authored-by: Marissa Gerchick <Marissa@users.noreply.huggingface.co>8c7ca69
-
upload flax model
db57b2f -
allow flax
4c9f740
-
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/gpt2-medium-README.md6a81b3f
-
For clarity, delete deprecated modelcard.json
We now use the README.md model card instead Approved-by: Julien Chaumond <julien@huggingface.co>b9fd73a
-
Update tokenizer.json
1538118
-
Update config.json
8cc8ed4
-
Update rust_model.ot
a4b58be
-
Update config.json
a0d42db
-
Update config.json
0a83037
-
Update modelcard.json
242f801
-
Update tf_model.h5
5117318
-
Update config.json
127883f -
Update merges.txt
22651d3 -
Update pytorch_model.bin
7b10018 -
Update vocab.json
e441e78 -
initial commit
d61fcf1