Hot on the heels of the popular EraX-VL-7B-V1.0 model, we proudly present EraX-VL-2B-V1.5. This enhanced multimodal model offers robust OCR and VQA capabilities across diverse languages 🌍, with a significant advantage in processing Vietnamese 🇻🇳. The EraX-VL-2B model stands out for its precise recognition capabilities across a range of documents 📝, including medical forms 🩺, invoices 🧾, bills of sale 💳, quotes 📄, and medical records 💊. This functionality is expected to be highly beneficial for hospitals 🏥, clinics 💉, insurance companies 🛡️, and other similar applications 📋. Built on the solid foundation of the Qwen/Qwen2-VL-2B-Instruct[1], which we found to be of high quality and fluent in Vietnamese, EraX-VL-2B has been fine-tuned to enhance its performance. We plan to continue improving and releasing new versions for free, along with sharing performance benchmarks in the near future.
One standing-out feature of EraX-VL-2B-V1.5 is the capability to do multi-turn Q&A with reasonable reasoning capability at its small size of only +2 billions parameters.
NOTA BENE:
EraX-VL-2B-V1.5 is NOT a typical OCR-only tool likes Tesseract but is a Multimodal LLM-based model. To use it effectively, you may have to twist your prompt carefully depending on your tasks.
This model was NOT finetuned with medical (X-ray) dataset or car accidences (yet). Stay tune for updated version coming up sometime 2025.
EraX-VL-2B-V1.5 is a young and tiny member of our EraX's LànhGPT collection of LLM models.
{
"Số thẻ":"037094012351"
"Họ và tên":"TRỊNH QUANG DUY"
"Ngày sinh":"04/09/1994"
"Giới tính":"Nam"
"Quốc tịch":"Việt Nam"
"Quê quán / Place of origin":"Tân Thành, Kim Sơn, Ninh Bình"
"Nơi thường trú / Place of residence":"Xóm 6 Tân Thành, Kim Sơn, Ninh Bình"
"Có giá trị đến":"04/09/2034"
"Đặc điểm nhân dạng / Personal identification":"seo chấm c:1cm trên đuôi mắt trái"
"Cục trưởng cục cảnh sát quản lý hành chính về trật tự xã hội":"Nguyễn Quốc Hùng"
"Ngày cấp":"10/12/2022"
}
{
"No.":"400116012313"
"Fullname":"NGUYỄN VĂN DŨNG"
"Date_of_birth":"08/06/1979"
"Nationality":"VIỆT NAM"
"Address":"X. Quỳnh Hầu, H. Quỳnh Lưu, T. Nghệ An
Nghệ An, ngày/date 23 tháng/month 04 năm/year 2022"
"Hang_Class":"FC"
"Expires":"23/04/2027"
"Place_of_issue":"Nghệ An"
"Date_of_issue":"ngày/date 23 tháng/month 04 năm/year 2022"
"Signer":"Trần Anh Tuấn"
"Các loại xe được phép":"Ô tô hạng C kéo rơmoóc, đầu kéo kéo sơmi rơmoóc và xe hạng B1, B2, C, FB2 (Motor vehicle of class C with a trailer, semi-trailer truck and vehicles of classes B1, B2, C, FB2)"
"Mã số":""
}
1import os
2import base64
3import json
45import cv2
6import numpy as np
7import matplotlib.pyplot as plt
89import torch
10from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor
11from qwen_vl_utils import process_vision_info
1213model_path ="erax/EraX-VL-2B-V1.5"1415model = Qwen2VLForConditionalGeneration.from_pretrained(16 model_path,17 torch_dtype=torch.bfloat16,18 attn_implementation="eager",# replace with "flash_attention_2" if your GPU is Ampere architecture19 device_map="auto"20)2122tokenizer = AutoTokenizer.from_pretrained(model_path)23# processor = AutoProcessor.from_pretrained(model_path)2425min_pixels =256*28*2826max_pixels =1280*28*2827processor = AutoProcessor.from_pretrained(28 model_path,29 min_pixels=min_pixels,30 max_pixels=max_pixels,31)3233image_path ="image.jpg"3435withopen(image_path,"rb")as f:36 encoded_image = base64.b64encode(f.read())37decoded_image_text = encoded_image.decode('utf-8')38base64_data =f"data:image;base64,{decoded_image_text}"3940messages =[41{42"role":"user",43"content":[44{45"type":"image",46"image": base64_data,47},48{49"type":"text",50"text":"Trích xuất thông tin nội dung từ hình ảnh được cung cấp."51},52],53}54]5556# Prepare prompt57tokenized_text = processor.apply_chat_template(58 messages, tokenize=False, add_generation_prompt=True59)6061image_inputs, video_inputs = process_vision_info(messages)6263inputs = processor(64 text=[ tokenized_text],65 images=image_inputs,66 videos=video_inputs,67 padding=True,68 return_tensors="pt",69)70inputs = inputs.to("cuda")7172# Generation configs73generation_config = model.generation_config
74generation_config.do_sample =True75generation_config.temperature =1.076generation_config.top_k =177generation_config.top_p =0.978generation_config.min_p =0.179generation_config.best_of =580generation_config.max_new_tokens =204881generation_config.repetition_penalty =1.068283# Inference84generated_ids = model.generate(**inputs, generation_config=generation_config)85generated_ids_trimmed =[86 out_ids[len(in_ids):]for in_ids, out_ids inzip(inputs.input_ids, generated_ids)87]88output_text = processor.batch_decode(89 generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False90)9192print(output_text[0])
References 📑
[1] Qwen team. Qwen2-VL. 2024.
[2] Bai, Jinze, et al. "Qwen-VL: A Versatile Vision-Language Model for Understanding, Localization, Text Reading, and Beyond." arXiv preprint arXiv:2308.12966 (2023).
[4] Yang, An, et al. "Qwen2 technical report." arXiv preprint arXiv:2407.10671 (2024).
[5] Chen, Zhe, et al. "Internvl: Scaling up vision foundation models and aligning for generic visual-linguistic tasks." Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2024.
[6] Chen, Zhe, et al. "How far are we to gpt-4v? closing the gap to commercial multimodal models with open-source suites." arXiv preprint arXiv:2404.16821 (2024).
[7] Tran, Chi, and Huong Le Thanh. "LaVy: Vietnamese Multimodal Large Language Model." arXiv preprint arXiv:2404.07922 (2024).
Contact 🤝
For correspondence regarding this work or inquiry for API trial, please contact Nguyễn Anh Nguyên at nguyen@erax.ai.