| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | import trackio |
| | from datasets import load_dataset |
| | from peft import LoraConfig |
| | from trl import SFTTrainer, SFTConfig |
| |
|
| | |
| | trackio.init( |
| | project="qwen-demo-sft", |
| | space_id="evalstate/trackio-demo", |
| | config={ |
| | "model": "Qwen/Qwen2.5-0.5B", |
| | "dataset": "trl-lib/Capybara", |
| | "dataset_size": 50, |
| | "learning_rate": 2e-5, |
| | "max_steps": 20, |
| | "demo": True, |
| | } |
| | ) |
| |
|
| | |
| | dataset = load_dataset("trl-lib/Capybara", split="train[:50]") |
| | print(f"β
Dataset loaded: {len(dataset)} examples") |
| | print(f"π Sample: {dataset[0]}") |
| |
|
| | |
| | config = SFTConfig( |
| | |
| | output_dir="qwen-demo-sft", |
| | push_to_hub=True, |
| | hub_model_id="evalstate/qwen-demo-sft", |
| | hub_strategy="end", |
| | |
| | |
| | max_steps=20, |
| | per_device_train_batch_size=2, |
| | gradient_accumulation_steps=2, |
| | learning_rate=2e-5, |
| | |
| | |
| | logging_steps=5, |
| | save_strategy="no", |
| | |
| | |
| | warmup_steps=5, |
| | lr_scheduler_type="cosine", |
| | |
| | |
| | report_to="trackio", |
| | ) |
| |
|
| | |
| | peft_config = LoraConfig( |
| | r=8, |
| | lora_alpha=16, |
| | lora_dropout=0.05, |
| | bias="none", |
| | task_type="CAUSAL_LM", |
| | target_modules=["q_proj", "v_proj"], |
| | ) |
| |
|
| | |
| | print("π Initializing trainer...") |
| | trainer = SFTTrainer( |
| | model="Qwen/Qwen2.5-0.5B", |
| | train_dataset=dataset, |
| | args=config, |
| | peft_config=peft_config, |
| | ) |
| |
|
| | |
| | print("π₯ Starting training (20 steps)...") |
| | trainer.train() |
| |
|
| | |
| | print("πΎ Pushing model to Hub...") |
| | trainer.push_to_hub() |
| |
|
| | |
| | trackio.finish() |
| |
|
| | print("β
Training complete!") |
| | print(f"π¦ Model: https://huggingface.co/evalstate/qwen-demo-sft") |
| | print(f"π Metrics: https://huggingface.co/spaces/evalstate/trackio-demo") |
| |
|