Add main.py, README.md, config.json, training_args.json, model.safetensors
Browse files- README.md +12 -12
- config.json +7 -7
- main.py +9 -9
- model.safetensors +2 -2
- training_args.json +5 -5
README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
| 1 |
---
|
| 2 |
-
license:
|
| 3 |
tags:
|
| 4 |
- pytorch
|
| 5 |
-
-
|
| 6 |
- multitask
|
| 7 |
---
|
| 8 |
|
| 9 |
-
#
|
| 10 |
|
| 11 |
## Overview
|
| 12 |
|
| 13 |
-
|
| 14 |
|
| 15 |
## Repository status
|
| 16 |
|
|
@@ -24,16 +24,16 @@ This repository is a compact, custom PyTorch implementation of **Coca** for **Mu
|
|
| 24 |
|
| 25 |
| Item | Value |
|
| 26 |
|---|---|
|
| 27 |
-
| Architecture |
|
| 28 |
-
| Scale |
|
| 29 |
-
| Attention |
|
| 30 |
-
| Fusion |
|
| 31 |
-
| Activation |
|
| 32 |
-
| Normalization |
|
| 33 |
|
| 34 |
## Default experiment recipe
|
| 35 |
|
| 36 |
-
The included configuration uses **
|
| 37 |
|
| 38 |
## Quick check
|
| 39 |
|
|
@@ -61,4 +61,4 @@ The initialization checkpoint has not been trained or audited for robustness, fa
|
|
| 61 |
|
| 62 |
## License
|
| 63 |
|
| 64 |
-
Released under **
|
|
|
|
| 1 |
---
|
| 2 |
+
license: mit
|
| 3 |
tags:
|
| 4 |
- pytorch
|
| 5 |
+
- mixer
|
| 6 |
- multitask
|
| 7 |
---
|
| 8 |
|
| 9 |
+
# Mixer for Multitask
|
| 10 |
|
| 11 |
## Overview
|
| 12 |
|
| 13 |
+
Working implementation of **Mixer** for **Multitask** using a **giant** configuration. The repository focuses on transparent code and repeatable smoke tests; benchmark claims are deliberately omitted.
|
| 14 |
|
| 15 |
## Repository status
|
| 16 |
|
|
|
|
| 24 |
|
| 25 |
| Item | Value |
|
| 26 |
|---|---|
|
| 27 |
+
| Architecture | Mixer |
|
| 28 |
+
| Scale | giant |
|
| 29 |
+
| Attention | linear |
|
| 30 |
+
| Fusion | low rank |
|
| 31 |
+
| Activation | mish |
|
| 32 |
+
| Normalization | scalenorm |
|
| 33 |
|
| 34 |
## Default experiment recipe
|
| 35 |
|
| 36 |
+
The included configuration uses **adafactor** with a **polynomial** schedule. These are starting values in the script, not evidence of a completed run. For a meaningful evaluation, train all baselines with the same data exposure, tuning budget, and random seeds.
|
| 37 |
|
| 38 |
## Quick check
|
| 39 |
|
|
|
|
| 61 |
|
| 62 |
## License
|
| 63 |
|
| 64 |
+
Released under **mit**. Review the source-data terms separately when this repository is used with external datasets.
|
config.json
CHANGED
|
@@ -2,13 +2,13 @@
|
|
| 2 |
"architectures": [
|
| 3 |
"CustomResearchModel"
|
| 4 |
],
|
| 5 |
-
"architecture": "
|
| 6 |
-
"model_type": "
|
| 7 |
-
"hidden_size":
|
| 8 |
-
"num_hidden_layers":
|
| 9 |
-
"num_attention_heads":
|
| 10 |
-
"intermediate_size":
|
| 11 |
-
"hidden_act": "
|
| 12 |
"max_position_embeddings": 128,
|
| 13 |
"layer_norm_eps": 1e-12,
|
| 14 |
"checkpoint_status": "initialization-only",
|
|
|
|
| 2 |
"architectures": [
|
| 3 |
"CustomResearchModel"
|
| 4 |
],
|
| 5 |
+
"architecture": "mixer",
|
| 6 |
+
"model_type": "mixer",
|
| 7 |
+
"hidden_size": 384,
|
| 8 |
+
"num_hidden_layers": 3,
|
| 9 |
+
"num_attention_heads": 8,
|
| 10 |
+
"intermediate_size": 1536,
|
| 11 |
+
"hidden_act": "mish",
|
| 12 |
"max_position_embeddings": 128,
|
| 13 |
"layer_norm_eps": 1e-12,
|
| 14 |
"checkpoint_status": "initialization-only",
|
main.py
CHANGED
|
@@ -3,14 +3,14 @@ import torch.nn as nn
|
|
| 3 |
import math
|
| 4 |
|
| 5 |
|
| 6 |
-
class
|
| 7 |
'''
|
| 8 |
-
|
| 9 |
-
Scale:
|
| 10 |
-
Fusion:
|
| 11 |
'''
|
| 12 |
|
| 13 |
-
def __init__(self, embed_dim=
|
| 14 |
super().__init__()
|
| 15 |
self.embed_dim = embed_dim
|
| 16 |
self.num_layers = num_layers
|
|
@@ -57,7 +57,7 @@ class CocaModel(nn.Module):
|
|
| 57 |
# task head
|
| 58 |
self.classifier = nn.Sequential(
|
| 59 |
nn.Linear(embed_dim, embed_dim),
|
| 60 |
-
nn.
|
| 61 |
nn.Dropout(0.1),
|
| 62 |
nn.Linear(embed_dim, num_classes),
|
| 63 |
)
|
|
@@ -67,7 +67,7 @@ class CocaModel(nn.Module):
|
|
| 67 |
def _initialize_weights(self):
|
| 68 |
for m in self.modules():
|
| 69 |
if isinstance(m, nn.Linear):
|
| 70 |
-
nn.init.
|
| 71 |
if m.bias is not None:
|
| 72 |
nn.init.zeros_(m.bias)
|
| 73 |
elif isinstance(m, nn.Embedding):
|
|
@@ -116,9 +116,9 @@ class CocaModel(nn.Module):
|
|
| 116 |
|
| 117 |
|
| 118 |
if __name__ == '__main__':
|
| 119 |
-
model =
|
| 120 |
total = sum(p.numel() for p in model.parameters())
|
| 121 |
-
print(f'
|
| 122 |
img = torch.randn(2, 3, 224, 224)
|
| 123 |
ids = torch.randint(0, 30522, (2, 128))
|
| 124 |
mask = torch.ones(2, 128)
|
|
|
|
| 3 |
import math
|
| 4 |
|
| 5 |
|
| 6 |
+
class MixerModel(nn.Module):
|
| 7 |
'''
|
| 8 |
+
mixer model with linear attention.
|
| 9 |
+
Scale: giant (dim=768, layers=16, heads=12)
|
| 10 |
+
Fusion: low_rank, Task: multitask
|
| 11 |
'''
|
| 12 |
|
| 13 |
+
def __init__(self, embed_dim=768, num_layers=16, num_heads=12, num_classes=10):
|
| 14 |
super().__init__()
|
| 15 |
self.embed_dim = embed_dim
|
| 16 |
self.num_layers = num_layers
|
|
|
|
| 57 |
# task head
|
| 58 |
self.classifier = nn.Sequential(
|
| 59 |
nn.Linear(embed_dim, embed_dim),
|
| 60 |
+
nn.Mish(),
|
| 61 |
nn.Dropout(0.1),
|
| 62 |
nn.Linear(embed_dim, num_classes),
|
| 63 |
)
|
|
|
|
| 67 |
def _initialize_weights(self):
|
| 68 |
for m in self.modules():
|
| 69 |
if isinstance(m, nn.Linear):
|
| 70 |
+
nn.init.xavier_uniform_(m.weight)
|
| 71 |
if m.bias is not None:
|
| 72 |
nn.init.zeros_(m.bias)
|
| 73 |
elif isinstance(m, nn.Embedding):
|
|
|
|
| 116 |
|
| 117 |
|
| 118 |
if __name__ == '__main__':
|
| 119 |
+
model = MixerModel()
|
| 120 |
total = sum(p.numel() for p in model.parameters())
|
| 121 |
+
print(f'MixerModel: {total:,} params ({total/1e6:.2f}M)')
|
| 122 |
img = torch.randn(2, 3, 224, 224)
|
| 123 |
ids = torch.randint(0, 30522, (2, 128))
|
| 124 |
mask = torch.ones(2, 128)
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1dd70963344440bec5121fc5474e381c88f953a52aa814c77796059529200833
|
| 3 |
+
size 198880
|
training_args.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
{
|
| 2 |
-
"optimizer": "
|
| 3 |
-
"scheduler": "
|
| 4 |
-
"learning_rate":
|
| 5 |
-
"batch_size":
|
| 6 |
-
"epochs":
|
| 7 |
"seed": 3407,
|
| 8 |
"status": "default recipe; not a completed run"
|
| 9 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"optimizer": "adafactor",
|
| 3 |
+
"scheduler": "polynomial",
|
| 4 |
+
"learning_rate": 0.0002,
|
| 5 |
+
"batch_size": 24,
|
| 6 |
+
"epochs": 30,
|
| 7 |
"seed": 3407,
|
| 8 |
"status": "default recipe; not a completed run"
|
| 9 |
}
|