Sin2pi commited on
Commit
71633df
·
verified ·
1 Parent(s): 4f942d7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +24 -34
README.md CHANGED
@@ -1,51 +1,41 @@
1
- Rotary embeddings with added rotation_dynamics is showing real promise.. Combo of these two:
 
2
 
 
 
3
 
 
 
4
 
5
- This is experimental code for the integration of different attention mechanisms in a transformer whisper-like model. Although everything runs and works, the code is not complete and is meant to be used as a reference for further development.
 
6
 
7
- The idea is to create a transformer model that can learn from different attention mechanisms and combine them to improve performance. This model includes the following attention mechanisms:
 
8
 
9
- 1. Dynamic Convolutional Attention
 
10
 
11
- 2. Hybrid Attention
 
12
 
13
- 3. Biased Attention
14
 
15
- 4. Augmented Memory
16
 
17
- 5. Rotary and Learned Sinusoidal Embeddings
18
 
19
- 6. Dynamic Attention Integration: A mechanism that dynamically weights and integrates the outputs of multiple attention mechanisms based on their relevance.
20
 
21
- 7. Rotation-Based Attention: Applied rotational dynamics to the attention mechanisms to reduce interference and enhance learning.
22
 
23
- Other components like LayerNorm, GroupNorm (RMS), custom linear and conv1 blocks, and MLP are also included to complete the transformer block. The code is written in PyTorch and is meant to be used as a reference for further development and experimentation. Training loop and data processing are included in PyTorch, with optional adaptation for Hugging Face Trainer and datasets. The code is not optimized and is meant for educational purposes only.
24
 
25
- The goal is to integrate these mechanisms into a single transformer block that can leverage the strengths of each attention mechanism to improve performance on various tasks.
26
 
27
- Natural Synergies and Integration Ideas for Future Stuff and Things:
28
- Dynamic Convolutional Attention and Hybrid Attention
29
 
30
- Natural Synergy: Dynamic convolutional attention can adapt convolutional filters based on the input, providing a local context that hybrid attention can leverage. Combining these can enhance both global and local context understanding.
31
 
32
- Integration Idea: Use dynamic convolutional attention within the local convolution part of the hybrid attention mechanism. This way, the dynamic adjustments made by the convolutional attention can be directly utilized by the hybrid attention layers.
33
 
34
- Biased Attention and Augmented Memory
35
-
36
- Natural Synergy: Biased attention can prioritize important features, while augmented memory can store and retrieve long-term dependencies. Together, they can ensure that important features are not only highlighted but also remembered over long sequences.
37
-
38
- Integration Idea: Embed bias terms in the augmented memory retrieval process, allowing the model to focus on and recall important features over extended periods.
39
-
40
- Rotary and Learned Sinusoidal Embeddings with Hybrid Attention
41
-
42
- Natural Synergy: Rotary and learned sinusoidal embeddings enhance positional encoding, which can be crucial for hybrid attention mechanisms that need to maintain the order of information while attending to both local and global contexts.
43
-
44
- Integration Idea: Apply rotary and learned sinusoidal embeddings within the hybrid attention layers to improve positional awareness and ensure the model accurately captures the order and structure of the input data.
45
-
46
- Enhancements to Rotary Embeddings
47
- Rotary Embeddings: We incorporated rotary embeddings to encode positional information into the queries and keys, helping the model capture the relative positions of tokens within a sequence.
48
-
49
- Rotational Dynamics Layer: We integrated a custom rotation layer that applies orthogonal transformations to the embeddings. This helps reduce interference between sensory inputs and memory representations by rotating the embeddings, which enhances the model’s ability to process and differentiate sequential data.
50
-
51
- Dynamic Integration of Attention Mechanisms: Introduced a mechanism that dynamically weights and integrates the outputs of multiple attention mechanisms based on their relevance and performance. This ensures that the model leverages the most effective attention mechanism for a given input, leading to more contextually appropriate and robust processing.
 
1
+ Dynamic Base Adjustment
2
+ Self-Adjusting Parameters: The model dynamically adjusts the base parameter in response to training loss, optimizing positional embeddings in real-time. This adaptive mechanism enhances the model's ability to fine-tune itself during training, ensuring better performance and efficiency.
3
 
4
+ RotaryEmbeddingWithRotation
5
+ Orthogonally Initialized Rotation Matrix: This component combines rotary embeddings with an orthogonally initialized rotation matrix, providing robust and stable positional embeddings. This novel approach enhances the model’s capacity to represent positional information effectively.
6
 
7
+ LearnedSinusoidalEmbeddings
8
+ Learned Sinusoidal Embeddings with Checkpointing: This unique integration of sinusoidal embeddings with optional checkpointing helps manage memory efficiently during training while maintaining stable embedding magnitudes through L2 normalization.
9
 
10
+ MultiHeadAttention
11
+ Dynamic Positional Bias: Supports rotary embeddings and includes relative positional bias, capturing dependencies effectively. The attention mechanism is finely tuned with a dynamically adjustable base parameter, providing flexibility and precision.
12
 
13
+ HybridAttention
14
+ Combining Local and Global Attention: This component leverages both local and global attention mechanisms, ensuring that the model captures both fine-grained and broad context. The sliding window approach for local attention enhances its ability to process long sequences efficiently.
15
 
16
+ DynamicConvAttention
17
+ Integrating Convolution and Attention: This component enriches feature representation by combining convolutional layers with attention mechanisms, enabling the model to extract local context while attending to global information simultaneously.
18
 
19
+ Model Components
20
+ LayerNorm: Custom normalization with gamma and beta parameters.
21
 
22
+ Linear: Custom linear layer with batch normalization and various activation functions.
23
 
24
+ Conv1d: Custom 1D convolution layer with Kaiming initialization.
25
 
26
+ RotaryEmbeddingWithRotation: Orthogonally initialized rotary embeddings with dynamic base adjustment.
27
 
28
+ LearnedSinusoidalEmbeddings: Sinusoidal embeddings with optional checkpointing and L2 normalization.
29
 
30
+ MultiHeadAttention: Dynamic positional bias with rotary embeddings and optional caching.
31
 
32
+ ResidualAttentionBlock: Integrates self and cross-attention with GELU-activated MLP.
33
 
34
+ AudioEncoder: Convolutional layers with learned sinusoidal embeddings and rotary embeddings.
35
 
36
+ TextDecoder: Token embeddings with rotary embeddings and cross-attention.
 
37
 
38
+ DynamicConvAttention: Combines convolution and attention for enriched feature extraction.
39
 
40
+ HybridAttention: Merges local and global attention mechanisms using sliding window and multi-head attention.
41