Instructions to use itlrc/gpt2-small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use itlrc/gpt2-small with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="itlrc/gpt2-small", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("itlrc/gpt2-small", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use itlrc/gpt2-small with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "itlrc/gpt2-small" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "itlrc/gpt2-small", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/itlrc/gpt2-small
- SGLang
How to use itlrc/gpt2-small 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 "itlrc/gpt2-small" \ --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": "itlrc/gpt2-small", "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 "itlrc/gpt2-small" \ --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": "itlrc/gpt2-small", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use itlrc/gpt2-small with Docker Model Runner:
docker model run hf.co/itlrc/gpt2-small
Download validation_report.json from itlrc/gpt2-small: direct link, hf CLI and curl.
- Browser
- Download file 518 Bytes
-
https://huggingface.co/itlrc/gpt2-small/resolve/main/validation_report.json
- Command line
-
hf download hf://itlrc/gpt2-small/validation_report.json
-
curl -L -o validation_report.json https://huggingface.co/itlrc/gpt2-small/resolve/main/validation_report.json
518 Bytes
| { | |
| "validated": true, | |
| "safetensors_sha256": "868d94679a6e0c46664ade35462570c49e35f1a220a6b3e048afdda7aa81eb75", | |
| "parameter_count": 124439808, | |
| "tensor_count_on_disk": 148, | |
| "tied_embeddings": true, | |
| "torch_version": "2.14.0+cpu", | |
| "transformers_version": "5.17.0", | |
| "validation_method": "AutoModelForCausalLM.from_pretrained with trust_remote_code=True", | |
| "sample_prompt": "Hi! I'm a", | |
| "sample_output": "Hi! I'm a little girl, but I did not know it. I was on the moon. I went back to work out how much" | |
| } | |