Skip to content

Commit

Permalink
[NEW V] [Removal of Alibi+XPOS]
Browse files Browse the repository at this point in the history
  • Loading branch information
Kye committed Dec 24, 2023
1 parent f7a008b commit dbffc20
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
20 changes: 10 additions & 10 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import torch
from gemini_torch.model import Gemini

# Initialize model
# Initialize model with smaller dimensions
model = Gemini(
num_tokens=50432,
max_seq_len=8192,
dim=2560,
depth=32,
dim_head=128,
heads=24,
max_seq_len=4096, # Reduced from 8192
dim=1280, # Reduced from 2560
depth=16, # Reduced from 32
dim_head=64, # Reduced from 128
heads=12, # Reduced from 24
use_abs_pos_emb=False,
alibi_pos_bias=True,
alibi_num_heads=12,
alibi_num_heads=6, # Reduced from 12
rotary_xpos=True,
attn_flash=True,
attn_kv_heads=2,
Expand All @@ -21,13 +21,13 @@
)

# Text shape: [batch, seq_len, dim]
text = torch.randint(0, 50432, (1, 8192))
text = torch.randint(0, 50432, (1, 4096)) # Reduced seq_len from 8192

# Img shape: [batch, channels, height, width]
img = torch.randn(1, 3, 256, 256)
img = torch.randn(1, 3, 128, 128) # Reduced height and width from 256

# Audio shape: [batch, audio_seq_len, dim]
audio = torch.randn(1, 128)
audio = torch.randn(1, 64) # Reduced audio_seq_len from 128

# Apply model to text and img
y = model(text, img, audio)
Expand Down
Empty file removed gemini_torch/audio_encoder_usm.py
Empty file.
6 changes: 0 additions & 6 deletions gemini_torch/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ def __init__(
dim_head=128,
heads=24,
use_abs_pos_emb=False,
alibi_pos_bias=True,
alibi_num_heads=12,
rotary_xpos=True,
attn_flash=True,
attn_kv_heads=2,
qk_norm=True,
Expand All @@ -74,9 +71,6 @@ def __init__(
depth=depth,
dim_head=dim_head,
heads=heads,
alibi_pos_bias=alibi_pos_bias,
alibi_num_heads=alibi_num_heads,
rotary_xpos=rotary_xpos,
attn_flash=attn_flash,
attn_kv_heads=attn_kv_heads,
qk_norm=qk_norm,
Expand Down
File renamed without changes.

0 comments on commit dbffc20

Please sign in to comment.