跳到正文
cccskills
免费在 GitHub 公开

synthetic-data-finetuning-expert

Expert guide for synthetic dataset generation, LLM-as-a-judge filtering, QLoRA fine-tuning (Unsloth), DPO alignment, and GGUF/Ollama export for local SLMs / Panduan ahli generasi data sintetis, fine-tuning QLoRA, DPO, dan ekspor GGUF/Ollama.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md9.0 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Synthetic Data & Fine-Tuning Expert (Custom Domain SLMs)

English | Bahasa Indonesia


<a name="english"></a>

English

Orchestration & Integration

  • Local SLM & Quantization: local-slm-edge-ai-expert, wasm-edge-computing-expert
  • FinOps & Cost Optimization: llm-finops-router, adaptive-model-cascade, ai-llm-integration-expert
  • Prompting & Evals: ai-prompt-engineering-expert, structured-output-contracts, ai-safety-governance-expert
  • Python Pipelines & Tools: python-programming-expert, data-pipeline-etl-expert
  • Lifecycle & Governance: zero-to-prod-orchestrator, session-memory-manager, anti-slop

Description

Production-grade guide for generating synthetic training datasets, curating high-signal instruction pairs, executing Parameter-Efficient Fine-Tuning (QLoRA / LoRA) with Unsloth and Hugging Face TRL, performing Direct Preference Optimization (DPO), and quantizing custom Small Language Models (SLMs) to GGUF for edge or on-premise execution.

Swarm Synergy: Within the AI Engineering Swarm, this skill serves as the Model Specialization Lead. When frontier API costs or latency become prohibitive, it trains, aligns, and deploys hyper-efficient domain SLMs (1B–8B parameters) in Phase 4.

Trigger Conditions

  • Generating domain-specific synthetic training data from seed documents, codebases, or APIs.
  • Filtering low-quality or hallucinated synthetic data using LLM-as-a-judge curation pipelines.
  • Fine-tuning open-weights models (Llama 3.3, Qwen 2.5, Mistral) on custom tasks using 4-bit QLoRA.
  • Aligning model outputs using Direct Preference Optimization (DPO) to enforce specific response styles.
  • Quantizing fine-tuned models to GGUF (q4_k_m, q8_0) for zero-latency local inference with Ollama or llama.cpp.

Synthetic Data & Fine-Tuning Lifecycle

1. SEED EXTRACTION & SYNTHESIS
   [Raw Docs / Codebase] ──► [Frontier LLM / Distilabel] ──► Raw Instruction Pairs (10k+)

2. QUALITY FILTERING (LLM-AS-A-JUDGE)
   Raw Instruction Pairs ──► [Rubric Scorer / De-duplication] ──► Curated Gold Dataset (2k-5k)

3. 4-BIT QLORA FINE-TUNING (UNSLOTH)
   Base Model (e.g. Qwen 2.5-Coder) + LoRA Adapters ──► SFT / DPO Training Loop

4. QUANTIZATION & LOCAL DEPLOYMENT
   Merged 16-bit Weights ──► [llama.cpp GGUF Export] ──► Local Ollama Service (<50ms latency)

Core Implementation Guidelines

1. Synthetic Instruction Generation & Rejection Sampling

Use frontier models to generate input-output pairs with strict rejection criteria:

from pydantic import BaseModel, Field
from openai import OpenAI
import json

client = OpenAI()

class SyntheticInstructionPair(BaseModel):
    user_instruction: str = Field(description="Realistic developer query")
    input_context: str = Field(description="Code snippet or API contract")
    ground_truth_response: str = Field(description="Flawless, production-grade output")
    quality_score: int = Field(ge=1, le=5, description="Self-evaluated quality score")

def generate_synthetic_samples(seed_text: str) -> list[SyntheticInstructionPair]:
    # Availability Fallback Invariant: Gemini 4 Argon -> Gemini 3.8 Flash
    import os
    model_name = "gemini-4-argon" if os.getenv("FRONTIER_MODEL_AVAILABLE", "true") == "true" else "gemini-3.8-flash"
    try:
        response = client.beta.chat.completions.parse(
            model=model_name,
            messages=[
                {"role": "system", "content": "Generate 5 diverse, hard edge-case instruction pairs based on the seed code."},
                {"role": "user", "content": seed_text}
            ],
            response_format=SyntheticInstructionPair,
        )
    except Exception:
        response = client.beta.chat.completions.parse(
            model="gemini-3.8-flash",
            messages=[
                {"role": "system", "content": "Generate 5 diverse, hard edge-case instruction pairs based on the seed code."},
                {"role": "user", "content": seed_text}
            ],
            response_format=SyntheticInstructionPair,
        )
    # Filter out anything below score 4 (Rejection Sampling)
    return [sample for sample in [response.choices[0].message.parsed] if sample.quality_score >= 4]

2. High-Speed 4-Bit QLoRA with Unsloth

Fine-tune on consumer GPUs (e.g., RTX 3090/4090 or single A10G) with 5x faster throughput:

from unsloth import FastLanguageModel
import torch
from trl import SFTTrainer
from transformers import TrainingArguments

# 1. Load Model & Tokenizer in 4-bit
max_seq_length = 2048
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name="unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit",
    max_seq_length=max_seq_length,
    load_in_4bit=True,
)

# 2. Add LoRA Adapters
model = FastLanguageModel.get_peft_model(
    model,
    r=16,
    target_modules=["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"],
    lora_alpha=16,
    lora_dropout=0, # Optimized 0 dropout for Unsloth
    bias="none",
)

# 3. Supervised Fine-Tuning (SFT)
trainer = SFTTrainer(
    model=model,
    tokenizer=tokenizer,
    train_dataset=dataset,
    dataset_text_field="text",
    max_seq_length=max_seq_length,
    args=TrainingArguments(
        per_device_train_batch_size=2,
        gradient_accumulation_steps=4,
        warmup_steps=10,
        max_steps=100,
        learning_rate=2e-4,
        fp16=not torch.cuda.is_bf16_supported(),
        bf16=torch.cuda.is_bf16_supported(),
        logging_steps=1,
        output_dir="outputs",
    ),
)
trainer.train()

3. GGUF Export for Local Ollama Deployment

Export merged model to 4-bit or 8-bit quantized GGUF format:

# Save to 16bit or GGUF directly
model.save_pretrained_gguf("custom-domain-coder", tokenizer, quantization_method="q4_k_m")

# Generate Modelfile for Ollama:
# FROM ./custom-domain-coder-q4_k_m.gguf
# PARAMETER temperature 0.2
# SYSTEM You are an expert domain coder.

<a name="bahasa-indonesia"></a>

Bahasa Indonesia

Integrasi Orkestrasi

  • SLM Lokal & Kuantisasi: local-slm-edge-ai-expert, wasm-edge-computing-expert
  • FinOps & Optimasi Biaya: llm-finops-router, adaptive-model-cascade, ai-llm-integration-expert
  • Prompting & Evaluasi: ai-prompt-engineering-expert, structured-output-contracts, ai-safety-governance-expert
  • Pipeline Python & Tools: python-programming-expert, data-pipeline-etl-expert
  • Siklus Hidup & Tata Kelola: zero-to-prod-orchestrator, session-memory-manager, anti-slop

Deskripsi

Panduan produksi untuk menghasilkan dataset pelatihan sintetis, mengurasi pasangan instruksi bernilai tinggi, mengeksekusi Parameter-Efficient Fine-Tuning (QLoRA / LoRA) dengan Unsloth dan Hugging Face TRL, menerapkan Direct Preference Optimization (DPO), dan mengkuantisasi Small Language Models (SLM) kustom ke format GGUF untuk inferensi lokal atau on-premise berlatensi ultra-rendah.

Sinergi Swarm: Di dalam AI Engineering Swarm, skill ini memegang peranan sebagai Pemimpin Spesialisasi Model. Ketika biaya API atau latensi model cloud frontier terlalu tinggi, skill ini melatih, menyelaraskan (align), dan men-deploy SLM domain yang sangat efisien (1B–8B parameter) pada Fase 4.

Kondisi Pemicu

  • Menghasilkan data pelatihan sintetis spesifik domain dari dokumen panduan, codebase, atau skema API.
  • Menyaring data sintetis berkualitas rendah menggunakan pipeline penilaian otomatis LLM-as-a-judge.
  • Melakukan fine-tuning model berbobot terbuka (Llama 3.3, Qwen 2.5, Mistral) dengan QLoRA 4-bit secara hemat memori VRAM.
  • Menyelaraskan respon model dengan Direct Preference Optimization (DPO) agar mematuhi aturan format dan gaya tertentu.
  • Mengkuantisasi model hasil fine-tuning ke format GGUF (q4_k_m, q8_0) untuk inferensi lokal instan di Ollama atau llama.cpp.

Implementasi Pola Kunci (Python)

1. Fine-Tuning Cepat QLoRA 4-Bit dengan Unsloth

from unsloth import FastLanguageModel
import torch
from trl import SFTTrainer
from transformers import TrainingArguments

# 1. Muat Model dan Tokenizer dalam mode 4-bit hemat VRAM
panjang_maksimum = 2048
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name="unsloth/Qwen2.5-Coder-7B-Instruct-bnb-4bit",
    max_seq_length=panjang_maksimum,
    load_in_4bit=True,
)

# 2. Pasang Adapter PEFT LoRA
model = FastLanguageModel.get_peft_model(
    model,
    r=16,
    target_modules=["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"],
    lora_alpha=16,
    lora_dropout=0,
    bias="none",
)

# 3. Ekspor Langsung ke GGUF untuk Ollama Lokal
model.save_pretrained_gguf("model-koding-kustom", tokenizer, quantization_method="q4_k_m")

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Expert guide for automated and manual Web Accessibility (a11y) testing — axe-core, Pa11y, Playwright a11y, screen reader testing, and WCAG 2.2 Level AA/AAA compliance / Panduan ahli pengujian aksesibilitas web.

中文简介正在准备中。当前显示原文说明。

roedyrustam/vibes-plug1122026年10月22日 更新

Expert guide for intelligent model cascading and routing — complexity-scored task routing from Fast (Composer 2.5, Grok 4.7/4.6) to Medium (Gemini 4 Argon, GPT-5.6 Sol, Claude Opus 5.5) and High (Claude Sonnet 5.5, Claude Fable 5.1, Muse Wonder) / Panduan ahli untuk kaskade dan routing model cerdas.

中文简介正在准备中。当前显示原文说明。

roedyrustam/vibes-plug1122026年10月22日 更新

Expert guide for intelligent model cascading and routing — complexity-scored task routing from Flash/Haiku to Sonnet/Opus/Astra, dynamic escalation with quality gates, 40-60% token cost reduction while maintaining output quality / Panduan ahli untuk kaskade dan routing model cerdas — routing tugas berbasis skor kompleksitas dari Flash/Haiku ke Sonnet/Opus/Astra, eskalasi dinamis dengan gerbang kualitas, pengurangan biaya token 40-60% dengan kualitas output terjaga.

中文简介正在准备中。当前显示原文说明。

roedyrustam/vibes-plug1122026年10月22日 更新

Master guide for Affective Computing, emotional AI, and real-time sentiment analysis through native multimodal tokens (voice intonation and facial micro-expressions) / Panduan utama komputasi afektif, AI emosional, dan analisis sentimen real-time melalui token multimodal native.

中文简介正在准备中。当前显示原文说明。

roedyrustam/vibes-plug1122026年10月22日 更新

Expert guide for Affective Computing, emotional AI, and real-time sentiment analysis through native multimodal tokens (voice intonation and facial micro-expressions) / Panduan ahli komputasi afektif, AI emosional, dan analisis sentimen real-time melalui token multimodal native.

中文简介正在准备中。当前显示原文说明。

roedyrustam/vibes-plug1122026年10月22日 更新

Expert guide for AI-assisted coding workflows — agentic code generation, multi-agent code swarms, self-healing CI/CD, automated PR review, spec-to-code pipelines, codebase knowledge graphs, and human-in-the-loop approval gates / Panduan ahli untuk workflow pengkodean berbasis AI — generasi kode agentic, code swarm multi-agen, CI/CD self-healing, review PR otomatis, pipeline spec-to-code, knowledge graph codebase, dan gate persetujuan human-in-the-loop.

中文简介正在准备中。当前显示原文说明。

roedyrustam/vibes-plug1122026年10月22日 更新

查看 roedyrustam 的全部技能

报告此技能的问题