Instructions to use distilbert/distilgpt2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use distilbert/distilgpt2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="distilbert/distilgpt2")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("distilbert/distilgpt2") model = AutoModelForCausalLM.from_pretrained("distilbert/distilgpt2") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use distilbert/distilgpt2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "distilbert/distilgpt2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "distilbert/distilgpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/distilbert/distilgpt2
- SGLang
How to use distilbert/distilgpt2 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 "distilbert/distilgpt2" \ --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": "distilbert/distilgpt2", "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 "distilbert/distilgpt2" \ --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": "distilbert/distilgpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use distilbert/distilgpt2 with Docker Model Runner:
docker model run hf.co/distilbert/distilgpt2
DistilGpt-2 and generating descriptive summary of a strava activity
New to this area, wondering if it is possible to train distill-gpt2, using a training set with below entries (assuming diversification in activity types, statistics, and how the formation of output ). Have around 1800 such entries for training :
{"input": "Date: 2014-12-20 08:16:45+0:0, Timezone: (GMT+05:30) Asia/Kolkata, Athlete: Sammy, Gender: Male, Sport: Run, Activity: 10.13 km, Elapsed: 1.10 hrs, Moving: 1.09 hrs, Elevation Gain: 0.0 m, Kudos: 0, Avg Pace: 6.45 min/km, Max Pace: 4.27 min/km, Photos: 0", "output": "2014-12-20 08:16:45+0:0 saw Sammy went for a run with a distance of 10.13 km with 0.0 m meters of elevation gain. It took 1.10 hrs, including 1.09 hrs of moving time. They garnered 0 kudos. Maintaining an average pace of 6.45 min/km , their fastest pace was 4.27 min/km. No photos were taken during this activity"}
I am expecting that if I provide data such as the one in input, I see a response similar to "output".
However, I am seeing echo of the input as response that if I provide input in the above format.
Also, attached are the loss curves from training and evaluation.
Any suggestions would be appreciated.
