Upload train_qwen3_codeforces.py with huggingface_hub
Browse files
train_qwen3_codeforces.py
CHANGED
|
@@ -10,6 +10,12 @@ from trl import SFTTrainer, SFTConfig
|
|
| 10 |
print("Loading dataset...")
|
| 11 |
dataset = load_dataset("open-r1/codeforces-cots", "solutions_py_decontaminated", split="train")
|
| 12 |
print(f"Dataset size: {len(dataset)} examples")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# Create train/eval split
|
| 15 |
dataset_split = dataset.train_test_split(test_size=0.05, seed=42)
|
|
@@ -25,7 +31,7 @@ peft_config = LoraConfig(
|
|
| 25 |
task_type="CAUSAL_LM",
|
| 26 |
)
|
| 27 |
|
| 28 |
-
# Training config
|
| 29 |
training_args = SFTConfig(
|
| 30 |
output_dir="qwen3-0.6b-codeforces-sft",
|
| 31 |
push_to_hub=True,
|
|
@@ -50,6 +56,7 @@ training_args = SFTConfig(
|
|
| 50 |
optim="adamw_torch_fused",
|
| 51 |
max_grad_norm=1.0,
|
| 52 |
max_length=2048,
|
|
|
|
| 53 |
)
|
| 54 |
|
| 55 |
# Initialize trainer
|
|
|
|
| 10 |
print("Loading dataset...")
|
| 11 |
dataset = load_dataset("open-r1/codeforces-cots", "solutions_py_decontaminated", split="train")
|
| 12 |
print(f"Dataset size: {len(dataset)} examples")
|
| 13 |
+
print(f"Columns: {dataset.column_names}")
|
| 14 |
+
|
| 15 |
+
# Check first example to understand structure
|
| 16 |
+
print(f"First example keys: {dataset[0].keys()}")
|
| 17 |
+
if "messages" in dataset.column_names:
|
| 18 |
+
print(f"Messages sample: {dataset[0]['messages'][:2] if len(dataset[0]['messages']) > 1 else dataset[0]['messages']}")
|
| 19 |
|
| 20 |
# Create train/eval split
|
| 21 |
dataset_split = dataset.train_test_split(test_size=0.05, seed=42)
|
|
|
|
| 31 |
task_type="CAUSAL_LM",
|
| 32 |
)
|
| 33 |
|
| 34 |
+
# Training config - using "messages" column for chat format
|
| 35 |
training_args = SFTConfig(
|
| 36 |
output_dir="qwen3-0.6b-codeforces-sft",
|
| 37 |
push_to_hub=True,
|
|
|
|
| 56 |
optim="adamw_torch_fused",
|
| 57 |
max_grad_norm=1.0,
|
| 58 |
max_length=2048,
|
| 59 |
+
dataset_text_field=None, # Use messages format
|
| 60 |
)
|
| 61 |
|
| 62 |
# Initialize trainer
|