Update README.md
Browse files
README.md
CHANGED
|
@@ -108,32 +108,41 @@ The [GPTQ](https://arxiv.org/abs/2210.17323) algorithm is applied for quantizati
|
|
| 108 |
|
| 109 |
## Deployment
|
| 110 |
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
```python
|
| 114 |
-
from
|
| 115 |
-
from transformers import AutoProcessor
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
|
|
|
| 119 |
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
| 122 |
|
| 123 |
-
|
| 124 |
|
| 125 |
-
prompts = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
|
| 126 |
|
| 127 |
-
|
|
|
|
|
|
|
| 128 |
|
| 129 |
-
outputs =
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
-
generated_text = outputs
|
| 132 |
print(generated_text)
|
| 133 |
```
|
| 134 |
|
| 135 |
-
vLLM also supports OpenAI-compatible serving. See the [documentation](https://docs.vllm.ai/en/latest/) for more details.
|
| 136 |
-
|
| 137 |
<details>
|
| 138 |
<summary>Deploy on <strong>Red Hat AI Inference Server</strong></summary>
|
| 139 |
|
|
|
|
| 108 |
|
| 109 |
## Deployment
|
| 110 |
|
| 111 |
+
1. Initialize vLLM server:
|
| 112 |
+
```
|
| 113 |
+
vllm serve RedHatAI/Mistral-Small-3.1-24B-Instruct-2503-quantized.w4a16 --tensor_parallel_size 1 --tokenizer_mode mistral
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
2. Send requests to the server:
|
| 117 |
|
| 118 |
```python
|
| 119 |
+
from openai import OpenAI
|
|
|
|
| 120 |
|
| 121 |
+
# Modify OpenAI's API key and API base to use vLLM's API server.
|
| 122 |
+
openai_api_key = "EMPTY"
|
| 123 |
+
openai_api_base = "http://<your-server-host>:8000/v1"
|
| 124 |
|
| 125 |
+
client = OpenAI(
|
| 126 |
+
api_key=openai_api_key,
|
| 127 |
+
base_url=openai_api_base,
|
| 128 |
+
)
|
| 129 |
|
| 130 |
+
model = "RedHatAI/Mistral-Small-3.1-24B-Instruct-2503-quantized.w4a16"
|
| 131 |
|
|
|
|
| 132 |
|
| 133 |
+
messages = [
|
| 134 |
+
{"role": "user", "content": "Explain quantum mechanics clearly and concisely."},
|
| 135 |
+
]
|
| 136 |
|
| 137 |
+
outputs = client.chat.completions.create(
|
| 138 |
+
model=model,
|
| 139 |
+
messages=messages,
|
| 140 |
+
)
|
| 141 |
|
| 142 |
+
generated_text = outputs.choices[0].message.content
|
| 143 |
print(generated_text)
|
| 144 |
```
|
| 145 |
|
|
|
|
|
|
|
| 146 |
<details>
|
| 147 |
<summary>Deploy on <strong>Red Hat AI Inference Server</strong></summary>
|
| 148 |
|