Update README.md
Browse files
README.md
CHANGED
|
@@ -1,4 +1,69 @@
|
|
| 1 |
---
|
| 2 |
base_model:
|
| 3 |
- mistralai/Mistral-Small-3.1-24B-Instruct-2503
|
| 4 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
base_model:
|
| 3 |
- mistralai/Mistral-Small-3.1-24B-Instruct-2503
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
## Evaluation
|
| 7 |
+
|
| 8 |
+
Server:
|
| 9 |
+
```
|
| 10 |
+
vllm serve nm-testing/Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic
|
| 11 |
+
```
|
| 12 |
+
|
| 13 |
+
Eval:
|
| 14 |
+
```
|
| 15 |
+
python -m eval.run eval_vllm --model_name nm-testing/Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic --url http://0.0.0.0:9000 --output_dir output/ --eval_name "chartqa"
|
| 16 |
+
Waiting for VLLM server to come online at http://0.0.0.0:9000/health ...
|
| 17 |
+
Timeout is 120s
|
| 18 |
+
Waiting for server (0s) ...
|
| 19 |
+
Server is up!
|
| 20 |
+
Loading lmms-lab/ChartQA [test]: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2500/2500 [00:11<00:00, 210.68it/s]
|
| 21 |
+
Querying model: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2500/2500 [06:53<00:00, 6.05it/s]
|
| 22 |
+
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2500/2500 [00:00<00:00, 22477.08it/s]
|
| 23 |
+
================================================================================
|
| 24 |
+
Metrics:
|
| 25 |
+
{
|
| 26 |
+
"explicit_prompt_relaxed_correctness": 0.8136,
|
| 27 |
+
"anywhere_in_answer_relaxed_correctness": 0.8144
|
| 28 |
+
}
|
| 29 |
+
================================================================================
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
## Creation
|
| 33 |
+
|
| 34 |
+
```python
|
| 35 |
+
from transformers import AutoProcessor, AutoModelForImageTextToText
|
| 36 |
+
|
| 37 |
+
from llmcompressor.modifiers.quantization import QuantizationModifier
|
| 38 |
+
from llmcompressor.transformers import oneshot
|
| 39 |
+
|
| 40 |
+
MODEL_ID = "mistralai/Mistral-Small-3.1-24B-Instruct-2503"
|
| 41 |
+
|
| 42 |
+
# Load model.
|
| 43 |
+
model = AutoModelForImageTextToText.from_pretrained(
|
| 44 |
+
MODEL_ID, device_map="auto", torch_dtype="auto"
|
| 45 |
+
)
|
| 46 |
+
processor = AutoProcessor.from_pretrained(MODEL_ID)
|
| 47 |
+
|
| 48 |
+
# Configure the quantization algorithm and scheme.
|
| 49 |
+
# In this case, we:
|
| 50 |
+
# * quantize the weights to fp8 with per channel via ptq
|
| 51 |
+
# * quantize the activations to fp8 with dynamic per token
|
| 52 |
+
recipe = QuantizationModifier(
|
| 53 |
+
targets="Linear",
|
| 54 |
+
scheme="FP8_DYNAMIC",
|
| 55 |
+
ignore=["re:.*lm_head", "re:multi_modal_projector.*", "re:vision_tower.*"],
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
# Apply quantization and save to disk in compressed-tensors format.
|
| 59 |
+
SAVE_DIR = MODEL_ID.split("/")[1] + "-FP8-dynamic"
|
| 60 |
+
oneshot(model=model, recipe=recipe, output_dir=SAVE_DIR)
|
| 61 |
+
processor.save_pretrained(SAVE_DIR)
|
| 62 |
+
|
| 63 |
+
# Confirm generations of the quantized model look sane.
|
| 64 |
+
print("========== SAMPLE GENERATION ==============")
|
| 65 |
+
input_ids = processor(text="Hello my name is", return_tensors="pt").input_ids.to("cuda")
|
| 66 |
+
output = model.generate(input_ids, max_new_tokens=20)
|
| 67 |
+
print(processor.decode(output[0]))
|
| 68 |
+
print("==========================================")
|
| 69 |
+
```
|