Qwen3_5MoeBackbone classkeras_hub.models.Qwen3_5MoeBackbone(
vocabulary_size,
num_layers,
num_query_heads,
num_key_value_heads,
head_dim,
hidden_dim,
moe_intermediate_dim,
shared_expert_intermediate_size,
num_experts,
top_k,
layer_types=None,
partial_rotary_factor=0.25,
rope_max_wavelength=10000,
rope_scaling_factor=1.0,
layer_norm_epsilon=1e-06,
dropout=0.0,
tie_word_embeddings=False,
sliding_window_size=32768,
linear_num_key_heads=16,
linear_num_value_heads=32,
linear_key_head_dim=128,
linear_value_head_dim=128,
linear_conv_kernel_dim=4,
vision_encoder=None,
mrope_section=None,
router_aux_loss_coefficient=0.001,
dtype=None,
**kwargs
)
The Qwen3.5 MoE Transformer core architecture with hyperparameters.
This network implements a hybrid Transformer-based decoder with two
layer types and a Mixture-of-Experts (MoE) feedforward:
- full_attention: Standard grouped-query attention with partial
rotary embeddings and sigmoid output gating.
- linear_attention: GatedDeltaNet recurrent linear attention with
causal conv1d and delta rule recurrence.
The feedforward in every layer is a SparseMoeBlock with top-k expert routing and a shared expert with sigmoid gating.
The backbone optionally accepts a vision_encoder to enable
multimodal (image + text) inputs.
Arguments
0.25.10000.1.0.1e-6.0.0.False.32768.keras.mixed_precision.DTypePolicy.Example
input_data = {
"token_ids": np.ones(shape=(1, 12), dtype="int32"),
"padding_mask": np.array([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]]),
}
model = keras_hub.models.Qwen3_5MoeBackbone(
vocabulary_size=248320,
num_layers=4,
num_query_heads=16,
num_key_value_heads=2,
head_dim=256,
hidden_dim=2048,
moe_intermediate_dim=512,
shared_expert_intermediate_size=512,
num_experts=8,
top_k=2,
)
model(input_data)
from_preset methodQwen3_5MoeBackbone.from_preset(preset, load_weights=True, **kwargs)
Instantiate a keras_hub.models.Backbone from a model preset.
A preset is a directory of configs, weights and other file assets used
to save and load a pre-trained model. The preset can be passed as a
one of:
'bert_base_en''kaggle://user/bert/keras/bert_base_en''hf://user/bert_base_en''modelscope://user/bert_base_en''./bert_base_en'This constructor can be called in one of two ways. Either from the base
class like keras_hub.models.Backbone.from_preset(), or from
a model class like keras_hub.models.GemmaBackbone.from_preset().
If calling from the base class, the subclass of the returning object
will be inferred from the config in the preset directory.
For any Backbone subclass, you can run cls.presets.keys() to list
all built-in presets available on the class.
Arguments
True, the weights will be loaded into the
model architecture. If False, the weights will be randomly
initialized.Examples
# Load a Gemma backbone with pre-trained weights.
model = keras_hub.models.Backbone.from_preset(
"gemma_2b_en",
)
# Load a Bert backbone with a pre-trained config and random weights.
model = keras_hub.models.Backbone.from_preset(
"bert_base_en",
load_weights=False,
)
| Preset | Parameters | Description |
|---|---|---|
| qwen3_5_moe_35b_a3b_base | 35.11B | 35 billion total parameter Qwen3.5 MoE base model with ~3 billion active parameters per token. Features a 3:1 hybrid attention stack (GatedDeltaNet linear attention and full attention) with sparse Mixture-of-Experts feedforward for highly efficient inference. Supports text and multimodal inputs. |
| qwen3_5_moe_35b_a3b | 35.11B | 35 billion total parameter Qwen3.5 MoE instruction-tuned model with ~3 billion active parameters per token. Features a 3:1 hybrid attention stack (GatedDeltaNet linear attention and full attention) with sparse Mixture-of-Experts feedforward. Optimized for chat, reasoning, coding, and multimodal tasks. |
| qwen3_6_moe_35b_a3b | 35.11B | 35 billion total parameter Qwen3.6 MoE instruction-tuned model with ~3 billion active parameters per token. Features a 3:1 hybrid attention stack (GatedDeltaNet linear attention and full attention) with sparse Mixture-of-Experts feedforward. Optimized for fast inference and extended context lengths. |
token_embedding propertykeras_hub.models.Qwen3_5MoeBackbone.token_embedding
A keras.layers.Embedding instance for embedding token ids.
This layer embeds integer token ids to the hidden dim of the model.
enable_lora methodQwen3_5MoeBackbone.enable_lora(rank, target_layer_names=None)
Enable Lora on the backbone.
Calling this method will freeze all weights on the backbone,
while enabling Lora on the query & value EinsumDense layers
of the attention layers.
Arguments
None, this will be populated with the
default LoRA layer names as returned by
backbone.default_lora_layer_names().