easydel.modules.rwkv.modeling_rwkv_flax#
- class easydel.modules.rwkv.modeling_rwkv_flax.FlaxRwkvBlockCollection(config: easydel.modules.rwkv.rwkv_configuration.RwkvConfig, dtype: numpy.dtype = <class 'jax.numpy.float32'>, param_dtype: numpy.dtype = <class 'jax.numpy.float32'>, precision: Union[str, jax._src.lax.lax.Precision, NoneType] = None, parent: Union[flax.linen.module.Module, flax.core.scope.Scope, flax.linen.module._Sentinel, NoneType] = <flax.linen.module._Sentinel object at 0x7ec913f46950>, name: Optional[str] = None)[source]#
Bases:
Module- config: RwkvConfig#
- name: Optional[str] = None#
- parent: Optional[Union[Module, Scope, _Sentinel]] = None#
- setup() None[source]#
Initializes a Module lazily (similar to a lazy
__init__).setupis called once lazily on a module instance when a module is bound, immediately before any other methods like__call__are invoked, or before asetup-defined attribute onselfis accessed.This can happen in three cases:
Immediately when invoking
apply(),init()orinit_and_output().Once the module is given a name by being assigned to an attribute of another module inside the other module’s
setupmethod (see__setattr__()):>>> class MyModule(nn.Module): ... def setup(self): ... submodule = nn.Conv(...) ... # Accessing `submodule` attributes does not yet work here. ... # The following line invokes `self.__setattr__`, which gives ... # `submodule` the name "conv1". ... self.conv1 = submodule ... # Accessing `submodule` attributes or methods is now safe and ... # either causes setup() to be called once.
Once a module is constructed inside a method wrapped with
compact(), immediately before another method is called orsetupdefined attribute is accessed.
- class easydel.modules.rwkv.modeling_rwkv_flax.FlaxRwkvFeedForward(config: easydel.modules.rwkv.rwkv_configuration.RwkvConfig, layer_id: int, dtype: numpy.dtype = <class 'jax.numpy.float32'>, param_dtype: numpy.dtype = <class 'jax.numpy.float32'>, precision: Union[str, jax._src.lax.lax.Precision, NoneType] = None, parent: Union[flax.linen.module.Module, flax.core.scope.Scope, flax.linen.module._Sentinel, NoneType] = <flax.linen.module._Sentinel object at 0x7ec913f46950>, name: Optional[str] = None)[source]#
Bases:
Module- config: RwkvConfig#
- layer_id: int#
- name: Optional[str] = None#
- parent: Optional[Union[Module, Scope, _Sentinel]] = None#
- setup()[source]#
Initializes a Module lazily (similar to a lazy
__init__).setupis called once lazily on a module instance when a module is bound, immediately before any other methods like__call__are invoked, or before asetup-defined attribute onselfis accessed.This can happen in three cases:
Immediately when invoking
apply(),init()orinit_and_output().Once the module is given a name by being assigned to an attribute of another module inside the other module’s
setupmethod (see__setattr__()):>>> class MyModule(nn.Module): ... def setup(self): ... submodule = nn.Conv(...) ... # Accessing `submodule` attributes does not yet work here. ... # The following line invokes `self.__setattr__`, which gives ... # `submodule` the name "conv1". ... self.conv1 = submodule ... # Accessing `submodule` attributes or methods is now safe and ... # either causes setup() to be called once.
Once a module is constructed inside a method wrapped with
compact(), immediately before another method is called orsetupdefined attribute is accessed.
- class easydel.modules.rwkv.modeling_rwkv_flax.FlaxRwkvForCausalLM(config: easydel.modules.rwkv.rwkv_configuration.RwkvConfig, dtype: numpy.dtype = <class 'jax.numpy.float32'>, param_dtype: numpy.dtype = <class 'jax.numpy.float32'>, precision: Union[str, jax._src.lax.lax.Precision, NoneType] = None, parent: Union[flax.linen.module.Module, flax.core.scope.Scope, flax.linen.module._Sentinel, NoneType] = <flax.linen.module._Sentinel object at 0x7ec913f46950>, name: Optional[str] = None)[source]#
Bases:
Module- config: RwkvConfig#
- name: Optional[str] = None#
- parent: Optional[Union[Module, Scope, _Sentinel]] = None#
- setup()[source]#
Initializes a Module lazily (similar to a lazy
__init__).setupis called once lazily on a module instance when a module is bound, immediately before any other methods like__call__are invoked, or before asetup-defined attribute onselfis accessed.This can happen in three cases:
Immediately when invoking
apply(),init()orinit_and_output().Once the module is given a name by being assigned to an attribute of another module inside the other module’s
setupmethod (see__setattr__()):>>> class MyModule(nn.Module): ... def setup(self): ... submodule = nn.Conv(...) ... # Accessing `submodule` attributes does not yet work here. ... # The following line invokes `self.__setattr__`, which gives ... # `submodule` the name "conv1". ... self.conv1 = submodule ... # Accessing `submodule` attributes or methods is now safe and ... # either causes setup() to be called once.
Once a module is constructed inside a method wrapped with
compact(), immediately before another method is called orsetupdefined attribute is accessed.
- class easydel.modules.rwkv.modeling_rwkv_flax.FlaxRwkvModel(config: easydel.modules.rwkv.rwkv_configuration.RwkvConfig, dtype: numpy.dtype = <class 'jax.numpy.float32'>, param_dtype: numpy.dtype = <class 'jax.numpy.float32'>, precision: Union[str, jax._src.lax.lax.Precision, NoneType] = None, parent: Union[flax.linen.module.Module, flax.core.scope.Scope, flax.linen.module._Sentinel, NoneType] = <flax.linen.module._Sentinel object at 0x7ec913f46950>, name: Optional[str] = None)[source]#
Bases:
Module- config: RwkvConfig#
- name: Optional[str] = None#
- parent: Optional[Union[Module, Scope, _Sentinel]] = None#
- setup()[source]#
Initializes a Module lazily (similar to a lazy
__init__).setupis called once lazily on a module instance when a module is bound, immediately before any other methods like__call__are invoked, or before asetup-defined attribute onselfis accessed.This can happen in three cases:
Immediately when invoking
apply(),init()orinit_and_output().Once the module is given a name by being assigned to an attribute of another module inside the other module’s
setupmethod (see__setattr__()):>>> class MyModule(nn.Module): ... def setup(self): ... submodule = nn.Conv(...) ... # Accessing `submodule` attributes does not yet work here. ... # The following line invokes `self.__setattr__`, which gives ... # `submodule` the name "conv1". ... self.conv1 = submodule ... # Accessing `submodule` attributes or methods is now safe and ... # either causes setup() to be called once.
Once a module is constructed inside a method wrapped with
compact(), immediately before another method is called orsetupdefined attribute is accessed.
- class easydel.modules.rwkv.modeling_rwkv_flax.FlaxRwkvPretrainedModel(*args: Any, **kwargs: Any)[source]#
Bases:
EasyDeLBaseModule- config_class#
alias of
RwkvConfig
- generate(*args, **kwargs)[source]#
Generates sequences of token ids for models with a language modeling head.
- Parameters
input_ids (chex.Array of shape (batch_size, sequence_length)) – The sequence used as a prompt for the generation.
generation_config (~generation.GenerationConfig, optional) – The generation configuration to be used as base parametrization for the generation call. **kwargs passed to generate matching the attributes of generation_config will override them. If generation_config is not provided, the default will be used, which had the following loading priority: 1) from the generation_config.json model file, if it exists; 2) from the model configuration. Please note that unspecified parameters will inherit [~generation.GenerationConfig]’s default values, whose documentation should be checked to parameterize generation.
trace (bool, optional, defaults to True) – Whether to trace generation. Setting trace=False should only be used for debugging and will lead to a considerably slower runtime.
logits_processor (`FlaxLogitsProcessorList `, optional) – Custom logits processors that complement the default logits processors built from arguments and generation config. If a logit processor is passed that is already created with the arguments or a generation config an error is thrown. This feature is intended for advanced users.
kwargs (tp.Dict[str, Any], optional) – Ad hoc parametrization of generate_config and/or additional model-specific kwargs that will be forwarded to the forward function of the model. If the model is an encoder-decoder model, encoder specific kwargs should not be prefixed and decoder specific kwargs should be prefixed with decoder_.
- Returns
[~utils.ModelOutput].
- init_weights(rng: PRNGKey, input_shape: Tuple, params: FrozenDict = None) Union[FrozenDict[Any, Any], Mapping[str, Any], Any][source]#
- module_class: Module#
- prepare_inputs_for_generation(input_ids, state=None, inputs_embeds=None, **kwargs)[source]#
The prepare_inputs_for_generation function is used to prepare the inputs for a generation task.
- Parameters
self – Access variables that belong to the class
input_ids – Pass in the input tokens
max_length – Set the length of the sequence to be generated
attention_mask – tp.Optional[chex.Array]: Mask the attention weights
- Returns
A dictionary of the past_key_values, attention_mask and position ids
- class easydel.modules.rwkv.modeling_rwkv_flax.FlaxRwkvSelfAttention(config: easydel.modules.rwkv.rwkv_configuration.RwkvConfig, layer_id: int, dtype: numpy.dtype = <class 'jax.numpy.float32'>, param_dtype: numpy.dtype = <class 'jax.numpy.float32'>, precision: Union[str, jax._src.lax.lax.Precision, NoneType] = None, parent: Union[flax.linen.module.Module, flax.core.scope.Scope, flax.linen.module._Sentinel, NoneType] = <flax.linen.module._Sentinel object at 0x7ec913f46950>, name: Optional[str] = None)[source]#
Bases:
Module- config: RwkvConfig#
- layer_id: int#
- name: Optional[str] = None#
- parent: Optional[Union[Module, Scope, _Sentinel]] = None#
- setup() None[source]#
Initializes a Module lazily (similar to a lazy
__init__).setupis called once lazily on a module instance when a module is bound, immediately before any other methods like__call__are invoked, or before asetup-defined attribute onselfis accessed.This can happen in three cases:
Immediately when invoking
apply(),init()orinit_and_output().Once the module is given a name by being assigned to an attribute of another module inside the other module’s
setupmethod (see__setattr__()):>>> class MyModule(nn.Module): ... def setup(self): ... submodule = nn.Conv(...) ... # Accessing `submodule` attributes does not yet work here. ... # The following line invokes `self.__setattr__`, which gives ... # `submodule` the name "conv1". ... self.conv1 = submodule ... # Accessing `submodule` attributes or methods is now safe and ... # either causes setup() to be called once.
Once a module is constructed inside a method wrapped with
compact(), immediately before another method is called orsetupdefined attribute is accessed.
- class easydel.modules.rwkv.modeling_rwkv_flax.RwkvCausalLMOutput(logits: Union[jax.Array, numpy.ndarray, numpy.bool, numpy.number] = None, state: Optional[List[Union[jax.Array, numpy.ndarray, numpy.bool, numpy.number]]] = None, hidden_states: Optional[Tuple[Union[jax.Array, numpy.ndarray, numpy.bool, numpy.number], ...]] = None, attentions: Optional[Tuple[Union[jax.Array, numpy.ndarray, numpy.bool, numpy.number], ...]] = None)[source]#
Bases:
ModelOutput- replace(**updates)#
Returns a new object replacing the specified fields with new values.
- class easydel.modules.rwkv.modeling_rwkv_flax.RwkvOutput(last_hidden_state: Union[jax.Array, numpy.ndarray, numpy.bool, numpy.number] = None, state: Optional[Tuple[Union[jax.Array, numpy.ndarray, numpy.bool, numpy.number], ...]] = None, hidden_states: Optional[Tuple[Union[jax.Array, numpy.ndarray, numpy.bool, numpy.number], ...]] = None, attentions: Optional[Tuple[Union[jax.Array, numpy.ndarray, numpy.bool, numpy.number], ...]] = None)[source]#
Bases:
ModelOutput- replace(**updates)#
Returns a new object replacing the specified fields with new values.
- class easydel.modules.rwkv.modeling_rwkv_flax.SingleStandFlaxRwkvBlock(config: easydel.modules.rwkv.rwkv_configuration.RwkvConfig, layer_id: int, dtype: numpy.dtype = <class 'jax.numpy.float32'>, param_dtype: numpy.dtype = <class 'jax.numpy.float32'>, precision: Union[str, jax._src.lax.lax.Precision, NoneType] = None, parent: Union[flax.linen.module.Module, flax.core.scope.Scope, flax.linen.module._Sentinel, NoneType] = <flax.linen.module._Sentinel object at 0x7ec913f46950>, name: Optional[str] = None)[source]#
Bases:
Module- config: RwkvConfig#
- layer_id: int#
- name: Optional[str] = None#
- parent: Optional[Union[Module, Scope, _Sentinel]] = None#
- setup()[source]#
Initializes a Module lazily (similar to a lazy
__init__).setupis called once lazily on a module instance when a module is bound, immediately before any other methods like__call__are invoked, or before asetup-defined attribute onselfis accessed.This can happen in three cases:
Immediately when invoking
apply(),init()orinit_and_output().Once the module is given a name by being assigned to an attribute of another module inside the other module’s
setupmethod (see__setattr__()):>>> class MyModule(nn.Module): ... def setup(self): ... submodule = nn.Conv(...) ... # Accessing `submodule` attributes does not yet work here. ... # The following line invokes `self.__setattr__`, which gives ... # `submodule` the name "conv1". ... self.conv1 = submodule ... # Accessing `submodule` attributes or methods is now safe and ... # either causes setup() to be called once.
Once a module is constructed inside a method wrapped with
compact(), immediately before another method is called orsetupdefined attribute is accessed.