Skip to content

Code not rendered properly on SFT page #233

@ag-mout

Description

@ag-mout

Ready to put theory into practice? Here's a preview of what you'll build in the exercises. You can use either Python or CLI approach:
<frameworkcontent>
<pythontab>
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
from trl import SFTTrainer, SFTConfig
from datasets import load_dataset
import trackio as wandb
# Initialize experiment tracking
wandb.init(project="smollm3-sft", name="my-first-sft-run")
# Load SmolLM3 base model
model = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM3-3B-Base")
tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/SmolLM3-3B-Base")
# Load SmolTalk2 dataset
dataset = load_dataset("HuggingFaceTB/smoltalk2", "SFT")
# Configure training with Trackio integration
config = SFTConfig(
output_dir="./smollm3-finetuned",
per_device_train_batch_size=4,
learning_rate=5e-5,
max_steps=1000,
report_to="trackio", # Enable Trackio logging
)
# Train!
trainer = SFTTrainer(
model=model,
tokenizer=tokenizer,
train_dataset=dataset["train"],
args=config,
)
trainer.train()
```
</pythontab>
<clitab>
```bash
# Fine-tune SmolLM3 using TRL CLI with Trackio tracking
trl sft \
--model_name_or_path HuggingFaceTB/SmolLM3-3B-Base \
--dataset_name HuggingFaceTB/smoltalk2 \
--dataset_config SFT \
--output_dir ./smollm3-sft-model \
--per_device_train_batch_size 4 \
--learning_rate 5e-5 \
--max_steps 1000 \
--logging_steps 50 \
--save_steps 200 \
--report_to trackio \
--push_to_hub \
--hub_model_id your-username/smollm3-custom
```
</clitab>
</frameworkcontent>
## Severless Training Options

No code is displayed when reading on my phone:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions