RWKV7Backbone classkeras_hub.models.RWKV7Backbone(
hidden_size,
head_size,
num_layers,
vocabulary_size,
intermediate_dim,
gate_lora=128,
mv_lora=32,
aaa_lora=64,
decay_lora=64,
dtype=None,
dropout_rate=0,
**kwargs
)
The RWKV7 Transformer core architecture with hyperparameters.
This network implements a RNN-based decoder network, Goose, as described in RWKV-7.
This network implements a Modern RNN architecture based on linear attention mechanisms with recurrent processing, as described in the RWKV papers. It includes the embedding lookups and RWKV-7 blocks.
The default constructor gives a fully customizable, randomly initialized
RWKV-7 model with any number of layers, heads, and embedding dimensions.
To load preset architectures and weights, use the from_preset
constructor.
Arguments
128 .32 .64 .64 .keras.mixed_precision.DTypePolicy. The dtype to use
for model computations and weights. Note that some computations,
such as softmax and layer normalization, will always be done at
float32 precision regardless of dtype.Examples
input_data = np.ones(shape=(1, 12), dtype="int32")
# Randomly initialized RWKV-7 decoder with custom config.
model = keras_hub.models.RWKV7Backbone(
vocabulary_size=10,
hidden_size=512,
num_layers=2,
head_size=64,
intermediate_dim=1024,
dtype="float32"
)
model(input_data)
from_preset methodRWKV7Backbone.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 |
|---|---|---|
| rwkv7_g1a_0.1b_en | 150.00M | 150 million parameter RWKV7 model. Optimized for edge devices and mobile deployment. |
| rwkv7_g1a_0.3b_en | 400.00M | 400 million parameter RWKV7 model. Small variant balancing speed and instruction following. |
token_embedding propertykeras_hub.models.RWKV7Backbone.token_embedding
A keras.layers.Embedding instance for embedding token ids.
This layer embeds integer token ids to the hidden dim of the model.