Instructions to use minhduc168/Qwen3-VL-2B-Instruct-unsloth-bnb-4bit-Vietnamese-LoRA with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use minhduc168/Qwen3-VL-2B-Instruct-unsloth-bnb-4bit-Vietnamese-LoRA with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/Qwen3-VL-2B-Instruct-unsloth-bnb-4bit") model = PeftModel.from_pretrained(base_model, "minhduc168/Qwen3-VL-2B-Instruct-unsloth-bnb-4bit-Vietnamese-LoRA") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,210 +1,130 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
pipeline_tag: text-generation
|
| 5 |
tags:
|
| 6 |
-
-
|
|
|
|
|
|
|
| 7 |
- lora
|
| 8 |
-
-
|
| 9 |
-
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
-
#
|
| 15 |
|
| 16 |
-
|
|
|
|
| 17 |
|
|
|
|
| 18 |
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
- **Developed by:** [More Information Needed]
|
| 29 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 30 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 31 |
-
- **Model type:** [More Information Needed]
|
| 32 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 33 |
-
- **License:** [More Information Needed]
|
| 34 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 35 |
-
|
| 36 |
-
### Model Sources [optional]
|
| 37 |
-
|
| 38 |
-
<!-- Provide the basic links for the model. -->
|
| 39 |
-
|
| 40 |
-
- **Repository:** [More Information Needed]
|
| 41 |
-
- **Paper [optional]:** [More Information Needed]
|
| 42 |
-
- **Demo [optional]:** [More Information Needed]
|
| 43 |
-
|
| 44 |
-
## Uses
|
| 45 |
-
|
| 46 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 47 |
-
|
| 48 |
-
### Direct Use
|
| 49 |
-
|
| 50 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 51 |
-
|
| 52 |
-
[More Information Needed]
|
| 53 |
-
|
| 54 |
-
### Downstream Use [optional]
|
| 55 |
-
|
| 56 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 57 |
-
|
| 58 |
-
[More Information Needed]
|
| 59 |
-
|
| 60 |
-
### Out-of-Scope Use
|
| 61 |
-
|
| 62 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 63 |
-
|
| 64 |
-
[More Information Needed]
|
| 65 |
-
|
| 66 |
-
## Bias, Risks, and Limitations
|
| 67 |
-
|
| 68 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 69 |
-
|
| 70 |
-
[More Information Needed]
|
| 71 |
-
|
| 72 |
-
### Recommendations
|
| 73 |
-
|
| 74 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 75 |
-
|
| 76 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 77 |
-
|
| 78 |
-
## How to Get Started with the Model
|
| 79 |
-
|
| 80 |
-
Use the code below to get started with the model.
|
| 81 |
-
|
| 82 |
-
[More Information Needed]
|
| 83 |
-
|
| 84 |
-
## Training Details
|
| 85 |
-
|
| 86 |
-
### Training Data
|
| 87 |
-
|
| 88 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
### Training Procedure
|
| 93 |
-
|
| 94 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 95 |
-
|
| 96 |
-
#### Preprocessing [optional]
|
| 97 |
-
|
| 98 |
-
[More Information Needed]
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
#### Training Hyperparameters
|
| 102 |
-
|
| 103 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 104 |
-
|
| 105 |
-
#### Speeds, Sizes, Times [optional]
|
| 106 |
-
|
| 107 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 108 |
-
|
| 109 |
-
[More Information Needed]
|
| 110 |
-
|
| 111 |
-
## Evaluation
|
| 112 |
-
|
| 113 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 114 |
-
|
| 115 |
-
### Testing Data, Factors & Metrics
|
| 116 |
-
|
| 117 |
-
#### Testing Data
|
| 118 |
-
|
| 119 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 120 |
-
|
| 121 |
-
[More Information Needed]
|
| 122 |
-
|
| 123 |
-
#### Factors
|
| 124 |
-
|
| 125 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 126 |
-
|
| 127 |
-
[More Information Needed]
|
| 128 |
-
|
| 129 |
-
#### Metrics
|
| 130 |
-
|
| 131 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 132 |
-
|
| 133 |
-
[More Information Needed]
|
| 134 |
-
|
| 135 |
-
### Results
|
| 136 |
-
|
| 137 |
-
[More Information Needed]
|
| 138 |
-
|
| 139 |
-
#### Summary
|
| 140 |
-
|
| 141 |
|
|
|
|
| 142 |
|
| 143 |
-
##
|
| 144 |
|
| 145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
-
|
| 148 |
|
| 149 |
-
##
|
| 150 |
|
| 151 |
-
|
| 152 |
|
| 153 |
-
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
- **Cloud Provider:** [More Information Needed]
|
| 158 |
-
- **Compute Region:** [More Information Needed]
|
| 159 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 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 |
-
|
| 196 |
|
| 197 |
-
|
| 198 |
|
| 199 |
-
|
| 200 |
|
| 201 |
-
##
|
| 202 |
|
| 203 |
-
|
| 204 |
|
| 205 |
-
|
| 206 |
|
| 207 |
-
|
| 208 |
-
### Framework versions
|
| 209 |
|
| 210 |
-
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- vi
|
|
|
|
| 4 |
tags:
|
| 5 |
+
- vision-language
|
| 6 |
+
- qwen
|
| 7 |
+
- vlm
|
| 8 |
- lora
|
| 9 |
+
- adapter
|
| 10 |
+
- peft
|
| 11 |
+
license: apache-2.0
|
| 12 |
+
datasets:
|
| 13 |
+
- minhduc168/dataset-qwen-vlm-extract-bill
|
| 14 |
+
base_model:
|
| 15 |
+
- unsloth/Qwen3-VL-2B-Instruct-bnb-4bit
|
| 16 |
+
pipeline_tag: image-to-text
|
| 17 |
---
|
| 18 |
|
| 19 |
+
# Qwen3-VL-2B-Instruct Vietnamese (LoRA Adapter)
|
| 20 |
|
| 21 |
+
Đây là **LoRA Adapter** được fine-tune để **trích xuất thông tin từ hóa đơn, phiếu thu và đơn thuốc tiếng Việt**.
|
| 22 |
+
Adapter được huấn luyện dựa trên mô hình gốc **[unsloth/Qwen3-VL-2B-Instruct-bnb-4bit](https://huggingface.co/unsloth/Qwen3-VL-2B-Instruct-bnb-4bit)** nhằm tối ưu khả năng hiểu tài liệu và trả về dữ liệu có cấu trúc.
|
| 23 |
|
| 24 |
+
---
|
| 25 |
|
| 26 |
+
## 📌 Thông tin mô hình
|
| 27 |
|
| 28 |
+
- **Loại mô hình:** LoRA (Low-Rank Adaptation)
|
| 29 |
+
- **Pipeline:** Image-to-Text
|
| 30 |
+
- **Mục đích:** Trích xuất dữ liệu có cấu trúc (JSON) từ hình ảnh tài liệu y tế và tài chính.
|
| 31 |
+
- **Ngôn ngữ:** Tối ưu cho **tiếng Việt**
|
| 32 |
+
- **Dataset huấn luyện:** [minhduc168/dataset-qwen-vlm-extract-bill](https://huggingface.co/datasets/minhduc168/dataset-qwen-vlm-extract-bill)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
---
|
| 35 |
|
| 36 |
+
## 🚀 Ưu điểm của LoRA
|
| 37 |
|
| 38 |
+
- ✅ **Kích thước nhỏ** — chỉ vài trăm MB thay vì vài GB
|
| 39 |
+
- ✅ **Load nhanh**, giảm yêu cầu VRAM
|
| 40 |
+
- ✅ Không làm thay đổi trọng số base model
|
| 41 |
+
- ✅ Dễ dàng tiếp tục fine-tune trên dataset riêng
|
| 42 |
+
- ✅ Phù hợp cho production hoặc triển khai on-premise
|
| 43 |
|
| 44 |
+
---
|
| 45 |
|
| 46 |
+
## 🔧 Hướng dẫn sử dụng
|
| 47 |
|
| 48 |
+
Để sử dụng Adapter này, bạn cần tải **base model** trước, sau đó nạp LoRA bằng thư viện `peft`.
|
| 49 |
|
| 50 |
+
```python
|
| 51 |
+
from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
|
| 52 |
+
from peft import PeftModel
|
| 53 |
+
import torch
|
| 54 |
|
| 55 |
+
base_model_id = "unsloth/Qwen3-VL-2B-Instruct-bnb-4bit"
|
| 56 |
+
adapter_id = "minhduc168/Qwen3-VL-2B-Instruct-Vietnamese-LoRA"
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
+
# 1️⃣ Load base model
|
| 59 |
+
model = Qwen2VLForConditionalGeneration.from_pretrained(
|
| 60 |
+
base_model_id,
|
| 61 |
+
device_map="auto"
|
| 62 |
+
)
|
| 63 |
|
| 64 |
+
# 2️⃣ Load LoRA adapter
|
| 65 |
+
model = PeftModel.from_pretrained(model, adapter_id)
|
| 66 |
|
| 67 |
+
# 3️⃣ Load processor
|
| 68 |
+
processor = AutoProcessor.from_pretrained(base_model_id)
|
| 69 |
|
| 70 |
+
model.eval()
|
| 71 |
+
print("Model và LoRA adapter đã sẵn sàng!")
|
| 72 |
+
```
|
| 73 |
+
## ⚠️ Lưu ý quan trọng
|
| 74 |
|
| 75 |
+
- **Bắt buộc phải tải đúng Base Model** để adapter hoạt động.
|
| 76 |
|
| 77 |
+
### Cài đặt thư viện cần thiết:
|
| 78 |
+
```bash
|
| 79 |
+
pip install peft transformers bitsandbytes
|
| 80 |
+
```
|
| 81 |
+
## 📊 Dataset
|
| 82 |
|
| 83 |
+
Model được huấn luyện trên:**[minhduc168/dataset-qwen-vlm-extract-bill](https://huggingface.co/datasets/minhduc168/dataset-qwen-vlm-extract-bill)**
|
| 84 |
|
| 85 |
+
**Bao gồm:**
|
| 86 |
+
- Hóa đơn bán lẻ
|
| 87 |
+
- Phiếu thu
|
| 88 |
+
- Đơn thuốc
|
| 89 |
+
- Chứng từ tiếng Việt
|
| 90 |
|
| 91 |
+
Định dạng **instruction-following** giúp model tạo ra kết quả JSON chính xác và ổn định hơn.
|
| 92 |
|
| 93 |
+
---
|
| 94 |
|
| 95 |
+
## 🎯 Use Cases
|
| 96 |
|
| 97 |
+
- Trích xuất thông tin hóa đơn tự động
|
| 98 |
+
- Structured OCR
|
| 99 |
+
- Document AI tiếng Việt
|
| 100 |
+
- Medical / pharmacy bill parsing
|
| 101 |
+
- Fintech document processing
|
| 102 |
|
| 103 |
+
---
|
| 104 |
|
| 105 |
+
## 📌 Khi nào nên dùng LoRA này?
|
| 106 |
|
| 107 |
+
👉 **Khi bạn muốn:**
|
| 108 |
|
| 109 |
+
- Giảm chi phí GPU
|
| 110 |
+
- Tăng tốc inference
|
| 111 |
+
- Tùy chỉnh model theo domain tiếng Việt
|
| 112 |
+
- Triển khai linh hoạt mà không cần merge model
|
| 113 |
|
| 114 |
+
---
|
| 115 |
|
| 116 |
+
## 🔗 Phiên bản khác
|
| 117 |
|
| 118 |
+
Nếu bạn muốn sử dụng phiên bản **đã merge trọng số** hoặc **GGUF để chạy local**, tham khảo tại:[minhduc168/Qwen3-VL-2B-Instruct-Vietnamese](https://huggingface.co/minhduc168/Qwen3-VL-2B-Instruct-Vietnamese)
|
| 119 |
|
| 120 |
+
---
|
| 121 |
|
| 122 |
+
## License
|
| 123 |
|
| 124 |
+
Apache-2.0
|
| 125 |
|
| 126 |
+
---
|
| 127 |
|
| 128 |
+
## 💬 Liên hệ
|
|
|
|
| 129 |
|
| 130 |
+
Nếu có câu hỏi về dataset hoặc quá trình training, vui lòng mở **Discussion** tại repository này!
|