Hefei University's CBTrans Reads Captions Both Ways Without Extra Parameters
CBTrans fuses left-to-right and right-to-left decoding into one shared-parameter Transformer, beating non-pretrained SOTA on MSCOCO by up to 5% CIDEr
ProTakeaways
- CBTrans fuses left-to-right and right-to-left caption generation into one shared-weight Transformer decoder, running both directions in parallel.
- No extra parameters are added beyond two special token embeddings; the bidirectional setup acts as a built-in regularizer.
- On MSCOCO, ensemble CBTrans hits CIDEr 140.3 on the Karpathy test split, beating all non-pretrained competitors by ~5% CIDEr.
- Ablations show the compact shared-parameter architecture and sentence-level ensemble matter far more than explicit cross-flow attention.
- The R2L flow can generate bad-ending captions after RL fine-tuning, slightly hurting BLEU scores -- a known limitation.
- Source code is open on GitHub; the architecture also extends to LSTM backbones (CBLSTM).
Every image captioning model you have probably used reads left to right. It predicts the next word using only the words it has already written, never peeking ahead. That works fine for simple scenes, but it means the model commits to early word choices before it knows how the sentence will end. A new paper from Hefei University of Technology introduces CBTrans (Compact Bidirectional Transformer for Image Captioning), a single model that generates captions in both directions simultaneously, with no extra parameters and no sequential bottleneck.
The left-to-right trap
The unidirectional property of standard captioning models means they can only leverage past context, not future context. This creates a compounding problem: if the model writes "a man" first, it has already narrowed its options for the rest of the sentence, even if the most informative part of the image is the surfboard he is carrying.
Researchers have tried to fix this with refinement-based models, which generate a draft caption and then refine it in a second pass. Though these models can exploit both past and future context, their decoder consists of two networks -- a retriever or captioner in the first stage and a refiner in the second -- which can only be executed sequentially. That kills GPU parallelism and doubles inference time.

One model, two directions, zero extra parameters
CBTrans introduces a Compact Bidirectional Transformer model for image captioning that can leverage bidirectional context implicitly and explicitly while the decoder can be executed in parallel. The key insight is deceptively simple: instead of training two separate models or two sequential stages, the authors tightly couple a left-to-right (L2R) and a right-to-left (R2L) decoding flow inside a single Transformer with fully shared weights.
During training, each image is paired with two captions: one prefixed with a special <l2r> token and one prefixed with <r2l> (the reversed caption from a different annotation for the same image, to prevent the model from just copying). Both flows run in parallel through the same decoder layers. The joint loss is the sum of the L2R and R2L cross-entropy losses, and the whole thing is end-to-end trainable.
At inference, both flows decode simultaneously in lockstep. The model then picks whichever output caption scores higher -- a strategy the authors call sentence-level ensemble. Critically, the L2R and R2L flows are tightly coupled into a single compact model to serve as a regularization for implicitly exploiting bidirectional context, while the final caption is chosen from either L2R or R2L flow in a sentence-level ensemble manner.
How the bidirectional attention actually works
The decoder's masked self-attention is extended with an optional cross-flow interaction. At each decoding step, the L2R flow can attend not only to its own past tokens but also to the R2L flow's past tokens (which encode future context from the other direction). Formally, each attention head computes:
- Past context head: standard masked attention over the L2R sequence so far
- Future context head: attention using the L2R query against the R2L keys and values
- Fusion: the two are combined as
H = H_past + λ * activation(H_future), where λ controls how much the other flow is trusted
Setting λ=0 degrades the model back to a standard Transformer, making it a strict superset of the baseline. The R2L direction gets a symmetric version of the same computation. Importantly, ablation studies on MSCOCO find that the compact bidirectional architecture and the sentence-level ensemble play more important roles than the explicit interaction mechanism. The shared-parameter regularization effect alone drives most of the gain -- explicit cross-flow attention only adds a small increment on top.

Training in two stages
The model follows the standard two-stage recipe used across image captioning research:
- Cross-entropy pre-training: minimize joint L2R + R2L token prediction loss for 15 epochs (Transformer) or 30 epochs (LSTM variant).
- Self-critical fine-tuning (SCST): optimize CIDEr score directly using reinforcement learning. Self-critical training (SCST) is a technique where the model's own greedy output acts as a baseline reward, and sampled captions that score higher than that baseline get positive gradient signal. The authors extend this to both flows simultaneously, sampling 5 captions per image per direction.
The authors also release CBLSTM, a compact bidirectional version of the classic Up-Down LSTM captioner, proving the architecture generalizes beyond Transformers.
Beating the leaderboard without pretraining
All experiments use the MSCOCO Karpathy split: 113,287 training images, 5,000 validation, 5,000 test, each with 5 human-written captions. Performance is measured on BLEU-1/4, METEOR, ROUGE-L, SPICE, and CIDEr -- the standard suite for captioning benchmarks. CIDEr is generally considered the most reliable single metric as it rewards consensus with human references.
Key results against non-pretrained models:
- In the model ensemble setting, CBTrans outperforms all other models in all metrics, especially by a large margin in CIDEr (about 5%).
- Single-model CBTrans with VinVL features reaches a CIDEr of 136.9 on the Karpathy test split, up from 134.9 for the standard unidirectional Transformer baseline.
- On the official MSCOCO online test server, CBTrans makes an absolute improvement over the best competitor RSTNet of 4.1%/4.6% in CIDEr c5/c40.
- By combining sentence-level ensemble with word-level ensemble seamlessly, the effect of sentence-level ensemble is further enlarged. The ensemble CBTrans hits CIDEr 140.3 on the Karpathy test split.
The ablation numbers tell a clear story: a single CBTrans model trained once already achieves the same effect as training two separate L2R and R2L models and ensembling them -- at no extra parameter cost.
Where it struggles
The R2L flow has a known failure mode after CIDEr fine-tuning: it sometimes generates captions with bad endings, like starting (in reverse) with a preposition such as "of". This happens because reversed ground-truth captions frequently begin with prepositions, and the RL objective over-exploits that pattern. The authors note this can be patched with a post-processing "remove bad endings" heuristic, but it is a real limitation. The BLEU metrics (which measure n-gram overlap) are slightly hurt by this, even when CIDEr improves.
It is also worth noting that CBTrans is compared only against non-pretrained models. Vision-language pretrained models like OSCAR or VinVL-finetuned variants operate in a different regime, and a direct comparison would not be fair. The authors suggest that the compact bidirectional decoder could be plugged into pretrained frameworks as a drop-in replacement for their unidirectional decoders -- an interesting avenue for future work.
Practical takeaways
If you are building or fine-tuning an image captioning system without access to large-scale vision-language pretraining, CBTrans is a strong baseline worth adopting. The source code is available on GitHub. The architecture is particularly attractive because:
- No parameter increase over a standard Transformer decoder -- only two new token embeddings (
<l2r>and<r2l>) - Parallel decoding: both flows run simultaneously, so inference is not slower than a single-direction model
- Built-in sentence-level ensemble at no extra model storage cost
- Generalizes to LSTM backbones, so it can be retrofitted into older pipelines
The real breakthrough here is not the bidirectional attention itself -- it is the finding that simply sharing parameters between two decoding directions acts as a powerful regularizer. The explicit cross-flow interaction that prior NMT work emphasized turns out to be mostly a distraction. You get most of the benefit just from forcing the model to be good at both directions at once, and then picking the better output at test time.