# %% Cell 7: Initialize SFTTrainer
from trl import SFTTrainer

trainer = SFTTrainer(
    model=model,
    tokenizer=tokenizer,
    train_dataset=dataset,
    dataset_text_field="text",
    max_seq_length=MAX_SEQ_LENGTH,
    args=args,
    packing=False,
)

print("✅ Trainer initialized.")
print(f"VRAM before training: {torch.cuda.memory_allocated() / 1024**3:.1f} GB")
print("\n→ Run Cell 8 to START TRAINING (takes hours).")
