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