nitinchat82 commited on
Commit
376fa18
·
verified ·
1 Parent(s): 38af570

Add main.py, README.md, config.json, training_args.json, model.safetensors

Browse files
Files changed (5) hide show
  1. README.md +12 -12
  2. config.json +7 -7
  3. main.py +9 -9
  4. model.safetensors +2 -2
  5. training_args.json +5 -5
README.md CHANGED
@@ -1,16 +1,16 @@
1
  ---
2
- license: bsd-3-clause
3
  tags:
4
  - pytorch
5
- - coca
6
  - multitask
7
  ---
8
 
9
- # Coca for Multitask
10
 
11
  ## Overview
12
 
13
- This repository is a compact, custom PyTorch implementation of **Coca** for **Multitask**. The **base** configuration is intended for code review, smoke tests, and small controlled experiments rather than as a production-ready pretrained release.
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 | Coca |
28
- | Scale | base |
29
- | Attention | dilated |
30
- | Fusion | bilinear |
31
- | Activation | gelu |
32
- | Normalization | groupnorm |
33
 
34
  ## Default experiment recipe
35
 
36
- The included configuration uses **novograd** with a **exponential** 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,4 +61,4 @@ The initialization checkpoint has not been trained or audited for robustness, fa
61
 
62
  ## License
63
 
64
- Released under **bsd-3-clause**. Review the source-data terms separately when this repository is used with external datasets.
 
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": "coca",
6
- "model_type": "coca",
7
- "hidden_size": 128,
8
- "num_hidden_layers": 6,
9
- "num_attention_heads": 2,
10
- "intermediate_size": 512,
11
- "hidden_act": "gelu",
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 CocaModel(nn.Module):
7
  '''
8
- coca model with dilated attention.
9
- Scale: base (dim=256, layers=6, heads=4)
10
- Fusion: bilinear, Task: multitask
11
  '''
12
 
13
- def __init__(self, embed_dim=256, num_layers=6, num_heads=4, num_classes=10):
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.GELU(),
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.trunc_normal_(m.weight, std=0.02)
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 = CocaModel()
120
  total = sum(p.numel() for p in model.parameters())
121
- print(f'CocaModel: {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)
 
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:4ed61401de9380bd9d9317060f5d36d1072a7a3801a494d8b1a066ef7470eeb6
3
- size 66784
 
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": "novograd",
3
- "scheduler": "exponential",
4
- "learning_rate": 5e-05,
5
- "batch_size": 32,
6
- "epochs": 10,
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
  }