Image-to-Text
Transformers
Safetensors
Vietnamese
paddleocr_vl
image-text-to-text
paddleocr-vl
merged
ocr
vietnamese
custom_code
Instructions to use tieubaoca/PaddleOCR-VL-1.6-Vietnamese-Merged with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tieubaoca/PaddleOCR-VL-1.6-Vietnamese-Merged with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "image-to-text" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("image-to-text", model="tieubaoca/PaddleOCR-VL-1.6-Vietnamese-Merged", trust_remote_code=True)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("tieubaoca/PaddleOCR-VL-1.6-Vietnamese-Merged", trust_remote_code=True) model = AutoModelForMultimodalLM.from_pretrained("tieubaoca/PaddleOCR-VL-1.6-Vietnamese-Merged", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
PaddleOCR-VL-1.6 Vietnamese Merged
Full BF16 model produced by merging the Vietnamese LoRA adapter into PaddlePaddle/PaddleOCR-VL-1.6. This repository is standalone; the LoRA adapter is not required at inference time.
Use the exact user prompt OCR: and preserve the included native multimodal chat template.
Loading and inference
The verified environment used Python 3.12, PyTorch 2.11.0+cu128, Transformers 4.55.4, and a CUDA GPU.
import os
os.environ.setdefault("CUBLAS_WORKSPACE_CONFIG", ":4096:8")
import torch
from PIL import Image
from transformers import AutoModelForCausalLM, AutoProcessor
model_id = "tieubaoca/PaddleOCR-VL-1.6-Vietnamese-Merged"
processor = AutoProcessor.from_pretrained(
model_id,
trust_remote_code=True,
use_fast=False,
)
model = AutoModelForCausalLM.from_pretrained(
model_id,
trust_remote_code=True,
torch_dtype=torch.bfloat16,
attn_implementation="eager",
).to("cuda").eval()
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": "document.png"},
{"type": "text", "text": "OCR:"},
],
}
]
prompt = processor.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
with Image.open("document.png") as source:
image = source.convert("RGB").copy()
inputs = processor(text=[prompt], images=[image], return_tensors="pt")
inputs = {name: value.to("cuda") for name, value in inputs.items()}
prompt_length = inputs["input_ids"].shape[1]
with torch.inference_mode():
generated_ids = model.generate(
**inputs,
do_sample=False,
num_beams=1,
max_new_tokens=256,
use_cache=True,
)
text = processor.batch_decode(
generated_ids[:, prompt_length:],
skip_special_tokens=True,
clean_up_tokenization_spaces=False,
)[0].strip()
print(text)
Evaluation
Deterministic greedy decoding with the native processor and chat template, 32 fixed validation samples from each of five sources, and 256 maximum new tokens.
| Model | Samples | CER | Exact match | Normalized edit distance |
|---|---|---|---|---|
| PaddleOCR-VL-1.6 base | 160 | 0.234065 | 0.137500 | 0.755668 |
| Vietnamese merged model | 160 | 0.066029 | 0.512500 | 0.941240 |
Merged per-source metrics:
| Source | Samples | CER | Exact match | Normalized edit distance |
|---|---|---|---|---|
| source-000 | 32 | 0.091364 | 0.062500 | 0.910921 |
| source-001 | 32 | 0.096000 | 0.781250 | 0.910813 |
| source-002 | 32 | 0.070355 | 0.312500 | 0.932029 |
| source-003 | 32 | 0.044308 | 0.718750 | 0.964717 |
| source-004 | 32 | 0.015504 | 0.687500 | 0.987720 |
Merge verification
- All 126 LoRA-targeted tensors were merged.
- The exported weights matched the in-memory merged model after BF16 output casting within
rtol=0.0005andatol=0.0005. - Exported and in-memory merged logits were identical on the verification fixture (
max_abs_error=0.0, equal argmax).
The original PaddleOCR-VL-1.6 license is included as LICENSE.
- Downloads last month
- 10
Model tree for tieubaoca/PaddleOCR-VL-1.6-Vietnamese-Merged
Base model
PaddlePaddle/PaddleOCR-VL-1.6