Revert README.md to pre-March-3 version (undo broken template changes)
Browse files
README.md
CHANGED
|
@@ -1,400 +1,280 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
base_model:
|
| 3 |
- openai/whisper-large-v3
|
| 4 |
base_model_relation: quantized
|
| 5 |
-
pipeline_tag:
|
| 6 |
language:
|
| 7 |
- en
|
| 8 |
-
-
|
| 9 |
- de
|
| 10 |
- es
|
| 11 |
-
- it
|
| 12 |
-
- pt
|
| 13 |
-
- nl
|
| 14 |
- ru
|
| 15 |
-
- zh
|
| 16 |
-
- ja
|
| 17 |
- ko
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
---
|
| 19 |
|
| 20 |
-
# Elastic model:
|
| 21 |
-
|
| 22 |
-
## Overview
|
| 23 |
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
| 29 |
-
- **L**: Near lossless model, with less than 1% degradation obtained on corresponding benchmarks.
|
| 30 |
-
- **M**: Faster model, with accuracy degradation less than 1.5%.
|
| 31 |
-
- **S**: The fastest model, with accuracy degradation less than 2%.
|
| 32 |
|
| 33 |
-
|
| 34 |
|
| 35 |
-
|
| 36 |
|
| 37 |
-
|
| 38 |
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
|
| 42 |
-
| --- | --- |
|
| 43 |
-
| **GPU** | H100, L40s, B200, RTX 5090, RTX 4090 |
|
| 44 |
-
| **Python Version** | 3.10-3.12 |
|
| 45 |
-
| **CPU** | Intel/AMD x86_64 |
|
| 46 |
-
| **CUDA Version** | 12.9+ |
|
| 47 |
|
| 48 |
|
| 49 |
-
##
|
| 50 |
|
| 51 |
-
|
| 52 |
|
| 53 |
-
|
| 54 |
-
pip install thestage
|
| 55 |
-
thestage config set --api-token <YOUR_ACCESS_TOKEN>
|
| 56 |
-
```
|
| 57 |
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
-
|
| 61 |
|
| 62 |
-
``
|
| 63 |
-
pip install 'thestage-elastic-models[nvidia,cudnn]' \
|
| 64 |
-
--extra-index-url https://thestage.jfrog.io/artifactory/api/pypi/pypi-thestage-ai-production/simple
|
| 65 |
-
pip install --force-reinstall --no-deps nvidia-cudnn-frontend==1.18.0
|
| 66 |
-
```
|
| 67 |
-
|
| 68 |
-
If you want to run on Nvidia Blackwell architecture, you need to install package as follows:
|
| 69 |
-
|
| 70 |
-
```bash
|
| 71 |
-
pip install 'thestage-elastic-models[blackwell,cudnn]' \
|
| 72 |
-
--extra-index-url https://thestage.jfrog.io/artifactory/api/pypi/pypi-thestage-ai-production/simple
|
| 73 |
-
pip install -U --pre torch \
|
| 74 |
-
--index-url https://download.pytorch.org/whl/nightly/cu128
|
| 75 |
-
pip install -U --pre torchvision \
|
| 76 |
-
--index-url https://download.pytorch.org/whl/nightly/cu128
|
| 77 |
-
pip install --force-reinstall --no-deps nvidia-cudnn-frontend==1.18.0
|
| 78 |
-
```
|
| 79 |
-
|
| 80 |
-
## Usage example
|
| 81 |
-
|
| 82 |
-
----
|
| 83 |
-
|
| 84 |
-
Elastic Models provides the same interface as HuggingFace Diffusers. Here is an example of how to use the whisper-large-v3 model:
|
| 85 |
|
| 86 |
```python
|
| 87 |
import torch
|
| 88 |
-
|
| 89 |
-
from
|
|
|
|
|
|
|
| 90 |
|
| 91 |
-
# Currently we require to have your HF token
|
| 92 |
-
# as we use original weights for part of layers and
|
| 93 |
-
# model configuration as well
|
| 94 |
model_name = "openai/whisper-large-v3"
|
| 95 |
-
|
| 96 |
-
device = torch.device("cuda")
|
| 97 |
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
| 103 |
model_name,
|
| 104 |
token=hf_token,
|
| 105 |
-
torch_dtype=torch.
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
)
|
| 109 |
-
model.
|
| 110 |
-
|
| 111 |
-
#
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
{
|
| 119 |
-
"role": "user",
|
| 120 |
-
"content": prompt
|
| 121 |
-
}
|
| 122 |
-
]
|
| 123 |
-
|
| 124 |
-
chat_prompt = tokenizer.apply_chat_template(
|
| 125 |
-
messages, add_generation_prompt=True, tokenize=False
|
| 126 |
)
|
| 127 |
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
with torch.inference_mode():
|
| 132 |
-
generate_ids = model.generate(**inputs, max_length=500)
|
| 133 |
-
|
| 134 |
-
input_len = inputs['input_ids'].shape[1]
|
| 135 |
-
generate_ids = generate_ids[:, input_len:]
|
| 136 |
-
output = tokenizer.batch_decode(
|
| 137 |
-
generate_ids,
|
| 138 |
-
skip_special_tokens=True,
|
| 139 |
-
clean_up_tokenization_spaces=False
|
| 140 |
-
)[0]
|
| 141 |
-
|
| 142 |
-
# Validate answer
|
| 143 |
-
print(f"# Q:\n{prompt}\n")
|
| 144 |
-
print(f"# A:\n{output}\n")
|
| 145 |
-
```
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
## Quality Benchmarks
|
| 149 |
-
|
| 150 |
-
------------
|
| 151 |
-
|
| 152 |
-
We have used the `lm_eval` library to validate the models. For each model size (S, M, L, XL), we have run the following tasks: MMLU, PIQA, Arc Challenge, Windogrande.
|
| 153 |
-
|
| 154 |
-
![Quality Benchmarking]()
|
| 155 |
-
|
| 156 |
-
### Quality Benchmark Results
|
| 157 |
-
|
| 158 |
-
| **Metric/Model Size**| **S**| **M**| **L**| **XL**| **Original** |
|
| 159 |
-
| --- | --- | --- | --- | --- | --- |
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
## Datasets
|
| 163 |
-
|
| 164 |
-
-------
|
| 165 |
-
|
| 166 |
-
- **MMLU**: Measures model performance on a diverse set of multiple-choice questions covering various academic subjects, testing general knowledge and reasoning.
|
| 167 |
-
- **PIQA**: Evaluates physical commonsense reasoning by asking the model to choose the most plausible solution to everyday physical problems.
|
| 168 |
-
- **Arc Challenge**: Assesses scientific and factual reasoning using challenging multiple-choice questions from the AI2 Reasoning Challenge dataset.
|
| 169 |
-
- **Winogrande**: Tests commonsense understanding and pronoun resolution through sentences requiring the model to identify the correct referent.
|
| 170 |
-
|
| 171 |
-
## Metrics
|
| 172 |
-
|
| 173 |
-
----------
|
| 174 |
-
|
| 175 |
-
- **Accuracy**: Accuracy measures the proportion of model predictions that exactly match the correct answers across evaluation tasks.
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
## Latency Benchmarks
|
| 179 |
-
|
| 180 |
-
-----
|
| 181 |
-
|
| 182 |
-
We measured TPS (tokens per second) for each model size using 100 input tokens and 300 output tokens.
|
| 183 |
-
|
| 184 |
-
![Latency Benchmarking]()
|
| 185 |
-
|
| 186 |
-
### Latency Benchmark Results
|
| 187 |
-
|
| 188 |
-
Tokens per second for different model sizes on various GPUs.
|
| 189 |
-
|
| 190 |
-
| **GPU/Model Size**| **S**| **M**| **L**| **XL**| **Original** |
|
| 191 |
-
| --- | --- | --- | --- | --- | --- |
|
| 192 |
-
| **H100** | 224 | N/A | N/A | 236 | N/A |
|
| 193 |
-
| **L40s** | 202 | N/A | N/A | 187 | 56 |
|
| 194 |
-
| **B200** | 199 | N/A | N/A | N/A | N/A |
|
| 195 |
-
| **GeForce RTX 4090** | 249 | N/A | N/A | N/A | 53 |
|
| 196 |
-
| **GeForce RTX 3090** | 201 | N/A | N/A | N/A | N/A |
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
## Benchmarking Methodology
|
| 200 |
-
|
| 201 |
-
----
|
| 202 |
-
|
| 203 |
-
The benchmarking was performed on a single GPU with a batch size of 1. Each model was run for 10 iterations, and the average latency was calculated.
|
| 204 |
-
|
| 205 |
-
> **Algorithm summary:**
|
| 206 |
-
> 1. Load the whisper-large-v3 model with the specified size (S, M, L, XL, original).
|
| 207 |
-
> 2. Move the model to the GPU.
|
| 208 |
-
> 3. Prepare a sample prompt for image generation.
|
| 209 |
-
> 4. Run the model for a number of iterations (e.g., 10) and measure the time taken for each iteration. On each iteration:
|
| 210 |
-
> - Synchronize the GPU to flush any previous operations.
|
| 211 |
-
> - Record the start time.
|
| 212 |
-
> - Generate the text using the model.
|
| 213 |
-
> - Synchronize the GPU again.
|
| 214 |
-
> - Record the end time and calculate the TTFT and TPS for that iteration.
|
| 215 |
-
> 5. Calculate the average TTFT and TPS over all iterations.
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
## Serving with Docker Image
|
| 219 |
-
|
| 220 |
-
------------
|
| 221 |
-
|
| 222 |
-
For serving with Nvidia GPUs, we provide ready-to-go Docker containers with OpenAI-compatible API endpoints.
|
| 223 |
-
Using our containers you can set up an inference endpoint on any desired cloud/serverless providers as well as on-premise servers.
|
| 224 |
-
You can also use this container to run inference through TheStage AI platform.
|
| 225 |
-
|
| 226 |
-
### Prebuilt image from ECR
|
| 227 |
-
|
| 228 |
-
| **GPU** | **Docker image name** |
|
| 229 |
-
| --- | --- |
|
| 230 |
-
| H100, L40s | `public.ecr.aws/i3f7g5s7/thestage/elastic-models:0.1.7.post0-llm-nvidia-24.09b` |
|
| 231 |
-
| B200, RTX 5090 | `public.ecr.aws/i3f7g5s7/thestage/elastic-models:0.1.7.post0-llm-blackwell-24.09b` |
|
| 232 |
-
|
| 233 |
-
Pull docker image for your Nvidia GPU and start inference container:
|
| 234 |
-
|
| 235 |
-
```bash
|
| 236 |
-
docker pull <IMAGE_NAME>
|
| 237 |
-
```
|
| 238 |
-
```bash
|
| 239 |
-
docker run --rm -ti \
|
| 240 |
-
--name serving_thestage_model \
|
| 241 |
-
-p 8000:80 \
|
| 242 |
-
-e AUTH_TOKEN=<AUTH_TOKEN> \
|
| 243 |
-
-e MODEL_REPO=openai/whisper-large-v3 \
|
| 244 |
-
-e MODEL_SIZE=<MODEL_SIZE> \
|
| 245 |
-
-e MODEL_BATCH=<MAX_BATCH_SIZE> \
|
| 246 |
-
-e HUGGINGFACE_ACCESS_TOKEN=<HUGGINGFACE_ACCESS_TOKEN> \
|
| 247 |
-
-e THESTAGE_AUTH_TOKEN=<THESTAGE_ACCESS_TOKEN> \
|
| 248 |
-
-v /mnt/hf_cache:/root/.cache/huggingface \
|
| 249 |
-
<IMAGE_NAME_DEPNDING_ON_YOUR_GPU>
|
| 250 |
-
```
|
| 251 |
-
|
| 252 |
-
| **Parameter** | **Description** |
|
| 253 |
-
|----------------------------|------------------------------------------------------------------------------------------------------|
|
| 254 |
-
| `<MODEL_SIZE>` | Available: S, M, L, XL. |
|
| 255 |
-
| `<MAX_BATCH_SIZE>` | Maximum batch size to process in parallel. |
|
| 256 |
-
| `<HUGGINGFACE_ACCESS_TOKEN>` | Hugging Face access token. |
|
| 257 |
-
| `<THESTAGE_ACCESS_TOKEN>` | TheStage token generated on the platform (Profile -> Access tokens). |
|
| 258 |
-
| `<AUTH_TOKEN>` | Token for endpoint authentication. You can set it to any random string; it must match the value used by the client. |
|
| 259 |
-
| `<IMAGE_NAME>` | Image name which you have pulled. |
|
| 260 |
-
|
| 261 |
-
## Invocation
|
| 262 |
-
|
| 263 |
-
------
|
| 264 |
-
|
| 265 |
-
You can invoke the endpoint using CURL as follows:
|
| 266 |
-
|
| 267 |
-
```bash
|
| 268 |
-
curl -X POST 'http://127.0.0.1:8000/v1/chat/completions' \
|
| 269 |
-
-H 'Authorization: Bearer 123' \
|
| 270 |
-
-H 'Content-Type: application/json' \
|
| 271 |
-
-H "X-Model-Name: whisper-large-v3-<MODEL_SIZE>-bs<MAX_BATCH_SIZE>-paged" \
|
| 272 |
-
-d '{
|
| 273 |
-
"messages":[{"role":"user","content":"Define AI"}]
|
| 274 |
-
}'
|
| 275 |
-
```
|
| 276 |
-
|
| 277 |
-
Or using OpenAI python client:
|
| 278 |
|
| 279 |
-
|
| 280 |
-
import os, base64, pathlib, json
|
| 281 |
-
from openai import OpenAI
|
| 282 |
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
|
|
|
|
|
|
| 286 |
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
default_headers={"X-Model-Name": MODEL}
|
| 291 |
)
|
| 292 |
|
| 293 |
-
|
| 294 |
-
model=MODEL,
|
| 295 |
-
messages=[
|
| 296 |
-
{"role": "user", "content": "Define AI"}
|
| 297 |
-
]
|
| 298 |
-
)
|
| 299 |
|
| 300 |
-
print(
|
| 301 |
```
|
| 302 |
|
| 303 |
-
|
|
|
|
|
|
|
|
|
|
| 304 |
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
### Method
|
| 308 |
-
|
| 309 |
-
> **POST** `/v1/chat/completions`
|
| 310 |
-
|
| 311 |
-
### Header Parameters
|
| 312 |
-
|
| 313 |
-
> `Authorization`: `string`
|
| 314 |
-
>
|
| 315 |
-
> Bearer token for authentication. Should match the `AUTH_TOKEN` set during container startup.
|
| 316 |
-
|
| 317 |
-
> `Content-Type`: `string`
|
| 318 |
-
>
|
| 319 |
-
> Must be set to `application/json`.
|
| 320 |
-
|
| 321 |
-
> `X-Model-Name`: `string`
|
| 322 |
-
>
|
| 323 |
-
> Specifies the model to use for generation. Format: `whisper-large-v3-<size>-bs<batch_size>`, where `<size>` is one of `S`, `M`, `L`, `XL`, `original` and `<batch_size>` is the maximum batch size configured during container startup.
|
| 324 |
-
|
| 325 |
-
### Input Body
|
| 326 |
-
|
| 327 |
-
> `messages` : `string`
|
| 328 |
-
>
|
| 329 |
-
> The input text prompt.
|
| 330 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
|
| 332 |
-
|
| 333 |
|
| 334 |
-
|
|
|
|
|
|
|
| 335 |
|
| 336 |
-
|
| 337 |
|
| 338 |
-
|
| 339 |
|
| 340 |
-
|
| 341 |
-
git clone https://github.com/TheStageAI/ElasticModels.git
|
| 342 |
-
cd ElasticModels/examples/modal
|
| 343 |
-
```
|
| 344 |
|
| 345 |
-
|
| 346 |
|
| 347 |
-
|
| 348 |
|
| 349 |
-
|
| 350 |
-
# modal_serving.py
|
| 351 |
-
|
| 352 |
-
ENVS = {
|
| 353 |
-
"MODEL_REPO": "openai/whisper-large-v3",
|
| 354 |
-
"MODEL_BATCH": "4",
|
| 355 |
-
"THESTAGE_AUTH_TOKEN": "",
|
| 356 |
-
"HUGGINGFACE_ACCESS_TOKEN": "",
|
| 357 |
-
"PORT": "80",
|
| 358 |
-
"PORT_HEALTH": "80",
|
| 359 |
-
"HF_HOME": "/cache/huggingface",
|
| 360 |
-
}
|
| 361 |
-
```
|
| 362 |
|
| 363 |
-
|
|
|
|
|
|
|
| 364 |
|
| 365 |
-
|
|
|
|
| 366 |
|
| 367 |
-
|
| 368 |
-
# modal_serving.py
|
| 369 |
-
|
| 370 |
-
@app.function(
|
| 371 |
-
image=image,
|
| 372 |
-
gpu="B200",
|
| 373 |
-
min_containers=8,
|
| 374 |
-
max_containers=8,
|
| 375 |
-
timeout=10000,
|
| 376 |
-
ephemeral_disk=600 * 1024,
|
| 377 |
-
volumes={"/opt/project/.cache": HF_CACHE},
|
| 378 |
-
startup_timeout=60*20
|
| 379 |
-
)
|
| 380 |
-
@modal.web_server(
|
| 381 |
-
80,
|
| 382 |
-
label="openai/whisper-large-v3-test",
|
| 383 |
-
startup_timeout=60*20
|
| 384 |
-
)
|
| 385 |
-
def serve():
|
| 386 |
-
pass
|
| 387 |
-
```
|
| 388 |
|
| 389 |
-
|
| 390 |
|
| 391 |
-
|
| 392 |
-
modal serve modal_serving.py
|
| 393 |
-
```
|
| 394 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 395 |
|
| 396 |
## Links
|
| 397 |
|
| 398 |
* __Platform__: [app.thestage.ai](https://app.thestage.ai)
|
| 399 |
-
* __Subscribe for updates__: [TheStageAI X](https://x.com/TheStageAI)
|
| 400 |
-
* __Contact email__: contact@thestage.ai
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
base_model:
|
| 4 |
- openai/whisper-large-v3
|
| 5 |
base_model_relation: quantized
|
| 6 |
+
pipeline_tag: automatic-speech-recognition
|
| 7 |
language:
|
| 8 |
- en
|
| 9 |
+
- zh
|
| 10 |
- de
|
| 11 |
- es
|
|
|
|
|
|
|
|
|
|
| 12 |
- ru
|
|
|
|
|
|
|
| 13 |
- ko
|
| 14 |
+
- fr
|
| 15 |
+
- ja
|
| 16 |
+
- pt
|
| 17 |
+
- tr
|
| 18 |
+
- pl
|
| 19 |
+
- ca
|
| 20 |
+
- nl
|
| 21 |
+
- ar
|
| 22 |
+
- sv
|
| 23 |
+
- it
|
| 24 |
+
- id
|
| 25 |
+
- hi
|
| 26 |
+
- fi
|
| 27 |
+
- vi
|
| 28 |
+
- he
|
| 29 |
+
- uk
|
| 30 |
+
- el
|
| 31 |
+
- ms
|
| 32 |
+
- cs
|
| 33 |
+
- ro
|
| 34 |
+
- da
|
| 35 |
+
- hu
|
| 36 |
+
- ta
|
| 37 |
+
- no
|
| 38 |
+
- th
|
| 39 |
+
- ur
|
| 40 |
+
- hr
|
| 41 |
+
- bg
|
| 42 |
+
- lt
|
| 43 |
+
- la
|
| 44 |
+
- mi
|
| 45 |
+
- ml
|
| 46 |
+
- cy
|
| 47 |
+
- sk
|
| 48 |
+
- te
|
| 49 |
+
- fa
|
| 50 |
+
- lv
|
| 51 |
+
- bn
|
| 52 |
+
- sr
|
| 53 |
+
- az
|
| 54 |
+
- sl
|
| 55 |
+
- kn
|
| 56 |
+
- et
|
| 57 |
+
- mk
|
| 58 |
+
- br
|
| 59 |
+
- eu
|
| 60 |
+
- is
|
| 61 |
+
- hy
|
| 62 |
+
- ne
|
| 63 |
+
- mn
|
| 64 |
+
- bs
|
| 65 |
+
- kk
|
| 66 |
+
- sq
|
| 67 |
+
- sw
|
| 68 |
+
- gl
|
| 69 |
+
- mr
|
| 70 |
+
- pa
|
| 71 |
+
- si
|
| 72 |
+
- km
|
| 73 |
+
- sn
|
| 74 |
+
- yo
|
| 75 |
+
- so
|
| 76 |
+
- af
|
| 77 |
+
- oc
|
| 78 |
+
- ka
|
| 79 |
+
- be
|
| 80 |
+
- tg
|
| 81 |
+
- sd
|
| 82 |
+
- gu
|
| 83 |
+
- am
|
| 84 |
+
- yi
|
| 85 |
+
- lo
|
| 86 |
+
- uz
|
| 87 |
+
- fo
|
| 88 |
+
- ht
|
| 89 |
+
- ps
|
| 90 |
+
- tk
|
| 91 |
+
- nn
|
| 92 |
+
- mt
|
| 93 |
+
- sa
|
| 94 |
+
- lb
|
| 95 |
+
- my
|
| 96 |
+
- bo
|
| 97 |
+
- tl
|
| 98 |
+
- mg
|
| 99 |
+
- as
|
| 100 |
+
- tt
|
| 101 |
+
- haw
|
| 102 |
+
- ln
|
| 103 |
+
- ha
|
| 104 |
+
- ba
|
| 105 |
+
- jw
|
| 106 |
+
- su
|
| 107 |
+
- yue
|
| 108 |
+
tags:
|
| 109 |
+
- audio
|
| 110 |
+
- automatic-speech-recognition
|
| 111 |
+
- speech-recognition
|
| 112 |
+
- whisper
|
| 113 |
+
- annthem
|
| 114 |
+
- qlip
|
| 115 |
+
- thestage
|
| 116 |
---
|
| 117 |
|
| 118 |
+
# Elastic model: Whisper Large v3. Fastest and most flexible models for self-serving.
|
|
|
|
|
|
|
| 119 |
|
| 120 |
+
Elastic models are the models produced by TheStage AI ANNA: Automated Neural Networks Accelerator. ANNA allows you to control model size, latency and quality with a simple slider movement. For each model, ANNA produces a series of optimized models:
|
| 121 |
|
| 122 |
+
* __XL__: Mathematically equivalent neural network, optimized with our DNN compiler.
|
| 123 |
|
| 124 |
+
* __L__: Near lossless model, with less than 1% degradation obtained on corresponding benchmarks.
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
+
* __M__: Faster model, with accuracy degradation less than 1.5%.
|
| 127 |
|
| 128 |
+
* __S__: The fastest model, with accuracy degradation less than 2%.
|
| 129 |
|
| 130 |
+
__Goals of elastic models:__
|
| 131 |
|
| 132 |
+
* Provide flexibility in cost vs quality selection for inference
|
| 133 |
+
* Provide clear quality and latency benchmarks for speech recognition
|
| 134 |
+
* Provide interface of HF libraries: `transformers` and `elastic_models` with a single line of code change for using optimized versions
|
| 135 |
+
* Provide models supported on a wide range of hardware (NVIDIA GPUs), which are pre-compiled and require no JIT
|
| 136 |
+
* Provide the best models and service for self-hosting
|
| 137 |
|
| 138 |
+
> It's important to note that we have consolidated all elastic model versions into a single optimized S model that provides the best balance of speed and quality for Whisper Large v3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
|
| 141 |
+
## Audio Examples
|
| 142 |
|
| 143 |
+
Below are examples demonstrating the transcription quality of the Elastic Whisper Large v3 S model compared to the original.
|
| 144 |
|
| 145 |
+
**Example Audio Transcriptions:**
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
+
| Audio Sample | Original Whisper Large v3 | Elastic S Model |
|
| 148 |
+
|---|---|---|
|
| 149 |
+
| <audio controls src="https://cdn-uploads.huggingface.co/production/uploads/6799fc8e150f5a4014b030ca/io62uN1l-tpqigMlzQMlm.mpga"></audio> | joel keaton disapproved of films and buster also had reservations about the medium | joel keaton disapproved of films and buster also had reservations about the medium |
|
| 150 |
+
| <audio controls src="https://cdn-uploads.huggingface.co/production/uploads/6799fc8e150f5a4014b030ca/CVabXfIP_Q5qxIjzoy5N6.mpga"></audio> | she ll be alright | she ll be alright |
|
| 151 |
+
| <audio controls src="https://cdn-uploads.huggingface.co/production/uploads/6799fc8e150f5a4014b030ca/-fidVnQcCa32c7-2rNz-w.mpga"></audio> | all is well that ends well | all is well that ends well |
|
| 152 |
+
## Inference
|
| 153 |
|
| 154 |
+
To infer our Whisper models, you primarily use the `elastic_models.transformers.WhisperForConditionalGeneration` class.
|
| 155 |
|
| 156 |
+
**Example using `elastic_models` with the optimized model:**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
|
| 158 |
```python
|
| 159 |
import torch
|
| 160 |
+
import librosa # check that you have this package installed
|
| 161 |
+
from transformers import AutoProcessor
|
| 162 |
+
from transformers.pipelines import pipeline
|
| 163 |
+
from elastic_models.transformers import WhisperForConditionalGeneration
|
| 164 |
|
|
|
|
|
|
|
|
|
|
| 165 |
model_name = "openai/whisper-large-v3"
|
| 166 |
+
mode = "S"
|
|
|
|
| 167 |
|
| 168 |
+
audio_path = "path_to_your_audio.wav"
|
| 169 |
+
hf_token = "YOUR_TOKEN"
|
| 170 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 171 |
+
|
| 172 |
+
# Load processor and model
|
| 173 |
+
processor = AutoProcessor.from_pretrained(model_name, token=hf_token)
|
| 174 |
+
|
| 175 |
+
model = WhisperForConditionalGeneration.from_pretrained(
|
| 176 |
model_name,
|
| 177 |
token=hf_token,
|
| 178 |
+
torch_dtype=torch.float16,
|
| 179 |
+
mode=mode,
|
| 180 |
+
device_map=device,
|
| 181 |
+
)
|
| 182 |
+
model.eval()
|
| 183 |
+
|
| 184 |
+
# Create pipeline
|
| 185 |
+
generator = pipeline(
|
| 186 |
+
task="automatic-speech-recognition",
|
| 187 |
+
model=model,
|
| 188 |
+
tokenizer=processor.tokenizer,
|
| 189 |
+
feature_extractor=processor.feature_extractor,
|
| 190 |
+
device=device,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
)
|
| 192 |
|
| 193 |
+
# Load audio
|
| 194 |
+
audio, sr = librosa.load(audio_path, sr=16000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
|
| 196 |
+
print(f"Transcribing audio from: {audio_path}")
|
|
|
|
|
|
|
| 197 |
|
| 198 |
+
# Generate transcription using pipeline
|
| 199 |
+
generate_kwargs = {
|
| 200 |
+
"max_new_tokens": 100,
|
| 201 |
+
"num_beams": 1,
|
| 202 |
+
}
|
| 203 |
|
| 204 |
+
result = generator(
|
| 205 |
+
audio,
|
| 206 |
+
generate_kwargs=generate_kwargs,
|
|
|
|
| 207 |
)
|
| 208 |
|
| 209 |
+
transcription = result["text"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
|
| 211 |
+
print(f"Transcription: {transcription}")
|
| 212 |
```
|
| 213 |
|
| 214 |
+
__System requirements:__
|
| 215 |
+
* GPUs: NVIDIA GeForce 4090, NVIDIA GeForce 5090, H100, L40S
|
| 216 |
+
* CPU: AMD, Intel
|
| 217 |
+
* Python: 3.8-3.12 (check dependencies for specific versions)
|
| 218 |
|
| 219 |
+
To work with our elastic models and compilation tools, you'll need to install `elastic_models` and `qlip` libraries from TheStage:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
|
| 221 |
+
```shell
|
| 222 |
+
pip install thestage
|
| 223 |
+
pip install 'thestage-elastic-models[nvidia]' --extra-index-url https://thestage.jfrog.io/artifactory/api/pypi/pypi-thestage-ai-production/simple
|
| 224 |
+
pip install flash-attn==2.7.3 --no-build-isolation
|
| 225 |
+
pip install tensorrt==10.11.0.33 # for 4090
|
| 226 |
+
pip uninstall apex
|
| 227 |
+
|
| 228 |
+
# or for blackwell support
|
| 229 |
+
pip install 'thestage-elastic-models[blackwell]' --extra-index-url https://thestage.jfrog.io/artifactory/api/pypi/pypi-thestage-ai-production/simple
|
| 230 |
+
pip install torch==2.7.0+cu128 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
|
| 231 |
+
# please download the appropriate version of Wheels for your system from https://github.com/Zarrac/flashattention-blackwell-wheels-whl-ONLY-5090-5080-5070-5060-flash-attention-/releases/tag/FlashAttention
|
| 232 |
+
mv flash_attn-2.7.4.post1-rtx5090-torch2.7.0cu128cxx11abiTRUE-cp311-linux_x86_64.whl flash_attn-2.7.4.post1-0rtx5090torch270cu128cxx11abiTRUE-cp311-cp311-linux_x86_64.whl
|
| 233 |
+
pip install flash_attn-2.7.4.post1-0rtx5090torch270cu128cxx11abiTRUE-cp311-cp311-linux_x86_64.whl
|
| 234 |
+
pip install tensorrt==10.11.0.33
|
| 235 |
+
pip uninstall apex
|
| 236 |
+
```
|
| 237 |
|
| 238 |
+
Then go to [app.thestage.ai](https://app.thestage.ai), login and generate API token from your profile page. Set up API token as follows:
|
| 239 |
|
| 240 |
+
```shell
|
| 241 |
+
thestage config set --api-token <YOUR_API_TOKEN>
|
| 242 |
+
```
|
| 243 |
|
| 244 |
+
Congrats, now you can use accelerated models and tools!
|
| 245 |
|
| 246 |
+
----
|
| 247 |
|
| 248 |
+
## Benchmarks
|
|
|
|
|
|
|
|
|
|
| 249 |
|
| 250 |
+
Benchmarking is one of the most important procedures during model acceleration. We aim to provide clear performance metrics for Whisper models using our algorithms.
|
| 251 |
|
| 252 |
+
### Quality benchmarks
|
| 253 |
|
| 254 |
+
Performance evaluation on standard speech recognition benchmarks:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
|
| 256 |
+
| Metric/Model | S | Original |
|
| 257 |
+
|--------------|---|----------|
|
| 258 |
+
| WER (Common Voice) | 0.18 | 0.22 |
|
| 259 |
|
| 260 |
+
* **WER (Word Error Rate)**: The primary metric for evaluating speech recognition accuracy. Lower is better.
|
| 261 |
+
* **Common Voice**: Multilingual speech recognition benchmark covering diverse languages and accents.
|
| 262 |
|
| 263 |
+
### Latency benchmarks (tps)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
|
| 265 |
+
Performance for transcribing audio (tps):
|
| 266 |
|
| 267 |
+
**Batch Size 1:**
|
|
|
|
|
|
|
| 268 |
|
| 269 |
+
| GPU Type | S | Original |
|
| 270 |
+
|----------|---|----------|
|
| 271 |
+
| H100 | 223.47 | 82.84 |
|
| 272 |
+
| L40S | 194.36 | 51.92 |
|
| 273 |
+
| GeForce RTX 4090 | 225.65 | 52.39 |
|
| 274 |
+
| GeForce RTX 5090 | 229.69 | 54.44 |
|
| 275 |
|
| 276 |
## Links
|
| 277 |
|
| 278 |
* __Platform__: [app.thestage.ai](https://app.thestage.ai)
|
| 279 |
+
* __Subscribe for updates__: [TheStageAI X (Twitter)](https://x.com/TheStageAI)
|
| 280 |
+
* __Contact email__: contact@thestage.ai
|