# 10th solution private 0.61 : TNT/VIT/CAIT ensemble + tricks

to be updated ….
there are two part:
part one: TNT/VIT/CAIT ensemble model (public/private LB 0.71/0.71)
[https://www.kaggle.com/c/bms-molecular-translation/discussion/243766](https://www.kaggle.com/c/bms-molecular-translation/discussion/243766)
(this post)
part two: OCR + MolBuilder + object detection CNN (public/private LB 0.62/0.61)
[https://www.kaggle.com/c/bms-molecular-translation/discussion/243809](https://www.kaggle.com/c/bms-molecular-translation/discussion/243809)
TNT/VIT/CAIT ensemble model (public/private LB 0.71/0.71)
we train 5 models : 3x patched based VIT (patch size 16, image scale = 0.8,0.9,0.1), 1x TNT with image size 384 and 1x CAIT with image size 240. For details, please refer to
[https://www.kaggle.com/c/bms-molecular-translation/discussion/231190](https://www.kaggle.com/c/bms-molecular-translation/discussion/231190)
(local CV 0.78)
we do 5 iterations of image perturbation. if an image has gives an invalid inchi (verification by rdkit), we perturb the image and try inference again.
( local CV 0.76)
finally, we apply rdkit normalisation.
(public/private LB 0.73/0.74, local CV 0.72)
The ensemble is our top score submission. We also have submissions for each of the individual models. We then sort all submission cvs by LB score. To create the final submission:
1. We start off will predictions from the top score submission csv.
2. For a current prediction has invalid inchi, it will be replaced from the corresponding one from the next higher score submission csv if ( and only if ) that corresponding one is valid
3. The process is repeated for all csvs.
Final LB score is (public/private LB 0.71/0.71, local CV 0.70)
![](assets/7a747236d36a01127da2a4f1.png)
we use random shift and scale to perturb image
here is a tip on ensemble strategy:
![](assets/2996ba965264e7beaafa5ec2.png)
we note that lb score is correlated to the number of invalid inchi (verified from rdkit). If you have fewer invalid inchi, you are likely to better LB score.
instead of making many submissions, you can use the number of invalid inchi to estimate your lb score. To know the limit of LB score of your current method, you can extrapolate your graph to the lowest number of possible inchi. If that doesn't work well, you can change your ensemble strategy so that you have a steeper graph. (i.e. better lb score per invalid inchi)
Acknowledgment
I am grateful to Z by HP & NVIDIA for sponsoring me a Z8 Workstation with dual RTX8000 GPU for this competition. In the final days, I need to run TNT/VIT/CAIT ensemble (5 transformers) on the 1.6 million test images. Some of the test images are large and have long sequences. Besides high computative power, we also need high GPU memory.
One RTX8000 GPU has 48GB onboard. It takes about 7 hours to process all images using the workstation. This is very fast and definitely help our team to secure a gold medal of 10th placing in the final ranking!