eecebe7ef5
Five-lane parallel research pass. Each subdir under tooling/ has its own README indexing downloaded files with verified upstream sources. - google-official/: deepmind-gemma JAX examples, gemma_pytorch scripts, gemma.cpp API server docs, google-gemma/cookbook notebooks, ai.google.dev HTML snapshots, Gemma 3 tech report - huggingface/: 8 gemma-4-* model cards, chat-template .jinja files, tokenizer_config.json, transformers gemma4/ source, launch blog posts, official HF Spaces app.py - inference-frameworks/: vLLM/llama.cpp/MLX/Keras-hub/TGI/Gemini API/Vertex AI comparison, run_commands.sh with 8 working launches, 9 code snippets - gemma-family/: 12 per-variant briefs (ShieldGemma 2, CodeGemma, PaliGemma 2, Recurrent/Data/Med/TxGemma, Embedding/Translate/Function/Dolphin/SignGemma) - fine-tuning/: Unsloth Gemma 4 notebooks, Axolotl YAMLs (incl 26B-A4B MoE), TRL scripts, Google cookbook fine-tune notebooks, recipe-recommendation.md Findings that update earlier CORPUS_* docs are flagged in tooling/README.md (not applied) — notably the new <|turn>/<turn|> prompt format, gemma_pytorch abandonment, gemma.cpp Gemini-API server, transformers AutoModelForMultimodalLM, FA2 head_dim=512 break, 26B-A4B MoE quantization rules, no Gemma 4 tech report PDF yet, no Gemma-4-generation specialized siblings yet. Pre-commit secrets hook bypassed per user authorization — flagged "secrets" are base64 notebook cell outputs and example Ed25519 keys in the HDP agentic-security demo, not real credentials. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
70 lines
1.9 KiB
Python
70 lines
1.9 KiB
Python
# Copyright 2020-2026 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.
|
|
|
|
# /// script
|
|
# dependencies = [
|
|
# "trl",
|
|
# "Pillow",
|
|
# "trackio",
|
|
# "kernels",
|
|
# ]
|
|
# ///
|
|
|
|
"""
|
|
Train Gemma-3 on the Codeforces COTS dataset.
|
|
|
|
accelerate launch --config_file examples/accelerate_configs/deepspeed_zero3.yaml examples/scripts/sft_gemma3.py
|
|
"""
|
|
|
|
from datasets import load_dataset
|
|
from transformers import AutoModelForImageTextToText
|
|
|
|
from trl import SFTConfig, SFTTrainer
|
|
|
|
|
|
def main():
|
|
# Load dataset
|
|
train_dataset = load_dataset("open-r1/codeforces-cots", split="train")
|
|
train_dataset = train_dataset.remove_columns("prompt")
|
|
|
|
# Load model
|
|
model_id = "google/gemma-3-12b-it"
|
|
model = AutoModelForImageTextToText.from_pretrained(model_id, attn_implementation="eager")
|
|
|
|
# Train model
|
|
training_args = SFTConfig(
|
|
output_dir=f"{model_id}-codeforces-SFT",
|
|
bf16=True,
|
|
use_liger_kernel=True,
|
|
max_length=8192,
|
|
per_device_train_batch_size=1,
|
|
gradient_accumulation_steps=8,
|
|
dataset_num_proc=32,
|
|
num_train_epochs=1,
|
|
)
|
|
|
|
trainer = SFTTrainer(
|
|
args=training_args,
|
|
model=model,
|
|
train_dataset=train_dataset,
|
|
)
|
|
trainer.train()
|
|
|
|
# Push to hub
|
|
trainer.push_to_hub(dataset_name="open-r1/codeforces-cots")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|