Some checks failed
Self-hosted runner (nightly-past-ci-caller) / Get number (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.11 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.10 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.9 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.8 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.7 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.6 (push) Has been cancelled
Self-hosted runner (nightly-past-ci-caller) / TensorFlow 2.5 (push) Has been cancelled
Self-hosted runner (benchmark) / Benchmark (aws-g5-4xlarge-cache) (push) Has been cancelled
Build documentation / build (push) Has been cancelled
Build documentation / build_other_lang (push) Has been cancelled
CodeQL Security Analysis / CodeQL Analysis (push) Has been cancelled
New model PR merged notification / Notify new model (push) Has been cancelled
PR CI / pr-ci (push) Has been cancelled
Slow tests on important models (on Push - A10) / Get all modified files (push) Has been cancelled
Secret Leaks / trufflehog (push) Has been cancelled
Update Transformers metadata / build_and_package (push) Has been cancelled
Slow tests on important models (on Push - A10) / Model CI (push) Has been cancelled
Check Tiny Models / Check tiny models (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Model CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Pipeline CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Example CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / DeepSpeed CI (push) Has been cancelled
Self-hosted runner (Intel Gaudi3 scheduled CI caller) / Trainer/FSDP CI (push) Has been cancelled
Nvidia CI - Flash Attn / Setup (push) Has been cancelled
Nvidia CI - Flash Attn / Model CI (push) Has been cancelled
Nvidia CI / Setup (push) Has been cancelled
Nvidia CI / Model CI (push) Has been cancelled
Nvidia CI / Torch pipeline CI (push) Has been cancelled
Nvidia CI / Example CI (push) Has been cancelled
Nvidia CI / Trainer/FSDP CI (push) Has been cancelled
Nvidia CI / DeepSpeed CI (push) Has been cancelled
Nvidia CI / Quantization CI (push) Has been cancelled
Nvidia CI / Kernels CI (push) Has been cancelled
Doctests / Setup (push) Has been cancelled
Doctests / Call doctest jobs (push) Has been cancelled
Doctests / Send results to webhook (push) Has been cancelled
Extras Smoke Test / Get supported Python versions (push) Has been cancelled
Extras Smoke Test / Test extras on Python ${{ matrix.python-version }} (push) Has been cancelled
Extras Smoke Test / Check Slack token availability (push) Has been cancelled
Extras Smoke Test / Notify failures to Slack (push) Has been cancelled
Self-hosted runner (AMD scheduled CI caller) / Trigger Scheduled AMD CI (push) Has been cancelled
Stale Bot / Close Stale Issues (push) Has been cancelled
97 lines
3.4 KiB
Markdown
97 lines
3.4 KiB
Markdown
<!--Copyright 2025 the HuggingFace Team. All rights reserved.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
|
|
⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer.
|
|
|
|
-->
|
|
*This model was published in HF papers on 2016-07-01 and contributed to Hugging Face Transformers on 2025-09-12.*
|
|
|
|
# VaultGemma
|
|
|
|
## Overview
|
|
|
|
[VaultGemma](https://services.google.com/fh/files/blogs/vaultgemma_tech_report.pdf) is a text-only decoder model
|
|
derived from [Gemma 2](https://huggingface.co/docs/transformers/en/model_doc/gemma2), notably it drops the norms after
|
|
the Attention and MLP blocks, and uses full attention for all layers instead of alternating between full attention and
|
|
local sliding attention. VaultGemma is available as a pretrained model with 1B parameters that uses a 1024 token
|
|
sequence length.
|
|
|
|
VaultGemma was trained from scratch with sequence-level differential privacy (DP). Its training data includes the same
|
|
mixture as the [Gemma 2 models](https://huggingface.co/collections/google/gemma-2-release-667d6600fd5220e7b967f315),
|
|
consisting of a number of documents of varying lengths. Additionally, it is trained using
|
|
[DP stochastic gradient descent (DP-SGD)](https://huggingface.co/papers/1607.00133) and provides a
|
|
(ε ≤ 2.0, δ ≤ 1.1e-10)-sequence-level DP guarantee, where a sequence consists of 1024 consecutive tokens extracted from
|
|
heterogeneous data sources. Specifically, the privacy unit of the guarantee is for the sequences after sampling and
|
|
packing of the mixture.
|
|
|
|
> [!TIP]
|
|
> Click on the VaultGemma models in the right sidebar for more examples of how to apply VaultGemma to different language tasks.
|
|
|
|
The example below demonstrates how to chat with the model with [`Pipeline`], the [`AutoModel`] class, or from the
|
|
command line.
|
|
|
|
<hfoptions id="usage">
|
|
<hfoption id="Pipeline">
|
|
|
|
```python
|
|
from transformers import pipeline
|
|
|
|
|
|
pipe = pipeline(
|
|
task="text-generation",
|
|
model="google/vaultgemma-1b",
|
|
device_map="auto",
|
|
)
|
|
|
|
text = "Tell me an unknown interesting biology fact about the brain."
|
|
outputs = pipe(text, max_new_tokens=32)
|
|
response = outputs[0]["generated_text"]
|
|
print(response)
|
|
```
|
|
|
|
</hfoption>
|
|
<hfoption id="AutoModel">
|
|
|
|
```python
|
|
# pip install accelerate
|
|
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
|
|
model_id = "google/vaultgemma-1b"
|
|
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
|
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
|
|
|
|
text = "Tell me an unknown interesting biology fact about the brain."
|
|
input_ids = tokenizer(text, return_tensors="pt").to(model.device)
|
|
|
|
outputs = model.generate(**input_ids, max_new_tokens=32)
|
|
print(tokenizer.decode(outputs[0]))
|
|
```
|
|
|
|
</hfoption>
|
|
</hfoptions>
|
|
|
|
## VaultGemmaConfig
|
|
|
|
[[autodoc]] VaultGemmaConfig
|
|
|
|
## VaultGemmaModel
|
|
|
|
[[autodoc]] VaultGemmaModel
|
|
- forward
|
|
|
|
## VaultGemmaForCausalLM
|
|
|
|
[[autodoc]] VaultGemmaForCausalLM
|