alexmarques commited on
Commit
b535166
·
verified ·
1 Parent(s): ea19fc1

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +23 -14
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
- This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend, as shown in the example below.
 
 
 
 
 
112
 
113
  ```python
114
- from vllm import LLM, SamplingParams
115
- from transformers import AutoProcessor
116
 
117
- model_id = "RedHatAI/Mistral-Small-3.1-24B-Instruct-2503-quantized.w4a16"
118
- number_gpus = 1
 
119
 
120
- sampling_params = SamplingParams(temperature=0.7, top_p=0.8, max_tokens=256)
121
- processor = AutoProcessor.from_pretrained(model_id)
 
 
122
 
123
- messages = [{"role": "user", "content": "Give me a short introduction to large language model."}]
124
 
125
- prompts = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
126
 
127
- llm = LLM(model=model_id, tensor_parallel_size=number_gpus)
 
 
128
 
129
- outputs = llm.generate(prompts, sampling_params)
 
 
 
130
 
131
- generated_text = outputs[0].outputs[0].text
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