Skill Library

advanced Code Development

LLM Fine-Tuning Specialist

Fine-tune large language models with LoRA and QLoRA

When to Use This Skill

  • Domain adaptation
  • Task-specific optimization
  • Private data training
  • Cost-effective deployment

How to use this skill

1. Copy the AI Core Logic from the Instructions tab below.

2. Paste it into your AI's System Instructions or as your first message.

3. Provide your raw data or requirements as requested by the AI.

#llm#fine-tuning#ml#training

System Directives

## Fine-Tuning Implementation ### LoRA Setup with PEFT ```python from transformers import AutoModelForCausalLM, AutoTokenizer, TrainingArguments from peft import LoraConfig, get_peft_model, TaskType from trl import SFTTrainer model = AutoModelForCausalLM.from_pretrained( "meta-llama/Llama-2-7b-hf", torch_dtype=torch.float16, device_map="auto" ) lora_config = LoraConfig( r=16, lora_alpha=32, target_modules=["q_proj", "v_proj", "k_proj", "o_proj"], lora_dropout=0.05, bias="none", task_type=TaskType.CAUSAL_LM ) model = get_peft_model(model, lora_config) model.print_trainable_parameters() training_args = TrainingArguments( output_dir="./results", num_train_epochs=3, per_device_train_batch_size=4, gradient_accumulation_steps=4, learning_rate=2e-4, fp16=True, logging_steps=10, save_strategy="epoch" ) trainer = SFTTrainer( model=model, train_dataset=dataset, tokenizer=tokenizer, args=training_args ) trainer.train() ``` ### QLoRA for Large Models ```python from transformers import BitsAndBytesConfig bnb_config = BitsAndBytesConfig( load_in_4bit=True, bnb_4bit_use_double_quant=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype=torch.bfloat16 ) model = AutoModelForCausalLM.from_pretrained( "meta-llama/Llama-2-70b-hf", quantization_config=bnb_config, device_map="auto" ) ``` ## Best Practices - Use appropriate learning rates (1e-4 to 1e-3 for LoRA) - Monitor for overfitting - Validate on held-out data - Merge adapters for inference speed

Procedural Integration

This skill is formatted as a set of persistent system instructions. When integrated, it provides the AI model with specialized workflows and knowledge constraints for Code Development.

Skill Actions


Model Compatibility
🤖 Claude Opus🧠 GPT-4
Code Execution: Optional
MCP Tools: Optional
Footprint ~499 tokens