Update README.md
Browse files
README.md
CHANGED
|
@@ -8,15 +8,104 @@ tags:
|
|
| 8 |
- trl
|
| 9 |
license: apache-2.0
|
| 10 |
language:
|
| 11 |
-
-
|
| 12 |
---
|
| 13 |
|
| 14 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
- **Developed by:** oddadmix
|
| 17 |
-
- **License:** apache-2.0
|
| 18 |
-
- **Finetuned from model :** unsloth/qwen2-vl-2b-instruct-unsloth-bnb-4bit
|
| 19 |
|
| 20 |
-
This qwen2_vl model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
| 21 |
|
| 22 |
-
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
|
| 8 |
- trl
|
| 9 |
license: apache-2.0
|
| 10 |
language:
|
| 11 |
+
- ar
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# Qwen2 VL - Arabic OCR Fine-Tuned Model
|
| 15 |
+
|
| 16 |
+
## Model Overview
|
| 17 |
+
This model is a fine-tuned version of [Qwen2 VL](https://huggingface.co/Qwen/Qwen2-VL) on an Arabic OCR dataset. It is optimized to perform Arabic Optical Character Recognition (OCR) for full-page text.
|
| 18 |
+
|
| 19 |
+
## Model Details
|
| 20 |
+
- **Base Model**: Qwen2 VL
|
| 21 |
+
- **Fine-tuning Dataset**: Arabic OCR dataset
|
| 22 |
+
- **Objective**: Extract full-page Arabic text with high accuracy
|
| 23 |
+
- **Languages**: Arabic
|
| 24 |
+
- **Tasks**: OCR (Optical Character Recognition)
|
| 25 |
+
|
| 26 |
+
## Evaluation Results
|
| 27 |
+
|
| 28 |
+
The fine-tuned model outperforms the base model significantly in terms of Character Error Rate (CER), Word Error Rate (WER), and BLEU score.
|
| 29 |
+
|
| 30 |
+
### Fine-Tuned Model Performance
|
| 31 |
+
- **Word Error Rate (WER)**: `0.0675`
|
| 32 |
+
- **Character Error Rate (CER)**: `0.0193`
|
| 33 |
+
- **BLEU Score**:
|
| 34 |
+
- BLEU: `0.8596`
|
| 35 |
+
- Precision @1: `93.95%`
|
| 36 |
+
- Precision @2: `88.55%`
|
| 37 |
+
- Precision @3: `83.82%`
|
| 38 |
+
- Precision @4: `79.52%`
|
| 39 |
+
|
| 40 |
+
### Base Model Performance
|
| 41 |
+
- **Word Error Rate (WER)**: `1.3435`
|
| 42 |
+
- **Character Error Rate (CER)**: `1.1915`
|
| 43 |
+
- **BLEU Score**:
|
| 44 |
+
- BLEU: `0.2007`
|
| 45 |
+
- Precision @1: `26.85%`
|
| 46 |
+
- Precision @2: `21.65%`
|
| 47 |
+
- Precision @3: `18.13%`
|
| 48 |
+
- Precision @4: `15.39%`
|
| 49 |
+
|
| 50 |
+
## Performance Comparison Charts
|
| 51 |
+
|
| 52 |
+
### WER & CER Comparison
|
| 53 |
+
```python
|
| 54 |
+
import matplotlib.pyplot as plt
|
| 55 |
+
|
| 56 |
+
categories = ["WER", "CER"]
|
| 57 |
+
base_values = [1.3435, 1.1915]
|
| 58 |
+
fine_tuned_values = [0.0675, 0.0193]
|
| 59 |
+
|
| 60 |
+
x = range(len(categories))
|
| 61 |
+
plt.bar(x, base_values, width=0.4, label="Base Model", color='r', align='center')
|
| 62 |
+
plt.bar(x, fine_tuned_values, width=0.4, label="Fine-Tuned Model", color='g', align='edge')
|
| 63 |
+
|
| 64 |
+
plt.xticks(x, categories)
|
| 65 |
+
plt.ylabel("Error Rate")
|
| 66 |
+
plt.title("WER & CER Comparison")
|
| 67 |
+
plt.legend()
|
| 68 |
+
plt.show()
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
### BLEU Score Comparison
|
| 72 |
+
```python
|
| 73 |
+
categories = ["BLEU", "Precision @1", "Precision @2", "Precision @3", "Precision @4"]
|
| 74 |
+
base_bleu = [0.2007, 26.85, 21.65, 18.13, 15.39]
|
| 75 |
+
fine_tuned_bleu = [0.8596, 93.95, 88.55, 83.82, 79.52]
|
| 76 |
+
|
| 77 |
+
x = range(len(categories))
|
| 78 |
+
plt.bar(x, base_bleu, width=0.4, label="Base Model", color='r', align='center')
|
| 79 |
+
plt.bar(x, fine_tuned_bleu, width=0.4, label="Fine-Tuned Model", color='g', align='edge')
|
| 80 |
+
|
| 81 |
+
plt.xticks(x, categories)
|
| 82 |
+
plt.ylabel("Score (%)")
|
| 83 |
+
plt.title("BLEU Score & Precision Comparison")
|
| 84 |
+
plt.legend()
|
| 85 |
+
plt.show()
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
## How to Use
|
| 89 |
+
You can load this model using the `transformers` library:
|
| 90 |
+
|
| 91 |
+
```python
|
| 92 |
+
from transformers import AutoModel, AutoProcessor
|
| 93 |
+
import torch
|
| 94 |
+
|
| 95 |
+
model_name = "your-model-name"
|
| 96 |
+
model = AutoModel.from_pretrained(model_name)
|
| 97 |
+
processor = AutoProcessor.from_pretrained(model_name)
|
| 98 |
+
|
| 99 |
+
image = "path/to/your/image.jpg"
|
| 100 |
+
inputs = processor(images=image, return_tensors="pt")
|
| 101 |
+
outputs = model(**inputs)
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
## License
|
| 105 |
+
This model follows the licensing terms of the original Qwen2 VL model. Please review the terms before using it commercially.
|
| 106 |
+
|
| 107 |
+
## Citation
|
| 108 |
+
If you use this model in your research or application, please cite it appropriately.
|
| 109 |
|
|
|
|
|
|
|
|
|
|
| 110 |
|
|
|
|
| 111 |
|
|
|