Tất cả bài viết
OCR
OCR
Computer Vision
Document AI
Tối ưu độ chính xác OCR cho chứng từ tiếng Việt
Infratek AI Team·Engineering8 tháng 1, 202510 phút đọc
Tối ưu độ chính xác OCR cho chứng từ tiếng Việt
OCR cho tiếng Việt có những thách thức riêng: dấu thanh, font đa dạng, chất lượng scan thấp, và layout phức tạp của chứng từ doanh nghiệp.
Thách thức đặc thù
- Dấu thanh: Các model train trên Latin script thường confuse "á" vs "à" vs "ả"
- Font đa dạng: Từ Times New Roman đến handwriting
- Chất lượng input: Scan nghiêng, mờ, stamp đè lên text
- Layout phức tạp: Tables, multi-column, stamps, signatures
Pipeline tối ưu
1. Preprocessing
import cv2
import numpy as np
def preprocess(image):
# Deskew
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
coords = np.column_stack(np.where(gray < 128))
angle = cv2.minAreaRect(coords)[-1]
# Denoise
denoised = cv2.fastNlMeansDenoising(gray)
# Adaptive threshold
binary = cv2.adaptiveThreshold(
denoised, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
cv2.THRESH_BINARY, 11, 2
)
return binary
2. Multi-engine approach
Không dựa vào một OCR engine duy nhất. Combine:
- PaddleOCR — mạnh với tiếng Việt
- EasyOCR — tốt với handwriting
- Azure Document Intelligence — mạnh với structured forms
- Custom fine-tuned model — cho document types đặc thù
3. Post-processing với LLM
Sử dụng LLM để correct OCR errors dựa trên context:
Nếu field "Tổng tiền" extract được "1O0.OOO VNĐ" — LLM hiểu đây phải là "100.000 VNĐ"
Kết quả thực tế
Trên dự án OCR cho financial services, pipeline này đạt:
- 98.2% field-level accuracy trên printed invoices
- 94.5% trên mixed printed + stamped documents
- 89% trên handwritten forms
Best practices
- Luôn có confidence score cho từng field
- Human-in-the-loop cho low-confidence extractions
- Continuous retraining từ correction data
- Validate với business rules (checksum, format, range)