File size: 4,713 Bytes
7e3d817 fbcc921 7e3d817 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
---
license: apache-2.0
pipeline_tag: text-generation
library_name: transformers
tags:
- multilingual
- compliant
- swiss-ai
- apertus
- fp8
- vllm
- compressed-tensors
- llm-compressor
base_model:
- swiss-ai/Apertus-70B-Instruct-2509
---
## Model Overview
- **Model Architecture:** ApertusForCausalLM
- **Input:** Text
- **Output:** Text
- **Model Optimizations:**
- **Weight quantization:** INT4
- **Release Date:** 9/22/2025
- **Version:** 1.0
- **Model Developers:** Red Hat
Quantized version of [swiss-ai/Apertus-70B-2509](https://huggingface.co/swiss-ai/Apertus-70B-2509).
### Model Optimizations
This model was obtained by quantizing the weights and activations of [swiss-ai/Apertus-70B-2509](https://huggingface.co/swiss-ai/Apertus-70B-2509) to FP8 data type.
This optimization reduces the number of bits per parameter from 16 to 8, reducing the disk size and GPU memory requirements by approximately 50%.
Only the weights and activations of the linear operators within transformers blocks are quantized.
## Deployment
### Use with vLLM
1. Initialize vLLM server:
```
vllm serve RedHatAI/Apertus-70B-Instruct-2509-quantized.w4a16
```
2. Send requests to the server:
```python
from openai import OpenAI
# Modify OpenAI's API key and API base to use vLLM's API server.
openai_api_key = "EMPTY"
openai_api_base = "http://<your-server-host>:8000/v1"
client = OpenAI(
api_key=openai_api_key,
base_url=openai_api_base,
)
model = "RedHatAI/Apertus-70B-Instruct-2509-quantized.w4a16"
messages = [
{"role": "user", "content": "Give me a short introduction to large language model."},
]
outputs = client.chat.completions.create(
model=model,
messages=messages,
)
generated_text = outputs.choices[0].message.content
print(generated_text)
```
## Creation
This model was created with [llm-compressor](https://github.com/vllm-project/llm-compressor) by running the code snippet below.
<details>
<summary>Model Creation Code</summary>
```python
from llmcompressor.modifiers.quantization import QuantizationModifier
from llmcompressor.transformers import oneshot
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load model
model_stub = "swiss-ai/Apertus-70B-Instruct-2509"
model_name = model_stub.split("/")[-1]
model = AutoModelForCausalLM.from_pretrained(model_stub, dtype="auto")
tokenizer = AutoTokenizer.from_pretrained(model_stub)
# Configure the quantization algorithm and scheme
recipe = QuantizationModifier(
ignore=["lm_head"],
targets="Linear",
scheme="FP8_dynamic",
)
# Apply quantization
oneshot(
model=model,
recipe=recipe,
)
# Save to disk in compressed-tensors format
save_path = model_name + "-quantized.w4a16"
model.save_pretrained(save_path)
tokenizer.save_pretrained(save_path)
print(f"Model and tokenizer saved to: {save_path}")
```
</details>
## Evaluation
The model was evaluated on OpenLLM Leaderboard [V1](https://huggingface.co/spaces/open-llm-leaderboard-old/open_llm_leaderboard), using the following command:
<details>
<summary>Evaluation Commands</summary>
OpenLLM Leaderboard V1:
```
lm_eval \
--model vllm \
--model_args pretrained="RedHatAI/Apertus-70B-Instruct-2509-quantized.w4a16",dtype=auto,add_bos_token=True,max_model_len=4096,tensor_parallel_size=2,gpu_memory_utilization=0.2,enable_chunked_prefill=True \
--tasks openllm \
--write_out \
--batch_size auto \
--output_path output_dir \
--show_config
```
</details>
### Accuracy
<table>
<thead>
<tr>
<th>Category</th>
<th>Metric</th>
<th>swiss-ai/Apertus-70B-Instruct-2509</th>
<th>RedHatAI/Apertus-70B-Instruct-2509-quantized.w4a16</th>
<th>Recovery (%)</th>
</tr>
</thead>
<tbody>
<!-- OpenLLM Leaderboard V1 -->
<tr>
<td rowspan="7"><b>OpenLLM V1</b></td>
<td>ARC-Challenge (Acc-Norm, 25-shot)</td>
<td>70.82</td>
<td>70.65</td>
<td>99.8</td>
</tr>
<tr>
<td>GSM8K (Strict-Match, 5-shot)</td>
<td>73.69</td>
<td>73.45</td>
<td>99.7</td>
</tr>
<tr>
<td>HellaSwag (Acc-Norm, 10-shot)</td>
<td>86.23</td>
<td>85.67</td>
<td>99.4</td>
</tr>
<tr>
<td>MMLU (Acc, 5-shot)</td>
<td>69.21</td>
<td>68.25</td>
<td>98.6</td>
</tr>
<tr>
<td>TruthfulQA (MC2, 0-shot)</td>
<td>60.31</td>
<td>60.55</td>
<td>100.4</td>
</tr>
<tr>
<td>Winogrande (Acc, 5-shot)</td>
<td>80.74</td>
<td>80.03</td>
<td>99.1</td>
</tr>
<tr>
<td><b>Average Score</b></td>
<td><b>73.50</b></td>
<td><b>73.10</b></td>
<td><b>99.5</b></td>
</tr>
</tbody>
</table>
|