Commit 1fc7aaf
committed
Add Gemma 3 support for FunctionGemma and other Gemma 3 models
Gemma 3 architecture includes several key differences from Gemma v1:
- QK-norm (RMS normalization on query/key after projection)
- Pre/post FFN layer norms (pre_feedforward_layernorm, post_feedforward_layernorm)
- Different residual connection order (after post_attention_layernorm)
- Alternating local/global attention (sliding window)
- RMS norm with shift=1.0 formula: output * (1.0 + weight)
Files added:
- lib/bumblebee/text/gemma3.ex: Full Gemma 3 model implementation
- test/bumblebee/text/gemma3_test.exs: Unit tests
- notebooks/function_calling.livemd: Livebook with FunctionGemma examples
Files modified:
- lib/bumblebee.ex: Model and tokenizer registrations
- lib/bumblebee/layers/transformer.ex: Per-layer attention_window_size support1 parent 55ec9ac commit 1fc7aaf
File tree
5 files changed
+1363
-1
lines changed- lib
- bumblebee
- layers
- text
- notebooks
- test/bumblebee/text
5 files changed
+1363
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
140 | 147 | | |
141 | 148 | | |
142 | 149 | | |
| |||
249 | 256 | | |
250 | 257 | | |
251 | 258 | | |
| 259 | + | |
| 260 | + | |
252 | 261 | | |
253 | 262 | | |
254 | 263 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
28 | 35 | | |
29 | 36 | | |
30 | 37 | | |
| |||
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
55 | | - | |
56 | 62 | | |
57 | 63 | | |
58 | 64 | | |
| |||
64 | 70 | | |
65 | 71 | | |
66 | 72 | | |
| 73 | + | |
67 | 74 | | |
68 | 75 | | |
69 | 76 | | |
| |||
85 | 92 | | |
86 | 93 | | |
87 | 94 | | |
| 95 | + | |
88 | 96 | | |
89 | 97 | | |
90 | 98 | | |
| |||
121 | 129 | | |
122 | 130 | | |
123 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
124 | 141 | | |
125 | 142 | | |
126 | 143 | | |
| |||
134 | 151 | | |
135 | 152 | | |
136 | 153 | | |
| 154 | + | |
137 | 155 | | |
138 | 156 | | |
139 | 157 | | |
| |||
0 commit comments