Talk to our team
Menu

BidirLM: From Text to Omnimodal Bidirectional Encoders by Adapting and Composing Causal LLMs

Authors
  • Nicolas Boizard
  • Théo Deschamps-Berger
  • Hippolyte Gisserot-Boukhlef
  • Celine Hudelot
  • Pierre Colombo
Affiliations
  • Diabolocom
  • Artefact Research Center
  • MICS, CentraleSupelec, Université Paris-Saclay
  • Cohere
Accepted at
COLM 2026
Date
arXiv
2604.02045

Abstract

Transforming causal generative language models into bidirectional encoders offers a powerful alternative to BERT-style architectures. However, current approaches remain limited: they lack consensus on optimal training objectives, suffer from catastrophic forgetting at scale, and fail to flexibly integrate the vast ecosystem of specialized generative models. In this work, through systematic ablations on the Gemma3 and Qwen3 families, we identify the key factors driving successful adaptation, highlighting the critical role of an often-omitted prior masking phase. To scale this process without original pre-training data, we introduce a dual strategy combining linear weight merging with a lightweight multi-domain data mixture that mitigates catastrophic forgetting. Finally, we augment our encoders by merging them with specialized causal models, seamlessly transferring modality- and domain-specific capabilities. This open-source recipe, designed for any causal decoder LLM, yields BidirLM, a family of five encoders that outperform alternatives on text, vision, and audio representation benchmarks.

Cite this paper

@inproceedings{boizard2026bidirlm,
  title = {BidirLM: From Text to Omnimodal Bidirectional Encoders by Adapting and Composing Causal LLMs},
  author = {Nicolas Boizard and Théo Deschamps-Berger and Hippolyte Gisserot-Boukhlef and Celine Hudelot and Pierre Colombo},
  booktitle = {Conference on Language Modeling (COLM 2026)},
  year = {2026}
}

Introduction

Causal large language models (LLMs) are not only dominant as generators but serve as the foundation of a vast ecosystem of specialized variants: code (Lozhkov et al., 2024), mathematics (Shao et al., 2024), safety (Zhao et al., 2025a), vision (Bai et al., 2025), and audio (Shi et al., 2026), collectively representing millions of GPU hours of open-source knowledge. Yet, representation tasks remain bound to bidirectional encoders (Devlin et al., 2019; He et al., 2023; Boizard et al., 2025a), leaving this knowledge untapped. Repurposing causal models into encoders is therefore a compelling goal, and recent work has begun to explore this direction (Ma et al., 2023; BehnamGhader et al., 2024; Wang et al., 2024a; Babakhin et al., 2025; Gisserot-Boukhlef et al., 2026). However, this adaptation landscape remains fragmented around three core questions. We address each through a fully open-source framework, validated under strictly identical conditions on Gemma3 and Qwen3.

What drives adaptation quality? Existing methods conflate critical design choices like training objectives and attention mechanisms, leaving no consensus on what drives quality. Through controlled ablations (§​ 2, §​ 3), we disentangle these factors and show that enabling bidirectional attention via a masking objective (a step often omitted) is critical to unlock performance on task-specific benchmarks, while contrastive objectives primarily drive generic embedding quality.

Can adaptation scale without the original pre-training data? Many adapted models are developed by the same organizations that trained the underlying base models (Vera et al., 2025; Zhang et al., 2025). This raises concerns about reproducibility, as these adaptations may implicitly benefit from alignment with undisclosed pre-training corpora, potentially masking the catastrophic forgetting that occurs under distribution shifts. To scale adaptation under strict independent data constraints (§​ 4), we propose a dual strategy combining training-free linear weight merging with a lightweight multi-domain data mixture. This approach yields adapted models that outperform current open-source alternatives (§​ 5).

Can adapted encoders compose with the causal ecosystem? Current adapted encoders rely on rigid pipelines that fail to compose with other specialized causal models derived from the same backbone. By ignoring the vast ecosystem that motivates starting from causal architectures, these methods leave thousands of GPU hours of open-source specialization unused. We address this by pushing the boundaries of weight merging (§​ 6). We seamlessly integrate knowledge from specialized causal variants, extending our encoders to new domains and modalities (safety, audio, vision) without requiring full pipeline re-training.

Accompanying this work, we release the multilingual BidirLM series, which outperforms open-source alternatives on text, vision, and audio representation benchmarks: BidirLM-270M/1B (Gemma3-based), BidirLM-0.6B/1.7B (Qwen3-based), and BidirLM-Omni-2.5B (text, vision, audio), alongside our training corpus, checkpoints, and experimental variants.

Experimental Setup

We adapt two causal language model families initialized from pretrained weights: Gemma3 (270M, 1B) (Gemma et al., 2025) and Qwen3 (600M, 1.7B) (Yang et al., 2025a) (Models utilized: Gemma3-270M (https://huggingface.co/google/gemma-3-270m), Gemma3-1B (https://huggingface.co/google/gemma-3-1b-pt), Qwen3-0.6B (https://huggingface.co/Qwen/Qwen3-0.6B-Base), and Qwen3-1.7B (https://huggingface.co/Qwen/Qwen3-1.7B-Base); Appendix A). We use the smaller models for ablation studies and the larger models for scaling analysis, covering typical embedding model sizes. From these base models, we derive five distinct variants (detailed in Figure 1) by switching from causal to bidirectional attention and applying two core adaptation objectives either individually or sequentially: Masked Next-Token Prediction (MNTP) (BehnamGhader et al., 2024) and InfoNCE contrastive training (van den Oord et al., 2019).

All adaptation experiments rely exclusively on open-source datasets. For clarity, we structure our corpora along three distinct domains:

English: Masking uses FineWeb-Edu (Penedo et al., 2024); contrastive training uses the English subset of KaLM-embedding (Zhao et al., 2025b) (7 hard negatives per query).

Multi-domain: Masking relies on FineWeb-Edu (English), FineWeb2-HQ (multilingual, 20 languages) (Messmer et al., 2026), FineMath (Liu et al., 2024a) (mathematics), and Stack V2 (code, 34 languages) (Lozhkov et al., 2024). Contrastive training employs a merged corpus of 89 datasets (1 to 7 hard negatives per query) detailed in Appendix C.

Multimodal: We introduce Omni-Contrastive (Dataset available at: https://huggingface.co/datasets/BidirLM/BidirLM-Omni-Contrastive), a 1.8M-pair contrastive corpus mixing 65% text-text (from the multi-domain corpus), 17.5% audio-text from Laion-Audio-300M (200K, audio-description) and LibriSpeech ASR (100K, speech-transcription), and 17.5% image-text from Colpali (Faysse et al., 2024) (100K, document-query), NatCap (Teiletche et al., 2025), and MSCOCO (Lin et al., 2015) (100K each, image-description).

To reflect the current usage landscape, we assess encoder performance across diverse representation tasks under two distinct paradigms:

Fine-tuning evaluation: We apply full-parameter adaptation for downstream tasks spanning the XTREME benchmark (Hu et al., 2020) and four specific task categories: Information Retrieval (IR) via MIRACL (Zhang et al., 2023) and CodeSearchNet (Husain et al., 2020); Sequence Classification (SC) via MNLI (Williams et al., 2018), XNLI (Conneau et al., 2018), PAWS-X (Yang et al., 2019), MathShepherd (Wang et al., 2024c), and CodeComplexity (Jeon et al., 2023); Token Classification (TC) via PAN-X and POS (Hu et al., 2020); and Sequence Regression (SR) via Seahorse (Clark et al., 2023).

Embedding evaluation: We assess off-the-shelf embedding performance via zero-shot and linear probing on MTEB-style benchmarks. Text evaluation uses English and Multilingual MTEB v2 (Muennighoff et al., 2023; Enevoldsen et al., 2025), while cross-modal capabilities rely on MIEB lite (Xiao et al., 2025) (image-only, image-to-image, text-to-image) and MAEB beta (Assadi et al., 2026) (audio-only, audio-to-audio, audio-text).

To verify the capacity to compose our encoder with specialized variants from the causal ecosystem, we perform post-adaptation specialization across three domains:

Safety moderation: We use Qwen3Guard-Gen-0.6B (Zhao et al., 2025a) to transfer safety moderation knowledge to our encoder, assessed via safe/unsafe classification on the Beaver (Ji et al., 2023), Safe (Ji et al., 2025), and Aegis (Ghosh et al., 2025) datasets.

Vision: Qwen3-VL-2B-Instruct (Bai et al., 2025) transfers visual-textual knowledge, evaluated via visual-textual entailment on the e-SNLI-VE (Do et al., 2021) benchmark.

Audio: Qwen3-ASR-0.6B (Shi et al., 2026) transfers audio understanding, which we evaluate via textual comprehension with vocal questions on the BoolQ dataset.

Base (1): The original causal model.
Figure 1. Base (1): The original causal model. Bi+Base (2): The Base model with bidirectional attention enabled. Bi+MNTP (3): The Bi+Base model with an MNTP adaptation 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.

Adaptation Strategies

Recent adaptation methods often rely exclusively on contrastive training, omitting masking objectives or bidirectional attention. To disentangle these choices, we evaluate our five adaptation variants (Figure 1) on Gemma3-270M and Qwen3-0.6B. We adapt these models using 10B tokens for masking and 3M samples for contrastive training on the English corpus (§​ 2), and report their downstream performance against the causal baseline (Base) in Figure 2.

As shown in Figure 2, enabling bidirectional attention at the fine-tuning stage only (Bi+Base) produces mixed results: it improves token classification and retrieval across both architectures but degrades performance on XNLI and Seahorse. However, introducing an MNTP adaptation phase unlocks the full benefit of bidirectional attention, boosting performance across all tasks with notable gains on XNLI and Seahorse (Gemma: +0.8 and +9.0; Qwen: +2.7 and +8.4, respectively).

Consistent with prior work (Gao et al., 2021; Li et al., 2023; BehnamGhader et al., 2024), contrastive objectives drive generic embedding performance under zero-shot and linear probing evaluation (Figure 2), outperforming Bi+MNTP on MTEB by over 13 points across both architectures. However, our controlled comparison reveals that contrastive training alone sacrifices performance on tasks requiring full-parameter fine-tuning (e.g., XNLI, Seahorse) for embedding gains. To leverage the strengths of both paradigms, we employ a sequential adaptation strategy: MNTP followed by contrastive training (Bi+MNTP+Contrastive). This approach matches or surpasses the individual objectives across all tasks.

Performance comparison of model variants across downstream tasks.
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.

Scaling Adaptation Phases

Following §​ 3, we scale the adaptation process while aiming to preserve the foundational knowledge of the base models. However, training on corpora diverging from the original pre-training distribution inherently risks alignment drift and catastrophic forgetting.

Catastrophic Forgetting

To assess forgetting under realistic constraints (Figure 3), we extend MNTP adaptation for Gemma3-270M and Qwen3-0.6B from 10B to 30B tokens on the English corpus (§​ 2). Simultaneously, we monitor multi-domain performance at 10B-token intervals across multilingual (MIRACL, XNLI), code (CodeSearchNet), and math (Math Shepherd) benchmarks.

Scaled Adaptation Induces Forgetting. As expected, scaling adaptation on a distribution unaligned with the original pre-training data leads to a clear forgetting phenomenon as training progresses: Gemma declines on Arabic (-7.0 points on MIRACL, -2.0 on XNLI), while Qwen demonstrates forgetting on Math Shepherd (-1.5) and CodeSearchNet (-2.0). To counteract this degradation, we propose two complementary approaches: a data-free model merging strategy and a lightweight multi-domain data mixture.

Model Merging Mitigates Forgetting and Preserves Bidirectional Capabilities. Motivated by the observation that the adapted and base models remain close in weight space, with an average cosine similarity of 0.78 for Gemma and 0.97 for Qwen, we explore linear model merging (Wortsman et al., 2022b), a technique shown to mitigate forgetting by averaging weights between different checkpoints. Specifically, we merge the 30B-token English-only MNTP models with their original base checkpoints using interpolation ratios ranging from 10% to 90% (30% means a 0.3 weighting factor is applied to the base model).

As shown in Figure 4, performance peaks near a 50% merging ratio, intuitively balancing the adapted bidirectional attention patterns with base model’s distributional coverage. Consequently, we report the 30B adapted checkpoints at this 50% ratio (denoted Merge) in Figure 3. Compared to unmerged baselines, these models yield substantial cross-domain gains: +6 points on Arabic MNLI and code for Gemma, and +4 points in math for Qwen. Overall, merging emerges as a highly effective, data-free strategy to recover original knowledge.

Complementing model merging, we investigate how multi-domain training mixtures mitigate adaptation forgetting without prior knowledge of the original pre-training distribution.

As illustrated in Figure 5, we replace part of our initial English mix with multi-domain data (§​ 2) distributed equally across multilingual, math, and code domains. We observe that performance plateaus when allocating just 20% to 30% of the mixture to this multi-domain subset, indicating that a small fraction is sufficient to preserve original knowledge. To control for this factor, we fix this ratio at 20% for subsequent experiments. Building on our merging strategy, interpolating this checkpoint with the original base weights yields further gains. This final Multilingual+Merge configuration (Figure 3) achieves our best overall results, with an average improvement of +2 points on XNLI and MIRACL for both architectures, and up to +11 points on code benchmarks for Gemma.

Evolution of model performances during long run adaptation.
Figure 3. Evolution of model performances during long run adaptation. Solid lines depict the absolute score change relative to the initial 10B adaptation, while dotted lines highlight the impact of complementary solutions to retain general knowledge.
Model performance across merging ratios.
Figure 4. Model performance across merging ratios. The first four columns report task scores, while the rightmost column reports the model ranking based on average normalized performance across all tasks. Merging ratio index dictates the interpolation weight.
Model performance across data mix ratios.
Figure 5. Model performance across data mix ratios. The first four columns report task scores, while the rightmost column reports the model ranking based on average normalized performance across all tasks. The mix ratio specifies the proportion of multi-domain data.

Frontier Performance Through Scaled Adaptation

Building upon our best-performing adaptation strategies (§​ 3) and empirical findings (§​ 4), we scale our approach to larger architectures, yielding four Bi+MNTP variants: Gemma3 (270M and 1B) and Qwen3 (0.6B and 1.7B). To establish strong general-purpose embedding capabilities, we execute the second step of our biphasic pipeline via contrastive training on 10M samples from our multi-domain corpus (§​ 2). We evaluate these final models, denoted the BidirLM series, on MTEB and an augmented XTREME benchmark (incorporating math and code domains, detailed in Appendix D), plotting the Pareto frontier against the latest fully open-source models (i.e., those releasing complete contrastive training data).

Under full-parameter fine-tuning, all BidirLM variants establish a new performance frontier on the augmented XTREME benchmark. Notably, BidirLM-270M matches the performance of mmBERT-base (Marone et al., 2025) while utilizing 10% fewer parameters, and BidirLM-0.6B outperforms its closest counterpart (EuroBERT-610m) by more than 1 point.

Traditionally, generic embeddings and task-specific fine-tuning rely on separate model variants. Our adaptation eliminates this trade-off: beyond achieving the strongest performance on full-parameter fine-tuning, the exact same BidirLM variants advance the open-source Pareto frontier across three of our four size configurations on generic embedding benchmarks (MTEB). Notably, we accomplish this using only classical contrastive training, completely avoiding knowledge distillation from proprietary models or costly multi-run averaging. Consequently, our models constitute robust open-source baselines for future work challenging closed-source systems such as Qwen3-Embedding and EmbeddingGemma.

Multilingual model performance by size.
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.

Domain and Modality Specialization

Motivated by the observation that weight merging efficiently preserves the base model’s foundational knowledge and bidirectional capabilities (§​ 4), we push the boundaries of this technique to tailor our generic encoders to new domains and modalities, harnessing the vast ecosystem of specialized generative models.

Domain Alignment

We explore domain knowledge transfer by exploiting the shared backbone between our Bi+MNTP Qwen3-0.6B and the Qwen3Guard-Gen-0.6B safety model (§​ 2). We merge them at a 50% ratio (cos sim: 0.97) and perform 500 fine-tuning steps on the Beaver training set (two minutes on one MI250X GPU). We evaluate the resulting encoder on the Beaver test set and two out-of-distribution benchmarks (Safe and Aegis) against the specialist causal model fine-tuned with bidirectional attention (Bi+Specialist) and the Bi+MNTP models.

As shown in Figure 7, the merged encoder (Bi+MNTP+Merge) outperforms all other configurations by over 1 point on average. It also shows better out-of-distribution generalization and greater training stability, with minimal variance between raw measurements and EMA-smoothed curves.

The Bi+MNTP+Merge model reaches over 93% of its peak performance across all benchmarks in just 20 steps (80 samples). At this early training stage, it outperforms all other variants by a margin of more than 5 points.

Modality Alignment

We extend this approach to new modalities by merging the bimodal vision-text Qwen3-VL-2B-Instruct and the unimodal audio Qwen3-ASR-0.6B models with our adapted Bi+MNTP encoders (Qwen3-1.7B and Qwen3-0.6B, respectively) in equal proportions (cosine similarities: 0.97 for vision, 0.93 for audio). Finally, we conduct a 500-step fine-tuning phase on e-SNLI-VE (visual-textual entailment) and BoolQ-Audio (vocal comprehension) (§​ 2).

Modality Adaptation Reveals a Warm-Up Phase. Merged variants yield the highest overall performance (Figure 8), exceeding Bi+Specialist by over 1 and 15 points on vision and audio tasks, and surpassing unmerged baselines by over 30 and 19 points respectively. Unlike in domain adaptation, the merged variant exhibits an initial warm-up period of 100 vision steps and 175 audio steps. Consistent with prior literature, this warm-up phase stems from the requirement to align internal representations with the newly introduced modality heads.

Merging succeeds without shared modalities. We observe a clear gap between baseline performances. While the Bi+Specialist remains competitive in vision, trailing the merged model by only 1 point, it degrades significantly in audio. We attribute this to the input modalities of the specialist models: the vision model already possessed multimodal capabilities for text and vision, whereas the audio model was trained exclusively for unimodal speech recognition. Crucially, we observe that merging technique still succeeds, demonstrating that models can be effectively combined even when they share no prior overlapping modalities.

Omnimodal Alignment

Building on the observation that our encoder can easily adapt to new modalities, we introduce BidirLM-Omni-2.5B, a compact omnimodal model. We construct this by merging the textual backbones of three Qwen3-1.7B variants (ASR, VL, and Bi+MNTP) in equal proportions, appending their respective audio and visual heads (Appendix E). Following contrastive training on our multimodal corpus (§​ 2), we evaluate the model against numerous baselines (Figure 9) across MTEB (Text), MIEB (Image), and MAEB (Audio).

BidirLM-Omni-2.5B outperforms the latest best-performing omnimodal model, Nemotron-Omni-3B (Xu et al., 2025), across all modalities, achieving notable gains on text (+17) and image (+5) benchmarks while being nearly half the size (2.5B vs. 4.8B).

Beyond outperforming its omnimodal counterparts, BidirLM-Omni-2.5B establishes new Pareto frontiers regardless of data transparency. Notably, the merging process efficiently leverages the strengths of each model variant, enabling it to rank first among all baselines on the MIEB benchmark and third on MAEB, surpassing bimodal architectures many times its size.

By reusing existing specialized models rather than training from scratch, BidirLM-Omni required only 250 additional GPU hours (MI250X) of compute for merging and contrastive training, demonstrating that new omnimodal architectures can be assembled incrementally as specialized models become available, bypassing the need to retrain the entire pipeline.

Evolution of performance during domain specialization.
Figure 7. Evolution of performance during domain specialization. We report test split performance on Beaver, SAFE and Aegis. Solid lines correspond to the exponential moving averaged (EMA) curves (α=0.4), with shaded areas showing raw value deviation.
Evolution of performance during modality specialization.
Figure 8. Evolution of performance during modality specialization. We report test split F1 score on e-SNLI-VE (vision) and Boolq-Audio (Audio). Solid lines correspond to exponential moving average curves (α=0.4), with shaded areas showing raw data deviation.

Related Work

Causal LLMs have emerged as strong backbones for text embeddings (Ma et al., 2023; Liu et al., 2024b; Springer et al., 2025), with adaptation strategies generally falling into two paradigms. The first injects bidirectionality through masking-based objectives, using either classical masked language modeling (MLM) (Devlin et al., 2019) or the next-token variant MNTP (BehnamGhader et al., 2024), prior to fine-tuning. While BehnamGhader et al. (2024) first proposed the MNTP-then-contrastive pipeline, their evaluation did not isolate the contributions of bidirectional attention, the masking objective, and contrastive training itself. Consequently, the second paradigm, which is now dominant in practice, skips the masking phase entirely and applies contrastive learning directly (Le-Khac et al., 2020; Wang et al., 2024a; Lee et al., 2025). Within this approach, attention design varies: some methods enable full bidirectionality (e.g., Embedding-Gemma (Vera et al., 2025)), while others preserve causal masking (e.g., Qwen3 Embedding (Zhang et al., 2025)). This contrastive paradigm has recently been extended to multimodal representations, yielding models like VLM2Vec (Jiang et al., 2025) and Nemotron-Omni (Xu et al., 2025).

Adapting models to new objectives and distributions inevitably risks catastrophic forgetting (French, 1999). While traditional continual learning relies on compute-intensive replay buffers or regularization (Rolnick et al., 2019; Wang et al., 2024b), post-hoc weight merging (Model Soups (Wortsman et al., 2022b) or Task Arithmetic (Ilharco et al., 2023)) offers a highly efficient alternative, enabling models to seamlessly adapt to new distributions. However, these techniques have historically been applied to models sharing similar objectives and attention mechanisms.

Conclusion

In this work, we introduce a unified, fully open-source framework for transforming causal decoder LLMs into bidirectional encoders spanning text to multiple modality domains. Through systematic comparisons, we show that the masking phase omitted by recent contrastive-only methods is in fact critical for fine-tunig performance. To scale this adaptation without proprietary pre-training data, we employ a dual strategy of linear weight merging and a lightweight multi-domain data mixture, yielding the BidirLM model family. Rather than building inflexible systems, our framework seamlessly composes specialized generative models with our adapted encoders, enabling efficient cross-modal and domain-specific adaptation without retraining entire pipelines, culminating in BidirLM-Omni.

Future Work

Our ablations focused on the masking phase, a step frequently omitted in concurrent work. While contrastive training already benefits from an extensive body of prior work and ablations (Xu et al., 2025; Zhang et al., 2025; Vera et al., 2025; Hu et al., 2025), systematically studying data composition, hard-negative mining strategies, and scaling behavior in the omnimodal setting remains a natural next step.

In this study, we rely on linear merging and data mixing, both lightweight by design. We plan to explore richer regularization strategies, notably knowledge distillation (Hinton et al., 2015) from the base model. Utilizing recent techniques that enable cross-architectural distillation (Boizard et al., 2025b; Minixhofer et al., 2025) may offer stronger knowledge retention at the cost of additional compute. Finally, validating our framework on non-transformer causal architectures, such as state-space models (Gu and Dao, 2024; Yang et al., 2025b), remains an open question.

Next step

A problem worth researching?

Tell us what you are trying to solve, and we will put you in touch with the people who work on it.