TL;DR
BidirLM provides a robust, open-source framework for transforming causal LLMs (like Gemma3 and Qwen3) into high-performance bidirectional encoders. By combining a critical "Masked Next-Token Prediction" (MNTP) phase with linear weight merging, the authors create a family of encoders that set new performance frontiers across text, vision, and audio representation benchmarks.
What Problem Does This Paper Address?
While causal decoder-only LLMs dominate the generative landscape, representation tasks—such as text embeddings, sequence classification, and retrieval—have traditionally remained the domain of bidirectional encoders like BERT. There is a vast ecosystem of specialized causal models (trained for code, math, or specific modalities), but their knowledge remains largely untapped for representation tasks.
Existing attempts to "encoder-ize" causal models face three main hurdles:
- Lack of Consensus: There is no agreement on whether to use masking objectives, contrastive training, or both.
- Catastrophic Forgetting: Scaling adaptation often causes the model to lose the foundational knowledge (like multilingual or math skills) present in the base LLM.
- Rigid Pipelines: Current methods don't easily allow for the integration of specialized knowledge from other models in the causal ecosystem.
Methods
The authors introduce a biphasic adaptation pipeline and a modular composition strategy:
- BidirLM Adaptation Pipeline: They start by enabling bidirectional attention in a causal base model. They then apply two sequential phases:
- Masked Next-Token Prediction (MNTP): A variant of masking that predicts a masked token based on the full bidirectional context.
-
InfoNCE Contrastive Training: Aligning representations of semantically similar pairs.
Figure 1: Base (1): The original causal model. Bi+Base (2): The Base model with bidi- rectional attention enabled. Bi+MNTP (3): The Bi+Base model with an MNTP adapta- tion phase. Bi+Contrastive (4): The Bi+Base model with a contrastive adaptation phase. Bi+MNTP+Contrastive (5): The Bi+Base model adapted sequentially using MNTP followed by contrastive training. Intermediate dashed blocks denote adaptation phases. -
Mitigating Forgetting: To scale adaptation without the original pre-training data, they use linear weight merging. By averaging the weights of the adapted model with the original base model (typically at a 50/50 ratio), they recover foundational knowledge without sacrificing new bidirectional capabilities. They also incorporate a lightweight multi-domain data mixture (20-30% code, math, and multilingual data).
- Omnimodal Composition: The authors demonstrate that you can "merge in" new modalities. By taking the textual backbones of specialized causal models (e.g., Qwen3-VL for vision) and merging them with their adapted text encoder, they create BidirLM-Omni, a single model capable of representing text, images, and audio.
Datasets
- Training: The authors rely exclusively on open-source data, including FineWeb-Edu (English), FineWeb2-HQ (multilingual), FineMath, and Stack V2 (code).
- Omni-Contrastive Corpus: A new 1.8M-pair dataset introduced in this paper, mixing text-text, audio-text (from Laion-Audio-300M and LibriSpeech), and image-text (from Colpali and MSCOCO) pairs.
- Evaluation: Models were tested on MTEB (text embeddings), an augmented XTREME benchmark (including math and code), MIEB (images), and MAEB (audio).
Key Insights and Ideas
-
MNTP is Critical for Fine-Tuning: A major "aha" moment is that while contrastive training drives zero-shot embedding quality, the often-omitted MNTP phase is essential for performance on downstream tasks that require full-parameter fine-tuning (like NLI or summarization).
Figure 2: Performance comparison of model variants across downstream tasks. Bars illustrate the absolute performance change relative to the unmodified Base model. Exact point differences are annotated above or below each bar. -
Weight Merging as a Regularizer: Linear weight merging acts as a powerful, data-free strategy to combat distribution shift. It effectively balances the new bidirectional patterns with the base model's original distributional coverage.
- Backbone Sharing Enables Modality Transfer: Because many specialized models (vision, audio, safety) share the same underlying LLM backbone, their weights can be merged directly into a text encoder to transfer those capabilities with minimal additional training.
Key Results
-
New Pareto Frontiers: The BidirLM series establishes a new state-of-the-art for open-source encoders across various sizes. For instance, BidirLM-270M matches the performance of the much larger mmBERT-base while using 10% fewer parameters.
Figure 6: Multilingual model performance by size. We report the average scores of the latest multilingual models across individual tasks on the XTREME and MTEB benchmarks. The dashed line indicates the open-source performance Pareto frontier. -
Omnimodal Success: BidirLM-Omni-2.5B outperforms Nemotron-Omni-3B across all modalities, achieving a +17 point gain on text and +5 on image benchmarks, despite being smaller.
- Sample Efficiency: The merged safety encoder reached 93% of its peak performance in just 20 fine-tuning steps, significantly outperforming non-merged baselines.
Limitations and Future Work
- Modality Alignment Warm-up: The authors noted a "warm-up" period (100-175 steps) required when aligning internal representations with newly introduced modality heads (vision/audio).
- Backbone Dependency: The merging technique requires models to share an identical underlying architecture and starting weights.
- Future Directions: The authors suggest that future work could explore more sophisticated merging techniques beyond simple linear interpolation and investigate how to further scale these omnimodal encoders to even larger LLM families.
Summary updated