Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/bumblebee.ex
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ defmodule Bumblebee do
"Qwen3Model" => {Bumblebee.Text.Qwen3, :base},
"Qwen3ForCausalLM" => {Bumblebee.Text.Qwen3, :for_causal_language_modeling},
"Qwen3ForSequenceClassification" => {Bumblebee.Text.Qwen3, :for_sequence_classification},
"Qwen3VLForConditionalGeneration" =>
{Bumblebee.Multimodal.Qwen3VL, :for_conditional_generation},
"ResNetForImageClassification" => {Bumblebee.Vision.ResNet, :for_image_classification},
"ResNetModel" => {Bumblebee.Vision.ResNet, :base},
"RobertaForMaskedLM" => {Bumblebee.Text.Roberta, :for_masked_language_modeling},
Expand Down Expand Up @@ -242,12 +244,14 @@ defmodule Bumblebee do

@transformers_image_processor_type_to_featurizer %{
"BlipImageProcessor" => Bumblebee.Vision.BlipFeaturizer,
"BitImageProcessor" => Bumblebee.Vision.BitFeaturizer
"BitImageProcessor" => Bumblebee.Vision.BitFeaturizer,
"Qwen3VLImageProcessor" => Bumblebee.Vision.Qwen3VLFeaturizer
}

@model_type_to_featurizer %{
"convnext" => Bumblebee.Vision.ConvNextFeaturizer,
"deit" => Bumblebee.Vision.DeitFeaturizer,
"qwen3_vl" => Bumblebee.Vision.Qwen3VLFeaturizer,
"resnet" => Bumblebee.Vision.ConvNextFeaturizer,
"vit" => Bumblebee.Vision.VitFeaturizer,
"whisper" => Bumblebee.Audio.WhisperFeaturizer
Expand All @@ -274,7 +278,9 @@ defmodule Bumblebee do
"mpnet" => :mpnet,
"phi" => :code_gen,
"phi3" => :llama,
"qwen2_vl" => :qwen2,
"qwen3" => :qwen2,
"qwen3_vl" => :qwen2,
"roberta" => :roberta,
"smollm3" => :smollm3,
"t5" => :t5,
Expand Down
10 changes: 10 additions & 0 deletions lib/bumblebee/layers/transformer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ defmodule Bumblebee.Layers.Transformer do
:num_blocks,
:rotary_embedding,
:attention_window_size,
:post_block_hook,
attention_mask: Layers.none(),
attention_head_mask: Layers.none(),
attention_relative_bias: nil,
Expand All @@ -97,6 +98,7 @@ defmodule Bumblebee.Layers.Transformer do
cache = opts[:cache]
rotary_embedding = opts[:rotary_embedding]
attention_window_size = opts[:attention_window_size]
post_block_hook = opts[:post_block_hook]

block_opts = Keyword.take(opts, block_opts_keys)

Expand Down Expand Up @@ -160,6 +162,14 @@ defmodule Bumblebee.Layers.Transformer do
] ++ block_opts
)

# Apply post-block hook if provided (e.g., for DeepStack feature injection)
hidden_state =
if post_block_hook do
post_block_hook.(idx, hidden_state)
else
hidden_state
end

cache = Layers.Decoder.put_block_cache(state.cache, idx, block_cache)

%{
Expand Down
Loading
Loading