| | |
| | |
| | |
| |
|
| | from datasets import load_dataset |
| | from peft import LoraConfig |
| | from trl import SFTTrainer, SFTConfig |
| | import trackio |
| |
|
| | |
| | dataset = load_dataset("machina-sports/sportingbot-classification", split="train") |
| |
|
| | |
| | dataset_split = dataset.train_test_split(test_size=0.1, seed=42) |
| |
|
| | print(f"β
Dataset loaded: {len(dataset_split['train'])} train, {len(dataset_split['test'])} eval") |
| |
|
| | |
| | peft_config = LoraConfig( |
| | r=32, |
| | lora_alpha=64, |
| | target_modules="all-linear", |
| | lora_dropout=0.05, |
| | bias="none", |
| | task_type="CAUSAL_LM" |
| | ) |
| |
|
| | |
| | training_args = SFTConfig( |
| | output_dir="sportingbot-gemma-classifier", |
| |
|
| | |
| | push_to_hub=True, |
| | hub_model_id="fernando-machina/sportingbot-gemma-classifier", |
| | hub_strategy="every_save", |
| | hub_private_repo=False, |
| |
|
| | |
| | num_train_epochs=5, |
| | per_device_train_batch_size=2, |
| | gradient_accumulation_steps=4, |
| | learning_rate=0.0001, |
| |
|
| | |
| | bf16=True, |
| | gradient_checkpointing=True, |
| |
|
| | |
| | eval_strategy="steps", |
| | eval_steps=10, |
| |
|
| | |
| | save_strategy="steps", |
| | save_steps=50, |
| | save_total_limit=3, |
| |
|
| | |
| | logging_steps=5, |
| | report_to="trackio", |
| |
|
| | |
| | project="sportingbot-classification", |
| | run_name="gemma-2-2b-it-v1", |
| |
|
| | |
| | max_length=512, |
| | ) |
| |
|
| | print("π Starting training with Gemma 2-2B-it...") |
| |
|
| | |
| | trainer = SFTTrainer( |
| | model="google/gemma-2-2b-it", |
| | train_dataset=dataset_split["train"], |
| | eval_dataset=dataset_split["test"], |
| | peft_config=peft_config, |
| | args=training_args, |
| | ) |
| |
|
| | |
| | trainer.train() |
| |
|
| | print("β
Training complete! Pushing to Hub...") |
| |
|
| | |
| | trainer.push_to_hub() |
| |
|
| | print(f"π Model saved to: https://huggingface.co/fernando-machina/sportingbot-gemma-classifier") |
| |
|