Spaces:
Running
Running
improves launcher with model family and defaults based on options, updates trl trainer , removes trl config paths by switching to trainingarguments class , tokenizer parameters updated to sfttrainer , resolves evaluation_strategy error
Browse filesFiles changed (2)
- launch.sh+137-104
- scripts/training/train_gpt_oss.py+5-7
157 unmodified lines158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269515 unmodified lines785786787788789790791792793794795246 unmodified lines1042104310441045104610471048157 unmodified linesfi}# Function to show training configurationsshow_training_configs() {echo ""print_header "Available Training Configurations"echo "======================================"echo ""echo "=== SmolLM3 Configurations ==="echo "1. Basic Training (Default)"echo " - Model: SmolLM3-3B"echo " - Dataset: SmolTalk"echo " - Epochs: 3"echo " - Batch Size: 2"echo " - Learning Rate: 5e-6"echo ""echo "2. H100 Lightweight (Rapid)"echo " - Model: SmolLM3-3B"echo " - Dataset: OpenHermes-FR (80K samples)"echo " - Epochs: 1"echo " - Batch Size: 16"echo " - Learning Rate: 8e-6"echo " - Sequence Length: 8192"echo " - Optimized for H100 rapid training"echo ""echo "3. A100 Large Scale"echo " - Model: SmolLM3-3B"echo " - Dataset: OpenHermes-FR"echo " - Epochs: 1.3 passes"echo " - Batch Size: 8"echo " - Learning Rate: 5e-6"echo " - Sequence Length: 8192"echo ""echo "4. Multiple Passes"echo " - Model: SmolLM3-3B"echo " - Dataset: OpenHermes-FR"echo " - Epochs: 4 passes"echo " - Batch Size: 6"echo " - Learning Rate: 3e-6"echo " - Sequence Length: 8192"echo ""echo "=== GPT-OSS Configurations ==="echo "5. GPT-OSS Basic Training"echo " - Model: openai/gpt-oss-20b"echo " - Dataset: Multilingual-Thinking"echo " - Epochs: 1"echo " - Batch Size: 4"echo " - Learning Rate: 2e-4"echo " - LoRA + MXFP4 Quantization"echo " - Optimized for multilingual reasoning"echo ""echo "6. GPT-OSS H100 Optimized"echo " - Model: openai/gpt-oss-20b"echo " - Dataset: Multilingual-Thinking"echo " - Epochs: 2"echo " - Batch Size: 8"echo " - Learning Rate: 3e-4"echo " - Enhanced LoRA (rank 16)"echo " - Optimized for H100 performance"echo ""echo "7. GPT-OSS Multilingual Reasoning"echo " - Model: openai/gpt-oss-20b"echo " - Dataset: Multilingual-Thinking"echo " - Epochs: 1"echo " - Batch Size: 4"echo " - Learning Rate: 2e-4"echo " - Specialized for reasoning tasks"echo " - Supports 10+ languages"echo ""echo "8. GPT-OSS Memory Optimized"echo " - Model: openai/gpt-oss-20b"echo " - Dataset: Multilingual-Thinking"echo " - Epochs: 1"echo " - Batch Size: 1 (effective 16 with accumulation)"echo " - Learning Rate: 2e-4"echo " - 4-bit quantization + reduced LoRA"echo " - Optimized for limited GPU memory"echo ""echo "9. GPT-OSS OpenHermes-FR (Recommended)"echo " - Model: openai/gpt-oss-20b"echo " - Dataset: legmlai/openhermes-fr (800K French examples)"echo " - Epochs: 1.5"echo " - Batch Size: 6 (effective 36 with accumulation)"echo " - Learning Rate: 2.5e-4"echo " - Optimized for French language training"echo " - Quality filtering enabled"echo ""echo "10. GPT-OSS OpenHermes-FR Memory Optimized"echo " - Model: openai/gpt-oss-20b"echo " - Dataset: legmlai/openhermes-fr (200K samples)"echo " - Epochs: 1"echo " - Batch Size: 2 (effective 32 with accumulation)"echo " - Learning Rate: 2e-4"echo " - Native MXFP4 quantization"echo " - Memory optimized for 40-80GB GPUs"echo " - Harmony format compatible"echo ""echo "10. GPT-OSS Custom Dataset"echo " - Model: openai/gpt-oss-20b"echo " - Dataset: User-defined (fully customizable)"echo " - Epochs: Configurable"echo " - Batch Size: Configurable"echo " - Learning Rate: Configurable"echo " - Maximum flexibility with all parameters"echo ""echo "11. Custom Configuration"echo " - User-defined parameters"echo ""}# Function to get training configuration515 unmodified linesprint_step "Step 2: Training Configuration"echo "=================================="show_training_configsselect_option "Select training configuration:" "Basic Training" "H100 Lightweight (Rapid)" "A100 Large Scale" "Multiple Passes" "GPT-OSS Basic Training" "GPT-OSS H100 Optimized" "GPT-OSS Multilingual Reasoning" "GPT-OSS Memory Optimized" "GPT-OSS OpenHermes-FR (Recommended)" "GPT-OSS OpenHermes-FR Memory Optimized" "GPT-OSS Custom Dataset" "Custom Configuration" TRAINING_CONFIG_TYPEget_training_config "$TRAINING_CONFIG_TYPE"# Step 3: Get experiment detailsprint_step "Step 3: Experiment Details"echo "=============================="246 unmodified linesget_input "Author name for model card" "$HF_USERNAME" AUTHOR_NAMEprint_info "Model description will be used in the model card and repository."get_input "Model description" "A fine-tuned version of SmolLM3-3B for improved french language text generation and conversation capabilities." MODEL_DESCRIPTION# Step 9: Deploy Trackio Space (automated)print_step "Step 9: Deploying Trackio Space"157 unmodified lines158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273515 unmodified lines789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828246 unmodified lines1075107610771078107910801081157 unmodified linesfi}# Function to show training configurations (optionally filtered by family)show_training_configs() {local family="$1" # Optional: "SmolLM3" or "GPT-OSS"echo ""print_header "Available Training Configurations"echo "======================================"echo ""if [ -z "$family" ] || [ "$family" = "SmolLM3" ]; thenecho "=== SmolLM3 Configurations ==="echo "1. Basic Training (Default)"echo " - Model: SmolLM3-3B"echo " - Dataset: SmolTalk"echo " - Epochs: 3"echo " - Batch Size: 2"echo " - Learning Rate: 5e-6"echo ""echo "2. H100 Lightweight (Rapid)"echo " - Model: SmolLM3-3B"echo " - Dataset: OpenHermes-FR (80K samples)"echo " - Epochs: 1"echo " - Batch Size: 16"echo " - Learning Rate: 8e-6"echo " - Sequence Length: 8192"echo " - Optimized for H100 rapid training"echo ""echo "3. A100 Large Scale"echo " - Model: SmolLM3-3B"echo " - Dataset: OpenHermes-FR"echo " - Epochs: 1.3 passes"echo " - Batch Size: 8"echo " - Learning Rate: 5e-6"echo " - Sequence Length: 8192"echo ""echo "4. Multiple Passes"echo " - Model: SmolLM3-3B"echo " - Dataset: OpenHermes-FR"echo " - Epochs: 4 passes"echo " - Batch Size: 6"echo " - Learning Rate: 3e-6"echo " - Sequence Length: 8192"echo ""fiif [ -z "$family" ] || [ "$family" = "GPT-OSS" ]; thenecho "=== GPT-OSS Configurations ==="echo "1. GPT-OSS Basic Training"echo " - Model: openai/gpt-oss-20b"echo " - Dataset: Multilingual-Thinking"echo " - Epochs: 1"echo " - Batch Size: 4"echo " - Learning Rate: 2e-4"echo " - LoRA + MXFP4 Quantization"echo " - Optimized for multilingual reasoning"echo ""echo "2. GPT-OSS H100 Optimized"echo " - Model: openai/gpt-oss-20b"echo " - Dataset: Multilingual-Thinking"echo " - Epochs: 2"echo " - Batch Size: 8"echo " - Learning Rate: 3e-4"echo " - Enhanced LoRA (rank 16)"echo " - Optimized for H100 performance"echo ""echo "3. GPT-OSS Multilingual Reasoning"echo " - Model: openai/gpt-oss-20b"echo " - Dataset: Multilingual-Thinking"echo " - Epochs: 1"echo " - Batch Size: 4"echo " - Learning Rate: 2e-4"echo " - Specialized for reasoning tasks"echo " - Supports 10+ languages"echo ""echo "4. GPT-OSS Memory Optimized"echo " - Model: openai/gpt-oss-20b"echo " - Dataset: Multilingual-Thinking"echo " - Epochs: 1"echo " - Batch Size: 1 (effective 16 with accumulation)"echo " - Learning Rate: 2e-4"echo " - 4-bit quantization + reduced LoRA"echo " - Optimized for limited GPU memory"echo ""echo "5. GPT-OSS OpenHermes-FR (Recommended)"echo " - Model: openai/gpt-oss-20b"echo " - Dataset: legmlai/openhermes-fr (800K French examples)"echo " - Epochs: 1.5"echo " - Batch Size: 6 (effective 36 with accumulation)"echo " - Learning Rate: 2.5e-4"echo " - Optimized for French language training"echo " - Quality filtering enabled"echo ""echo "6. GPT-OSS OpenHermes-FR Memory Optimized"echo " - Model: openai/gpt-oss-20b"echo " - Dataset: legmlai/openhermes-fr (200K samples)"echo " - Epochs: 1"echo " - Batch Size: 2 (effective 32 with accumulation)"echo " - Learning Rate: 2e-4"echo " - Native MXFP4 quantization"echo " - Memory optimized for 40-80GB GPUs"echo " - Harmony format compatible"echo ""echo "7. GPT-OSS Custom Dataset"echo " - Model: openai/gpt-oss-20b"echo " - Dataset: User-defined (fully customizable)"echo " - Epochs: Configurable"echo " - Batch Size: Configurable"echo " - Learning Rate: Configurable"echo " - Maximum flexibility with all parameters"echo ""fi}# Function to get training configuration515 unmodified linesprint_step "Step 2: Training Configuration"echo "=================================="# 2.1 Select model family firstselect_option "Select model family:" "SmolLM3" "GPT-OSS" MODEL_FAMILY# 2.2 Show only the configurations for the selected family and prompt selectionshow_training_configs "$MODEL_FAMILY"if [ "$MODEL_FAMILY" = "SmolLM3" ]; thenselect_option "Select training configuration:" \"Basic Training" \"H100 Lightweight (Rapid)" \"A100 Large Scale" \"Multiple Passes" \"Custom Configuration" \TRAINING_CONFIG_TYPEelseselect_option "Select training configuration:" \"GPT-OSS Basic Training" \"GPT-OSS H100 Optimized" \"GPT-OSS Multilingual Reasoning" \"GPT-OSS Memory Optimized" \"GPT-OSS OpenHermes-FR (Recommended)" \"GPT-OSS OpenHermes-FR Memory Optimized" \"GPT-OSS Custom Dataset" \TRAINING_CONFIG_TYPEfiget_training_config "$TRAINING_CONFIG_TYPE"# 2.3 Set a family-specific default model description for the model cardif [ "$MODEL_FAMILY" = "GPT-OSS" ]; thenDEFAULT_MODEL_DESCRIPTION="A fine-tuned GPT-OSS-20B model optimized for multilingual reasoning and instruction following."elseDEFAULT_MODEL_DESCRIPTION="A fine-tuned SmolLM3-3B model optimized for instruction following and French language tasks."fi# Step 3: Get experiment detailsprint_step "Step 3: Experiment Details"echo "=============================="246 unmodified linesget_input "Author name for model card" "$HF_USERNAME" AUTHOR_NAMEprint_info "Model description will be used in the model card and repository."get_input "Model description" "$DEFAULT_MODEL_DESCRIPTION" MODEL_DESCRIPTION# Step 9: Deploy Trackio Space (automated)print_step "Step 9: Deploying Trackio Space"
8 unmodified lines91011121314151617335 unmodified lines35335435535635735835927 unmodified lines3873883893903913923931 unmodified line39539639739839940040140 unmodified lines44244344444544644744855 unmodified lines5045055065075085095108 unmodified linesimport sysimport argparseimport torchfrom transformers import AutoTokenizer, AutoModelForCausalLMfrom peft import LoraConfig, get_peft_modelfrom trl import SFTTrainer, SFTConfigfrom datasets import load_datasetfrom pathlib import Path335 unmodified lines# Learning rate configurationlearning_rate = config.learning_ratelr_scheduler_type = getattr(config, 'scheduler', 'cosine_with_min_lr')lr_scheduler_kwargs = getattr(config, 'lr_scheduler_kwargs', {"min_lr_rate": 0.1})# Batch configurationper_device_train_batch_size = config.batch_size27 unmodified linesprint(f" • Gradient accumulation: {gradient_accumulation_steps}")print(f" • Effective batch size: {per_device_train_batch_size * gradient_accumulation_steps}")sft_config = SFTConfig(# Training durationnum_train_epochs=num_train_epochs,max_steps=max_steps,1 unmodified line# Learning ratelearning_rate=learning_rate,lr_scheduler_type=lr_scheduler_type,lr_scheduler_kwargs=lr_scheduler_kwargs,warmup_ratio=warmup_ratio,warmup_steps=warmup_steps,40 unmodified linespush_to_hub=push_to_hub,# Monitoringreport_to="trackio" if getattr(config, 'enable_tracking', False) else None,)return sft_config55 unmodified linesmodel=peft_model,args=sft_config,train_dataset=dataset,processing_class=tokenizer,dataset_text_field="text",max_seq_length=getattr(config, 'max_seq_length', 2048),)8 unmodified lines91011121314151617335 unmodified lines35335435535635735827 unmodified lines3863873883893903913921 unmodified line39439539639739839940 unmodified lines44044144244344444544655 unmodified lines5025035045055065075088 unmodified linesimport sysimport argparseimport torchfrom transformers import AutoTokenizer, AutoModelForCausalLM, TrainingArgumentsfrom peft import LoraConfig, get_peft_modelfrom trl import SFTTrainerfrom datasets import load_datasetfrom pathlib import Path335 unmodified lines# Learning rate configurationlearning_rate = config.learning_ratelr_scheduler_type = getattr(config, 'scheduler', 'cosine_with_min_lr')# Batch configurationper_device_train_batch_size = config.batch_size27 unmodified linesprint(f" • Gradient accumulation: {gradient_accumulation_steps}")print(f" • Effective batch size: {per_device_train_batch_size * gradient_accumulation_steps}")sft_config = TrainingArguments(# Training durationnum_train_epochs=num_train_epochs,max_steps=max_steps,1 unmodified line# Learning ratelearning_rate=learning_rate,lr_scheduler_type=lr_scheduler_type,warmup_ratio=warmup_ratio,warmup_steps=warmup_steps,40 unmodified linespush_to_hub=push_to_hub,# Monitoringreport_to=("trackio" if getattr(config, 'enable_tracking', False) else None),)return sft_config55 unmodified linesmodel=peft_model,args=sft_config,train_dataset=dataset,tokenizer=tokenizer,dataset_text_field="text",max_seq_length=getattr(config, 'max_seq_length', 2048),)
launch.sh+137-104
scripts/training/train_gpt_oss.py+5-7