
* gemma2 fallback to dynamic cache * Update src/transformers/models/gemma2/modeling_gemma2.py Co-authored-by: Joao Gante <joaofranciscocardosogante@gmail.com> * Update src/transformers/models/gemma2/modeling_gemma2.py Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com> * raise error and dont fallback to dynamic cache * prev will break most forward calls/tests * Update src/transformers/models/gemma2/modeling_gemma2.py Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com> * update * fix copies --------- Co-authored-by: Joao Gante <joaofranciscocardosogante@gmail.com> Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
2.6 KiB
Gemma2
Overview
The Gemma2 model was proposed in Gemma2: Open Models Based on Gemini Technology and Research by Gemma2 Team, Google. Two Gemma2 models are released, with parameters sizes of 9 billion (9B) and 27 billion (27B).
The abstract from the blog post is the following:
Now we’re officially releasing Gemma 2 to researchers and developers globally. Available in both 9 billion (9B) and 27 billion (27B) parameter sizes, Gemma 2 is higher-performing and more efficient at inference than the first generation, with significant safety advancements built in. In fact, at 27B, it offers competitive alternatives to models more than twice its size, delivering the kind of performance that was only possible with proprietary models as recently as December.
Tips:
- The original checkpoints can be converted using the conversion script
src/transformers/models/Gemma2/convert_Gemma2_weights_to_hf.py
- Gemma2 uses sliding window attention every second layer, which makes it unsuitable for typical kv caching with [
~DynamicCache
] or tuples of tensors. To enable caching in Gemma2 forward call, you must initialize a [~HybridCache
] instance and pass it aspast_key_values
to the forward call. Note, that you also have to preparecache_position
if thepast_key_values
already contains previous keys and values.
This model was contributed by Arthur Zucker, Pedro Cuenca and Tom Arsen.
Gemma2Config
autodoc Gemma2Config
Gemma2Model
autodoc Gemma2Model - forward
Gemma2ForCausalLM
autodoc Gemma2ForCausalLM - forward
Gemma2ForSequenceClassification
autodoc Gemma2ForSequenceClassification - forward
Gemma2ForTokenClassification
autodoc Gemma2ForTokenClassification - forward