LLM#
- class BatchMultiHeadAttention(n_heads, d_model, d_value, d_key, masked=True, dropout_p=0.2, device='cpu')[source]#
Bases:
ModuleThis is more truthful to the paper
- forward(X: Tensor)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class BatchMultiHeadAttentionV2(n_heads, d_model, d_value, d_key, masked=True, dropout_p=0.2, device='cpu')[source]#
Bases:
ModuleThis is modern implementation for more efficient processing
- forward(X: Tensor)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class FFN(in_units, out_units, dropout_p=0.2, device='cpu')[source]#
Bases:
Module- forward(X)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class LLM(n_heads, d_model, d_key, d_value, n_x, vocab_size, dropout_p, device='cpu')[source]#
Bases:
Module- forward(X: Tensor)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class PositionalEncoding(d_model, context_len=10000, scale=10000, device='cpu')[source]#
Bases:
Module- forward(X)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class RepeatBlock(n_heads, d_model, d_key, d_value, device, dropout_p)[source]#
Bases:
Module- forward(X)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class Word2Vec(vocab_size, embedding_dims, device='cpu')[source]#
Bases:
Module- forward(X: Tensor)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.