alexmarques commited on
Commit
495d817
·
verified ·
1 Parent(s): f1dedd8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +23 -14
README.md CHANGED
@@ -110,32 +110,41 @@ A combination of the [SmoothQuant](https://arxiv.org/abs/2211.10438) and [GPTQ](
110
 
111
  ## Deployment
112
 
113
- This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend, as shown in the example below.
 
 
 
 
 
114
 
115
  ```python
116
- from vllm import LLM, SamplingParams
117
- from transformers import AutoProcessor
118
 
119
- model_id = "RedHatAI/Mistral-Small-3.1-24B-Instruct-2503-quantized.w8a8"
120
- number_gpus = 1
 
121
 
122
- sampling_params = SamplingParams(temperature=0.7, top_p=0.8, max_tokens=256)
123
- processor = AutoProcessor.from_pretrained(model_id)
 
 
124
 
125
- messages = [{"role": "user", "content": "Give me a short introduction to large language model."}]
126
 
127
- prompts = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
128
 
129
- llm = LLM(model=model_id, tensor_parallel_size=number_gpus)
 
 
130
 
131
- outputs = llm.generate(prompts, sampling_params)
 
 
 
132
 
133
- generated_text = outputs[0].outputs[0].text
134
  print(generated_text)
135
  ```
136
 
137
- vLLM aslo supports OpenAI-compatible serving. See the [documentation](https://docs.vllm.ai/en/latest/) for more details.
138
-
139
  <details>
140
  <summary>Deploy on <strong>Red Hat AI Inference Server</strong></summary>
141
 
 
110
 
111
  ## Deployment
112
 
113
+ 1. Initialize vLLM server:
114
+ ```
115
+ vllm serve RedHatAI/Mistral-Small-3.1-24B-Instruct-2503-quantized.w4a16 --tensor_parallel_size 1 --tokenizer_mode mistral
116
+ ```
117
+
118
+ 2. Send requests to the server:
119
 
120
  ```python
121
+ from openai import OpenAI
 
122
 
123
+ # Modify OpenAI's API key and API base to use vLLM's API server.
124
+ openai_api_key = "EMPTY"
125
+ openai_api_base = "http://<your-server-host>:8000/v1"
126
 
127
+ client = OpenAI(
128
+ api_key=openai_api_key,
129
+ base_url=openai_api_base,
130
+ )
131
 
132
+ model = "RedHatAI/Mistral-Small-3.1-24B-Instruct-2503-quantized.w4a16"
133
 
 
134
 
135
+ messages = [
136
+ {"role": "user", "content": "Explain quantum mechanics clearly and concisely."},
137
+ ]
138
 
139
+ outputs = client.chat.completions.create(
140
+ model=model,
141
+ messages=messages,
142
+ )
143
 
144
+ generated_text = outputs.choices[0].message.content
145
  print(generated_text)
146
  ```
147
 
 
 
148
  <details>
149
  <summary>Deploy on <strong>Red Hat AI Inference Server</strong></summary>
150