BidirLM: From Text to Omnimodal Bidirectional Encoders by Adapting and Composing Causal LLMs
Abstract
Adapting causal generative language models into bidirectional encoders through systematic ablation and novel merging strategies achieves superior performance across multiple modalities.
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.
Community
Hi @Nicolas-BZRD , very cool approach! Do you btw. plan to release the code for building a BidirLM model? I would be super interested in trying this out for smaller German models (we have Llämmlein and Boldt here) and I see a lot of potential in these new bidirectional encoders :)
Hey @stefan-it , which part are you interested in? For contrastive training (including the multimodal one), we rely on Sentence-Transformers. For the adaptation, we use a fork of the EuroBERT codebase, which is available on GitHub: https://github.com/Diabolocom-Research/Decoder2Encoder and merging is performed with MergeKit: https://github.com/arcee-ai/mergekit
The Decoder2Encoder repo is exactly what I was looking for, many thanks for the link!
Get this paper in your agent:
hf papers read 2604.02045 Don't have the latest CLI?
curl -LsSf https://hf.co/cli/install.sh | bash 