[Paper Review] End-to-End Attention-based Image Captioning
This paper proposes an end-to-end vision transformer (ViT)-based model for molecular image captioning, replacing traditional CNN+RNN encoders with a pure transformer architecture to improve performance on noisy or low-feature molecular images. The model achieves a 6.95 average Levenshtein distance on InChI generation, outperforming ResNet+LSTM baselines by 15% in edit distance reduction.
In this paper, we address the problem of image captioning specifically for molecular translation where the result would be a predicted chemical notation in InChI format for a given molecular structure. Current approaches mainly follow rule-based or CNN+RNN based methodology. However, they seem to underperform on noisy images and images with small number of distinguishable features. To overcome this, we propose an end-to-end transformer model. When compared to attention-based techniques, our proposed model outperforms on molecular datasets.
Motivation & Objective
- To address the limitations of rule-based and CNN+RNN models in generating accurate InChI notations from noisy or low-feature molecular images.
- To improve molecular translation performance by leveraging the self-attention mechanism of transformers for better long-range and local feature modeling.
- To develop a simple, end-to-end trainable model that avoids handcrafted feature extraction and reduces dependency on domain-specific rules.
- To evaluate the effectiveness of vision transformers in molecular structure recognition and InChI generation, particularly on real-world, imperfect images from scientific publications.
Proposed method
- Replace the CNN encoder in standard image captioning pipelines with a vision transformer (ViT) to extract patch-based image representations without convolutional inductive biases.
- Use a standard transformer decoder with autoregressive decoding to generate InChI strings token-by-token, conditioned on the image features.
- Implement a caching mechanism to store and reuse encoder outputs and decoded token embeddings across decoding steps, reducing redundant computation.
- Optimize inference speed by segregating encoder and decoder modules, enabling single computation of encoder output and reuse during autoregressive generation.
- Apply layer-wise caching of hidden states instead of attention matrices to reduce time complexity from O(N³) to O(MN + N²) per decoding step.
- Train the model end-to-end using cross-entropy loss on a dataset combining Bristol-Myers Squibb, GDB-13, and augmented molecular images.
Experimental results
Research questions
- RQ1Can a pure transformer-based encoder-decoder model outperform CNN+RNN models in generating InChI notations from molecular structure images?
- RQ2How does the ViT encoder’s ability to capture long-range dependencies improve performance on noisy or low-feature molecular images?
- RQ3To what extent do architectural optimizations like output caching and module segregation reduce inference time without sacrificing accuracy?
- RQ4Does increasing input resolution (e.g., 384×384) and patch size (16×16) improve model performance, and how does this affect sequence length constraints?
Key findings
- The ViT-based model achieved a mean Levenshtein distance of 6.95 on InChI generation, representing a 15% improvement over the best-performing ResNet+LSTM baseline (7.49).
- Increasing the number of transformer layers from 3 to 24 significantly improved model accuracy, with 24 layers achieving the best performance on the test set.
- The model outperformed all CNN+RNN baselines, including ResNet50+LSTM, which had a Levenshtein distance of 7.49, even with more parameters and longer training.
- The caching and module segregation techniques reduced inference time complexity from O(N³) to O(MN + N²), enabling faster autoregressive decoding with minimal re-computation.
- Training on 384×384 images with 16×16 patches improved performance compared to 224×224, suggesting that longer sequence lengths benefit from the self-attention mechanism.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.