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
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: distilbert/distilgpt2
|
| 3 |
+
datasets:
|
| 4 |
+
- openwebtext
|
| 5 |
+
language: en
|
| 6 |
+
license: apache-2.0
|
| 7 |
+
tags:
|
| 8 |
+
- exbert
|
| 9 |
+
- openvino
|
| 10 |
+
co2_eq_emissions: 149200
|
| 11 |
+
model-index:
|
| 12 |
+
- name: distilgpt2
|
| 13 |
+
results:
|
| 14 |
+
- task:
|
| 15 |
+
type: text-generation
|
| 16 |
+
name: Text Generation
|
| 17 |
+
dataset:
|
| 18 |
+
name: WikiText-103
|
| 19 |
+
type: wikitext
|
| 20 |
+
metrics:
|
| 21 |
+
- type: perplexity
|
| 22 |
+
value: 21.1
|
| 23 |
+
name: Perplexity
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
This model was converted to OpenVINO from [`distilbert/distilgpt2`](https://huggingface.co/distilbert/distilgpt2) using [optimum-intel](https://github.com/huggingface/optimum-intel)
|
| 27 |
+
via the [export](https://huggingface.co/spaces/echarlaix/openvino-export) space.
|
| 28 |
+
|
| 29 |
+
First make sure you have optimum-intel installed:
|
| 30 |
+
|
| 31 |
+
```bash
|
| 32 |
+
pip install optimum[openvino]
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
To load your model you can do as follows:
|
| 36 |
+
|
| 37 |
+
```python
|
| 38 |
+
from optimum.intel import OVModelForCausalLM
|
| 39 |
+
|
| 40 |
+
model_id = "echarlaix/distilgpt2-openvino"
|
| 41 |
+
model = OVModelForCausalLM.from_pretrained(model_id)
|
| 42 |
+
```
|