Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- multilingual
|
| 4 |
+
base_model:
|
| 5 |
+
- nanonets/Nanonets-OCR2-3B
|
| 6 |
+
tags:
|
| 7 |
+
- OCR
|
| 8 |
+
- image-to-text
|
| 9 |
+
- pdf2markdown
|
| 10 |
+
- VQA
|
| 11 |
+
pipeline_tag: image-text-to-text
|
| 12 |
+
library_name: transformers
|
| 13 |
+
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
Creation Code
|
| 17 |
+
|
| 18 |
+
```python
|
| 19 |
+
from transformers import AutoProcessor, Qwen2_5_VLForConditionalGeneration
|
| 20 |
+
|
| 21 |
+
from llmcompressor import oneshot
|
| 22 |
+
from llmcompressor.modifiers.quantization import QuantizationModifier
|
| 23 |
+
from llmcompressor.utils import dispatch_for_generation
|
| 24 |
+
|
| 25 |
+
MODEL_ID = "nanonets/Nanonets-OCR2-3B"
|
| 26 |
+
|
| 27 |
+
# Load model.
|
| 28 |
+
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(MODEL_ID, torch_dtype="auto")
|
| 29 |
+
processor = AutoProcessor.from_pretrained(MODEL_ID)
|
| 30 |
+
|
| 31 |
+
# Configure the quantization algorithm and scheme.
|
| 32 |
+
# In this case, we:
|
| 33 |
+
# * quantize the weights to fp8 with per channel via ptq
|
| 34 |
+
# * quantize the activations to fp8 with dynamic per token
|
| 35 |
+
recipe = QuantizationModifier(
|
| 36 |
+
targets="Linear",
|
| 37 |
+
scheme="FP8_DYNAMIC",
|
| 38 |
+
ignore=["lm_head", "re:visual.*", "re:model.visual.*"],
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
# Apply quantization and save to disk in compressed-tensors format.
|
| 42 |
+
oneshot(model=model, recipe=recipe)
|
| 43 |
+
|
| 44 |
+
```
|