You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Q] Non-causal / bidirectional attention in decoder models for sentence embeddings #478
While working on sentence transformers support in Bumblebee, I hit an issue running popular decoder-based text embedding models (such as Alibaba-NLP/gte-Qwen2-7B-instruct or fine-tuned Llama/Mistral embedding backbones). These models require non-causal (bidirectional) attention across input tokens.
In #468, :use_bidirectional_attention (default false) was introduced for Gemma3Text, following Gemma3TextConfig.use_bidirectional_attention in huggingface/transformers.
However, in checkpoints for other decoder architectures (like Qwen, Llama, and Mistral), Hugging Face models typically set "is_causal": false in config.json instead of using use_bidirectional_attention.
Before opening a PR, I'd like to ask how you'd prefer to model this in Bumblebee:
Unify on :use_bidirectional_attention (default: false):
Add :use_bidirectional_attention to Shared.common_options/1 across Llama, Mistral, Qwen3, and Gemma 3, map "is_causal": false from HF configs, and validate against conflicting values in shared options.
We generally try to use consistent naming across models, so we can have :use_bidirectional_attention across models.
Note that the Alibaba-NLP/gte-Qwen2-7B-instruct example you gave they actually use "auto_map" with custom .py implementation of the model, which we don't support. is_causal is not typically in the config, since models like Llama, Mistral generally are causal, so I would rather add it on case by case basis.
Also, I wouldn't necessarily add it to Llama and Mistral, unless there is a specific checkpoint that has this flag in the config and is relevant, since those models are typically causal. In other words, I would do it on case by case basis.
Activity
jonatanklosko commentedon Oct 5, 2026
We generally try to use consistent naming across models, so we can have
:use_bidirectional_attentionacross models.Note that the
Alibaba-NLP/gte-Qwen2-7B-instructexample you gave they actually use "auto_map" with custom .py implementation of the model, which we don't support.is_causalis not typically in the config, since models like Llama, Mistral generally are causal, so I would rather add it on case by case basis.Also, I wouldn't necessarily add it to Llama and Mistral, unless there is a specific checkpoint that has this flag in the config and is relevant, since those models are typically causal. In other words, I would do it on case by case basis.