Instructions to use echarlaix/distilgpt2-openvino with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use echarlaix/distilgpt2-openvino with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="echarlaix/distilgpt2-openvino")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("echarlaix/distilgpt2-openvino") model = AutoModelForCausalLM.from_pretrained("echarlaix/distilgpt2-openvino", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use echarlaix/distilgpt2-openvino with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "echarlaix/distilgpt2-openvino" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "echarlaix/distilgpt2-openvino", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/echarlaix/distilgpt2-openvino
- SGLang
How to use echarlaix/distilgpt2-openvino 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 "echarlaix/distilgpt2-openvino" \ --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": "echarlaix/distilgpt2-openvino", "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 "echarlaix/distilgpt2-openvino" \ --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": "echarlaix/distilgpt2-openvino", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use echarlaix/distilgpt2-openvino with Docker Model Runner:
docker model run hf.co/echarlaix/distilgpt2-openvino
| base_model: distilbert/distilgpt2 | |
| datasets: | |
| - openwebtext | |
| language: en | |
| license: apache-2.0 | |
| tags: | |
| - exbert | |
| - openvino | |
| - openvino-export | |
| co2_eq_emissions: 149200 | |
| model-index: | |
| - name: distilgpt2 | |
| results: | |
| - task: | |
| type: text-generation | |
| name: Text Generation | |
| dataset: | |
| name: WikiText-103 | |
| type: wikitext | |
| metrics: | |
| - type: perplexity | |
| value: 21.1 | |
| name: Perplexity | |
| This model was converted to OpenVINO from [`distilbert/distilgpt2`](https://huggingface.co/distilbert/distilgpt2) using [optimum-intel](https://github.com/huggingface/optimum-intel) | |
| via the [export](https://huggingface.co/spaces/echarlaix/openvino-export) space. | |
| First make sure you have optimum-intel installed: | |
| ```bash | |
| pip install optimum[openvino] | |
| ``` | |
| To load your model you can do as follows: | |
| ```python | |
| from optimum.intel import OVModelForCausalLM | |
| model_id = "echarlaix/distilgpt2-openvino" | |
| model = OVModelForCausalLM.from_pretrained(model_id) | |
| ``` | |