Abstract
TaCo (Textual Attribute Contrastive learning) is a novel framework designed for fine-grained textual attribute recognition (TAR), identifying features such as font, color, and style in document images. By leveraging a specialized masking module and a quality-control scoring system within a contrastive learning paradigm, TaCo overcomes the limitations of traditional supervised methods in handling subtle stylistic differences and real-world noise. Experimental results demonstrate that TaCo sets a new state-of-the-art in font recognition and significantly enhances downstream document understanding tasks.
Introduction
While Optical Character Recognition (OCR) has matured significantly, focusing on the semantic content of text, Textual Attribute Recognition (TAR) remains a challenging frontier. TAR aims to identify how text is presented—its font, color, and styles such as bold or italic. This task is complicated by the subtle differences between typefaces and the degradation common in real-world document scans, such as blur and lighting variations.
Traditional supervised models often struggle with the open-ended nature of font styles and the noise inherent in "in-the-wild" data. TaCo addresses these challenges by employing a contrastive learning approach, teaching the model to identify the underlying stylistic "signature" of text regardless of its semantic meaning or environmental noise.
The TaCo Framework
TaCo is built upon the SimSiam contrastive learning architecture, enhanced with three key innovations designed specifically for textual data:
- Custom Pretext Tasks: To ensure the model focuses on visual style rather than semantics, TaCo uses random character reordering alongside standard augmentations like cropping and color jittering. This prevents the model from "cheating" by recognizing words.
- Masked Attributes Enhancement Module (MAEM): This module forces the model to focus on local, fine-grained details. By randomly masking patches of the feature map, the model must learn to identify attributes from specific character fragments (e.g., the serif of a 'd' or the slant of an 'f') rather than the global word shape.
- Paired-view Scoring Module (PSM): Recognizing that not all augmented pairs are equally informative, the PSM automatically evaluates and weights training samples. It prioritizes high-quality, moderately challenging pairs over noisy or uninformative "junk" data, leading to more stable pre-training.
Experimental Setup and Results
To evaluate TaCo, the authors developed two new datasets: SynAttr, a synthetic dataset of 1 million images with over 1,000 fonts, and Attr-5k, a benchmark of 5,000 real-world images manually cropped from diverse document scenes.
TaCo achieves state-of-the-art performance across multiple metrics:
- Accuracy: On the Attr-5k real-world dataset, TaCo reached 94.28% accuracy in font recognition, significantly outperforming ResNet-50 (86.71%) and specialized models like DeepFont (88.07%).
- Ablation Studies: The inclusion of the MAEM module alone provided a 2.98% gain in F1-score, confirming the importance of local feature enhancement for TAR.
- Downstream Utility: Integrating TaCo's attribute features into Entity Recognition tasks improved precision by 1.49%, demonstrating that stylistic information is a vital cue for understanding document structure.
Conclusion
TaCo demonstrates that contrastive learning, when tailored with text-specific modules like MAEM and PSM, is highly effective for fine-grained attribute recognition. By prioritizing local features over global word shapes, the model avoids the "ambiguity trap" of traditional classification. While currently focused on English and Chinese, future work will expand language support and explore more complex artistic styles. Despite the high computational cost of pre-training, the resulting model provides a robust and efficient solution for real-world document understanding.
Summary updated