[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KQKWEXEDSM6VF6P6SY2QC2":3,"skill-same:01M6KQKWEXEDSM6VF6P6SY2QC2":87},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":40,"linkOnly":41,"markdownContent":42,"markdownBody":43,"frontMatter":44,"refName":53,"commitSha":54,"skillDirectory":55,"forksCount":13,"repositoryHtmlUrl":56,"repositoryHomepageUrl":6,"ownerHtmlUrl":57,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":58,"install":59,"resources":72},"01M6KQKWEXEDSM6VF6P6SY2QC2","model-merging",null,"Merge multiple fine-tuned models using mergekit to combine capabilities without retraining. Use when creating specialized models by blending domain-specific expertise (math + coding + chat), improving performance beyond single models, or experimenting rapidly with model variants. Covers SLERP, TIES-Merging, DARE, Task Arithmetic, linear merging, and production deployment strategies.","endman100\u002Fskill-router-nexus","endman100","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F31997019?v=4","01M6KPDX17BYDWW4RRB0TNGGMX","01M6KPDX64Y2QBEWVFG5W5PWPF",0,"MIT","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FAI-Training\u002Fmodel-merging\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39],"model","Model Merging","Mergekit","when","variants","expertise","Multi-Capability","No Retraining","Model Fusion","Task Arithmetic","DARE","TIES","SLERP","performance","Emerging Techniques","fusion","strategies","specialized","math","Transformers","capabilities","merge","2026-11-10 10:12:30",false,"---\nname: model-merging\ndescription: Merge multiple fine-tuned models using mergekit to combine capabilities without retraining. Use when creating specialized models by blending domain-specific expertise (math + coding + chat), improving performance beyond single models, or experimenting rapidly with model variants. Covers SLERP, TIES-Merging, DARE, Task Arithmetic, linear merging, and production deployment strategies.\nversion: 1.0.0\nauthor: Orchestra Research\nlicense: MIT\ntags: [Emerging Techniques, Model Merging, Mergekit, SLERP, TIES, DARE, Task Arithmetic, Model Fusion, No Retraining, Multi-Capability, Arcee AI]\ndependencies: [mergekit, transformers, torch]\n---\n\n# Model Merging: Combining Pre-trained Models\n\n## When to Use This Skill\n\nUse Model Merging when you need to:\n- **Combine capabilities** from multiple fine-tuned models without retraining\n- **Create specialized models** by blending domain-specific expertise (math + coding + chat)\n- **Improve performance** beyond single models (often +5-10% on benchmarks)\n- **Reduce training costs** - no GPUs needed, merges run on CPU\n- **Experiment rapidly** - create new model variants in minutes, not days\n- **Preserve multiple skills** - merge without catastrophic forgetting\n\n**Success Stories**: Marcoro14-7B-slerp (best on Open LLM Leaderboard 02\u002F2024), many top HuggingFace models use merging\n\n**Tools**: mergekit (Arcee AI), LazyMergekit, Model Soup\n\n## Installation\n\n```bash\n# Install mergekit\ngit clone https:\u002F\u002Fgithub.com\u002Farcee-ai\u002Fmergekit.git\ncd mergekit\npip install -e .\n\n# Or via pip\npip install mergekit\n\n# Optional: Transformer library\npip install transformers torch\n```\n\n## Quick Start\n\n### Simple Linear Merge\n\n```yaml\n# config.yml - Merge two models with equal weights\nmerge_method: linear\nmodels:\n  - model: mistralai\u002FMistral-7B-v0.1\n    parameters:\n      weight: 0.5\n  - model: teknium\u002FOpenHermes-2.5-Mistral-7B\n    parameters:\n      weight: 0.5\ndtype: bfloat16\n```\n\n```bash\n# Run merge\nmergekit-yaml config.yml .\u002Fmerged-model --cuda\n\n# Use merged model\npython -m transformers.models.auto --model_name_or_path .\u002Fmerged-model\n```\n\n### SLERP Merge (Best for 2 Models)\n\n```yaml\n# config.yml - Spherical interpolation\nmerge_method: slerp\nslices:\n  - sources:\n      - model: mistralai\u002FMistral-7B-v0.1\n        layer_range: [0, 32]\n      - model: teknium\u002FOpenHermes-2.5-Mistral-7B\n        layer_range: [0, 32]\nparameters:\n  t: 0.5  # Interpolation factor (0=model1, 1=model2)\ndtype: bfloat16\n```\n\n## Core Concepts\n\n### 1. Merge Methods\n\n**Linear (Model Soup)**\n- Simple weighted average of parameters\n- Fast, works well for similar models\n- Can merge 2+ models\n\n```python\nmerged_weights = w1 * model1_weights + w2 * model2_weights + w3 * model3_weights\n# where w1 + w2 + w3 = 1\n```\n\n**SLERP (Spherical Linear Interpolation)**\n- Interpolates along sphere in weight space\n- Preserves magnitude of weight vectors\n- Best for merging 2 models\n- Smoother than linear\n\n```python\n# SLERP formula\nmerged = (sin((1-t)*θ) \u002F sin(θ)) * model1 + (sin(t*θ) \u002F sin(θ)) * model2\n# where θ = arccos(dot(model1, model2))\n# t ∈ [0, 1]\n```\n\n**Task Arithmetic**\n- Extract \"task vectors\" (fine-tuned - base)\n- Combine task vectors, add to base\n- Good for merging multiple specialized models\n\n```python\n# Task vector\ntask_vector = finetuned_model - base_model\n\n# Merge multiple task vectors\nmerged = base_model + α₁*task_vector₁ + α₂*task_vector₂\n```\n\n**TIES-Merging**\n- Task arithmetic + sparsification\n- Resolves sign conflicts in parameters\n- Best for merging many task-specific models\n\n**DARE (Drop And REscale)**\n- Randomly drops fine-tuned parameters\n- Rescales remaining parameters\n- Reduces redundancy, maintains performance\n\n### 2. Configuration Structure\n\n```yaml\n# Basic structure\nmerge_method: \u003Cmethod>  # linear, slerp, ties, dare_ties, task_arithmetic\nbase_model: \u003Cpath>      # Optional: base model for task arithmetic\n\nmodels:\n  - model: \u003Cpath\u002Fto\u002Fmodel1>\n    parameters:\n      weight: \u003Cfloat>   # Merge weight\n      density: \u003Cfloat>  # For TIES\u002FDARE\n\n  - model: \u003Cpath\u002Fto\u002Fmodel2>\n    parameters:\n      weight: \u003Cfloat>\n\nparameters:\n  # Method-specific parameters\n\ndtype: \u003Cdtype>  # bfloat16, float16, float32\n\n# Optional\nslices:  # Layer-wise merging\ntokenizer:  # Tokenizer configuration\n```\n\n## Merge Methods Guide\n\n### Linear Merge\n\n**Best for**: Simple model combinations, equal weighting\n\n```yaml\nmerge_method: linear\nmodels:\n  - model: WizardLM\u002FWizardMath-7B-V1.1\n    parameters:\n      weight: 0.4\n  - model: teknium\u002FOpenHermes-2.5-Mistral-7B\n    parameters:\n      weight: 0.3\n  - model: NousResearch\u002FNous-Hermes-2-Mistral-7B-DPO\n    parameters:\n      weight: 0.3\ndtype: bfloat16\n```\n\n### SLERP Merge\n\n**Best for**: Two models, smooth interpolation\n\n```yaml\nmerge_method: slerp\nslices:\n  - sources:\n      - model: mistralai\u002FMistral-7B-v0.1\n        layer_range: [0, 32]\n      - model: teknium\u002FOpenHermes-2.5-Mistral-7B\n        layer_range: [0, 32]\nparameters:\n  t: 0.5  # 0.0 = first model, 1.0 = second model\ndtype: bfloat16\n```\n\n**Layer-specific SLERP:**\n\n```yaml\nmerge_method: slerp\nslices:\n  - sources:\n      - model: model_a\n        layer_range: [0, 32]\n      - model: model_b\n        layer_range: [0, 32]\nparameters:\n  t:\n    - filter: self_attn    # Attention layers\n      value: 0.3\n    - filter: mlp          # MLP layers\n      value: 0.7\n    - value: 0.5           # Default for other layers\ndtype: bfloat16\n```\n\n### Task Arithmetic\n\n**Best for**: Combining specialized skills\n\n```yaml\nmerge_method: task_arithmetic\nbase_model: mistralai\u002FMistral-7B-v0.1\nmodels:\n  - model: WizardLM\u002FWizardMath-7B-V1.1  # Math\n    parameters:\n      weight: 0.5\n  - model: teknium\u002FOpenHermes-2.5-Mistral-7B  # Chat\n    parameters:\n      weight: 0.3\n  - model: ajibawa-2023\u002FCode-Mistral-7B  # Code\n    parameters:\n      weight: 0.2\ndtype: bfloat16\n```\n\n### TIES-Merging\n\n**Best for**: Many models, resolving conflicts\n\n```yaml\nmerge_method: ties\nbase_model: mistralai\u002FMistral-7B-v0.1\nmodels:\n  - model: WizardLM\u002FWizardMath-7B-V1.1\n    parameters:\n      density: 0.5  # Keep top 50% of parameters\n      weight: 1.0\n  - model: teknium\u002FOpenHermes-2.5-Mistral-7B\n    parameters:\n      density: 0.5\n      weight: 1.0\n  - model: NousResearch\u002FNous-Hermes-2-Mistral-7B-DPO\n    parameters:\n      density: 0.5\n      weight: 1.0\nparameters:\n  normalize: true\ndtype: bfloat16\n```\n\n### DARE Merge\n\n**Best for**: Reducing redundancy\n\n```yaml\nmerge_method: dare_ties\nbase_model: mistralai\u002FMistral-7B-v0.1\nmodels:\n  - model: WizardLM\u002FWizardMath-7B-V1.1\n    parameters:\n      density: 0.5    # Drop 50% of deltas\n      weight: 0.6\n  - model: teknium\u002FOpenHermes-2.5-Mistral-7B\n    parameters:\n      density: 0.5\n      weight: 0.4\nparameters:\n  int8_mask: true  # Use int8 for masks (saves memory)\ndtype: bfloat16\n```\n\n## Advanced Patterns\n\n### Layer-wise Merging\n\n```yaml\n# Different models for different layers\nmerge_method: passthrough\nslices:\n  - sources:\n      - model: mistralai\u002FMistral-7B-v0.1\n        layer_range: [0, 16]   # First half\n  - sources:\n      - model: teknium\u002FOpenHermes-2.5-Mistral-7B\n        layer_range: [16, 32]  # Second half\ndtype: bfloat16\n```\n\n### MoE from Merged Models\n\n```yaml\n# Create Mixture of Experts\nmerge_method: moe\nbase_model: mistralai\u002FMistral-7B-v0.1\nexperts:\n  - source_model: WizardLM\u002FWizardMath-7B-V1.1\n    positive_prompts:\n      - \"math\"\n      - \"calculate\"\n  - source_model: teknium\u002FOpenHermes-2.5-Mistral-7B\n    positive_prompts:\n      - \"chat\"\n      - \"conversation\"\n  - source_model: ajibawa-2023\u002FCode-Mistral-7B\n    positive_prompts:\n      - \"code\"\n      - \"python\"\ndtype: bfloat16\n```\n\n### Tokenizer Merging\n\n```yaml\nmerge_method: linear\nmodels:\n  - model: mistralai\u002FMistral-7B-v0.1\n  - model: custom\u002Fspecialized-model\n\ntokenizer:\n  source: \"union\"  # Combine vocabularies from both models\n  tokens:\n    \u003C|special_token|>:\n      source: \"custom\u002Fspecialized-model\"\n```\n\n## Best Practices\n\n### 1. Model Compatibility\n\n```python\n# ✅ Good: Same architecture\nmodels = [\n    \"mistralai\u002FMistral-7B-v0.1\",\n    \"teknium\u002FOpenHermes-2.5-Mistral-7B\",  # Both Mistral 7B\n]\n\n# ❌ Bad: Different architectures\nmodels = [\n    \"meta-llama\u002FLlama-2-7b-hf\",  # Llama\n    \"mistralai\u002FMistral-7B-v0.1\",  # Mistral (incompatible!)\n]\n```\n\n### 2. Weight Selection\n\n```yaml\n# ✅ Good: Weights sum to 1.0\nmodels:\n  - model: model_a\n    parameters:\n      weight: 0.6\n  - model: model_b\n    parameters:\n      weight: 0.4  # 0.6 + 0.4 = 1.0\n\n# ⚠️  Acceptable: Weights don't sum to 1 (for task arithmetic)\nmodels:\n  - model: model_a\n    parameters:\n      weight: 0.8\n  - model: model_b\n    parameters:\n      weight: 0.8  # May boost performance\n```\n\n### 3. Method Selection\n\n```python\n# Choose merge method based on use case:\n\n# 2 models, smooth blend → SLERP\nmerge_method = \"slerp\"\n\n# 3+ models, simple average → Linear\nmerge_method = \"linear\"\n\n# Multiple task-specific models → Task Arithmetic or TIES\nmerge_method = \"ties\"\n\n# Want to reduce redundancy → DARE\nmerge_method = \"dare_ties\"\n```\n\n### 4. Density Tuning (TIES\u002FDARE)\n\n```yaml\n# Start conservative (keep more parameters)\nparameters:\n  density: 0.8  # Keep 80%\n\n# If performance good, increase sparsity\nparameters:\n  density: 0.5  # Keep 50%\n\n# If performance degrades, reduce sparsity\nparameters:\n  density: 0.9  # Keep 90%\n```\n\n### 5. Layer-specific Merging\n\n```yaml\n# Preserve base model's beginning and end\nmerge_method: passthrough\nslices:\n  - sources:\n      - model: base_model\n        layer_range: [0, 2]     # Keep first layers\n  - sources:\n      - model: merged_middle    # Merge middle layers\n        layer_range: [2, 30]\n  - sources:\n      - model: base_model\n        layer_range: [30, 32]   # Keep last layers\n```\n\n## Evaluation & Testing\n\n### Benchmark Merged Models\n\n```python\nfrom transformers import AutoModelForCausalLM, AutoTokenizer\n\n# Load merged model\nmodel = AutoModelForCausalLM.from_pretrained(\".\u002Fmerged-model\")\ntokenizer = AutoTokenizer.from_pretrained(\".\u002Fmerged-model\")\n\n# Test on various tasks\ntest_prompts = {\n    \"math\": \"Calculate: 25 * 17 =\",\n    \"code\": \"Write a Python function to reverse a string:\",\n    \"chat\": \"What is the capital of France?\",\n}\n\nfor task, prompt in test_prompts.items():\n    inputs = tokenizer(prompt, return_tensors=\"pt\")\n    outputs = model.generate(**inputs, max_length=100)\n    print(f\"{task}: {tokenizer.decode(outputs[0])}\")\n```\n\n### Common Benchmarks\n\n- **Open LLM Leaderboard**: General capabilities\n- **MT-Bench**: Multi-turn conversation\n- **MMLU**: Multitask accuracy\n- **HumanEval**: Code generation\n- **GSM8K**: Math reasoning\n\n## Production Deployment\n\n### Save and Upload\n\n```python\nfrom transformers import AutoModelForCausalLM, AutoTokenizer\n\n# Load merged model\nmodel = AutoModelForCausalLM.from_pretrained(\".\u002Fmerged-model\")\ntokenizer = AutoTokenizer.from_pretrained(\".\u002Fmerged-model\")\n\n# Upload to HuggingFace Hub\nmodel.push_to_hub(\"username\u002Fmy-merged-model\")\ntokenizer.push_to_hub(\"username\u002Fmy-merged-model\")\n```\n\n### Quantize Merged Model\n\n```bash\n# Quantize with GGUF\npython convert.py .\u002Fmerged-model --outtype f16 --outfile merged-model.gguf\n\n# Quantize with GPTQ\npython quantize_gptq.py .\u002Fmerged-model --bits 4 --group_size 128\n```\n\n## Common Pitfalls\n\n### ❌ Pitfall 1: Merging Incompatible Models\n\n```yaml\n# Wrong: Different architectures\nmodels:\n  - model: meta-llama\u002FLlama-2-7b  # Llama architecture\n  - model: mistralai\u002FMistral-7B   # Mistral architecture\n```\n\n**Fix**: Only merge models with same architecture\n\n### ❌ Pitfall 2: Over-weighting One Model\n\n```yaml\n# Suboptimal: One model dominates\nmodels:\n  - model: model_a\n    parameters:\n      weight: 0.95  # Too high\n  - model: model_b\n    parameters:\n      weight: 0.05  # Too low\n```\n\n**Fix**: Use more balanced weights (0.3-0.7 range)\n\n### ❌ Pitfall 3: Not Evaluating\n\n```bash\n# Wrong: Merge and deploy without testing\nmergekit-yaml config.yml .\u002Fmerged-model\n# Deploy immediately (risky!)\n```\n\n**Fix**: Always benchmark before deploying\n\n## Resources\n\n- **mergekit GitHub**: https:\u002F\u002Fgithub.com\u002Farcee-ai\u002Fmergekit\n- **HuggingFace Tutorial**: https:\u002F\u002Fhuggingface.co\u002Fblog\u002Fmlabonne\u002Fmerge-models\n- **LazyMergekit**: Automated merging notebook\n- **TIES Paper**: https:\u002F\u002Farxiv.org\u002Fabs\u002F2306.01708\n- **DARE Paper**: https:\u002F\u002Farxiv.org\u002Fabs\u002F2311.03099\n\n## See Also\n\n- `references\u002Fmethods.md` - Deep dive into merge algorithms\n- `references\u002Fexamples.md` - Real-world merge configurations\n- `references\u002Fevaluation.md` - Benchmarking and testing strategies\n\n\n","# Model Merging: Combining Pre-trained Models\n\n## When to Use This Skill\n\nUse Model Merging when you need to:\n- **Combine capabilities** from multiple fine-tuned models without retraining\n- **Create specialized models** by blending domain-specific expertise (math + coding + chat)\n- **Improve performance** beyond single models (often +5-10% on benchmarks)\n- **Reduce training costs** - no GPUs needed, merges run on CPU\n- **Experiment rapidly** - create new model variants in minutes, not days\n- **Preserve multiple skills** - merge without catastrophic forgetting\n\n**Success Stories**: Marcoro14-7B-slerp (best on Open LLM Leaderboard 02\u002F2024), many top HuggingFace models use merging\n\n**Tools**: mergekit (Arcee AI), LazyMergekit, Model Soup\n\n## Installation\n\n```bash\n# Install mergekit\ngit clone https:\u002F\u002Fgithub.com\u002Farcee-ai\u002Fmergekit.git\ncd mergekit\npip install -e .\n\n# Or via pip\npip install mergekit\n\n# Optional: Transformer library\npip install transformers torch\n```\n\n## Quick Start\n\n### Simple Linear Merge\n\n```yaml\n# config.yml - Merge two models with equal weights\nmerge_method: linear\nmodels:\n  - model: mistralai\u002FMistral-7B-v0.1\n    parameters:\n      weight: 0.5\n  - model: teknium\u002FOpenHermes-2.5-Mistral-7B\n    parameters:\n      weight: 0.5\ndtype: bfloat16\n```\n\n```bash\n# Run merge\nmergekit-yaml config.yml .\u002Fmerged-model --cuda\n\n# Use merged model\npython -m transformers.models.auto --model_name_or_path .\u002Fmerged-model\n```\n\n### SLERP Merge (Best for 2 Models)\n\n```yaml\n# config.yml - Spherical interpolation\nmerge_method: slerp\nslices:\n  - sources:\n      - model: mistralai\u002FMistral-7B-v0.1\n        layer_range: [0, 32]\n      - model: teknium\u002FOpenHermes-2.5-Mistral-7B\n        layer_range: [0, 32]\nparameters:\n  t: 0.5  # Interpolation factor (0=model1, 1=model2)\ndtype: bfloat16\n```\n\n## Core Concepts\n\n### 1. Merge Methods\n\n**Linear (Model Soup)**\n- Simple weighted average of parameters\n- Fast, works well for similar models\n- Can merge 2+ models\n\n```python\nmerged_weights = w1 * model1_weights + w2 * model2_weights + w3 * model3_weights\n# where w1 + w2 + w3 = 1\n```\n\n**SLERP (Spherical Linear Interpolation)**\n- Interpolates along sphere in weight space\n- Preserves magnitude of weight vectors\n- Best for merging 2 models\n- Smoother than linear\n\n```python\n# SLERP formula\nmerged = (sin((1-t)*θ) \u002F sin(θ)) * model1 + (sin(t*θ) \u002F sin(θ)) * model2\n# where θ = arccos(dot(model1, model2))\n# t ∈ [0, 1]\n```\n\n**Task Arithmetic**\n- Extract \"task vectors\" (fine-tuned - base)\n- Combine task vectors, add to base\n- Good for merging multiple specialized models\n\n```python\n# Task vector\ntask_vector = finetuned_model - base_model\n\n# Merge multiple task vectors\nmerged = base_model + α₁*task_vector₁ + α₂*task_vector₂\n```\n\n**TIES-Merging**\n- Task arithmetic + sparsification\n- Resolves sign conflicts in parameters\n- Best for merging many task-specific models\n\n**DARE (Drop And REscale)**\n- Randomly drops fine-tuned parameters\n- Rescales remaining parameters\n- Reduces redundancy, maintains performance\n\n### 2. Configuration Structure\n\n```yaml\n# Basic structure\nmerge_method: \u003Cmethod>  # linear, slerp, ties, dare_ties, task_arithmetic\nbase_model: \u003Cpath>      # Optional: base model for task arithmetic\n\nmodels:\n  - model: \u003Cpath\u002Fto\u002Fmodel1>\n    parameters:\n      weight: \u003Cfloat>   # Merge weight\n      density: \u003Cfloat>  # For TIES\u002FDARE\n\n  - model: \u003Cpath\u002Fto\u002Fmodel2>\n    parameters:\n      weight: \u003Cfloat>\n\nparameters:\n  # Method-specific parameters\n\ndtype: \u003Cdtype>  # bfloat16, float16, float32\n\n# Optional\nslices:  # Layer-wise merging\ntokenizer:  # Tokenizer configuration\n```\n\n## Merge Methods Guide\n\n### Linear Merge\n\n**Best for**: Simple model combinations, equal weighting\n\n```yaml\nmerge_method: linear\nmodels:\n  - model: WizardLM\u002FWizardMath-7B-V1.1\n    parameters:\n      weight: 0.4\n  - model: teknium\u002FOpenHermes-2.5-Mistral-7B\n    parameters:\n      weight: 0.3\n  - model: NousResearch\u002FNous-Hermes-2-Mistral-7B-DPO\n    parameters:\n      weight: 0.3\ndtype: bfloat16\n```\n\n### SLERP Merge\n\n**Best for**: Two models, smooth interpolation\n\n```yaml\nmerge_method: slerp\nslices:\n  - sources:\n      - model: mistralai\u002FMistral-7B-v0.1\n        layer_range: [0, 32]\n      - model: teknium\u002FOpenHermes-2.5-Mistral-7B\n        layer_range: [0, 32]\nparameters:\n  t: 0.5  # 0.0 = first model, 1.0 = second model\ndtype: bfloat16\n```\n\n**Layer-specific SLERP:**\n\n```yaml\nmerge_method: slerp\nslices:\n  - sources:\n      - model: model_a\n        layer_range: [0, 32]\n      - model: model_b\n        layer_range: [0, 32]\nparameters:\n  t:\n    - filter: self_attn    # Attention layers\n      value: 0.3\n    - filter: mlp          # MLP layers\n      value: 0.7\n    - value: 0.5           # Default for other layers\ndtype: bfloat16\n```\n\n### Task Arithmetic\n\n**Best for**: Combining specialized skills\n\n```yaml\nmerge_method: task_arithmetic\nbase_model: mistralai\u002FMistral-7B-v0.1\nmodels:\n  - model: WizardLM\u002FWizardMath-7B-V1.1  # Math\n    parameters:\n      weight: 0.5\n  - model: teknium\u002FOpenHermes-2.5-Mistral-7B  # Chat\n    parameters:\n      weight: 0.3\n  - model: ajibawa-2023\u002FCode-Mistral-7B  # Code\n    parameters:\n      weight: 0.2\ndtype: bfloat16\n```\n\n### TIES-Merging\n\n**Best for**: Many models, resolving conflicts\n\n```yaml\nmerge_method: ties\nbase_model: mistralai\u002FMistral-7B-v0.1\nmodels:\n  - model: WizardLM\u002FWizardMath-7B-V1.1\n    parameters:\n      density: 0.5  # Keep top 50% of parameters\n      weight: 1.0\n  - model: teknium\u002FOpenHermes-2.5-Mistral-7B\n    parameters:\n      density: 0.5\n      weight: 1.0\n  - model: NousResearch\u002FNous-Hermes-2-Mistral-7B-DPO\n    parameters:\n      density: 0.5\n      weight: 1.0\nparameters:\n  normalize: true\ndtype: bfloat16\n```\n\n### DARE Merge\n\n**Best for**: Reducing redundancy\n\n```yaml\nmerge_method: dare_ties\nbase_model: mistralai\u002FMistral-7B-v0.1\nmodels:\n  - model: WizardLM\u002FWizardMath-7B-V1.1\n    parameters:\n      density: 0.5    # Drop 50% of deltas\n      weight: 0.6\n  - model: teknium\u002FOpenHermes-2.5-Mistral-7B\n    parameters:\n      density: 0.5\n      weight: 0.4\nparameters:\n  int8_mask: true  # Use int8 for masks (saves memory)\ndtype: bfloat16\n```\n\n## Advanced Patterns\n\n### Layer-wise Merging\n\n```yaml\n# Different models for different layers\nmerge_method: passthrough\nslices:\n  - sources:\n      - model: mistralai\u002FMistral-7B-v0.1\n        layer_range: [0, 16]   # First half\n  - sources:\n      - model: teknium\u002FOpenHermes-2.5-Mistral-7B\n        layer_range: [16, 32]  # Second half\ndtype: bfloat16\n```\n\n### MoE from Merged Models\n\n```yaml\n# Create Mixture of Experts\nmerge_method: moe\nbase_model: mistralai\u002FMistral-7B-v0.1\nexperts:\n  - source_model: WizardLM\u002FWizardMath-7B-V1.1\n    positive_prompts:\n      - \"math\"\n      - \"calculate\"\n  - source_model: teknium\u002FOpenHermes-2.5-Mistral-7B\n    positive_prompts:\n      - \"chat\"\n      - \"conversation\"\n  - source_model: ajibawa-2023\u002FCode-Mistral-7B\n    positive_prompts:\n      - \"code\"\n      - \"python\"\ndtype: bfloat16\n```\n\n### Tokenizer Merging\n\n```yaml\nmerge_method: linear\nmodels:\n  - model: mistralai\u002FMistral-7B-v0.1\n  - model: custom\u002Fspecialized-model\n\ntokenizer:\n  source: \"union\"  # Combine vocabularies from both models\n  tokens:\n    \u003C|special_token|>:\n      source: \"custom\u002Fspecialized-model\"\n```\n\n## Best Practices\n\n### 1. Model Compatibility\n\n```python\n# ✅ Good: Same architecture\nmodels = [\n    \"mistralai\u002FMistral-7B-v0.1\",\n    \"teknium\u002FOpenHermes-2.5-Mistral-7B\",  # Both Mistral 7B\n]\n\n# ❌ Bad: Different architectures\nmodels = [\n    \"meta-llama\u002FLlama-2-7b-hf\",  # Llama\n    \"mistralai\u002FMistral-7B-v0.1\",  # Mistral (incompatible!)\n]\n```\n\n### 2. Weight Selection\n\n```yaml\n# ✅ Good: Weights sum to 1.0\nmodels:\n  - model: model_a\n    parameters:\n      weight: 0.6\n  - model: model_b\n    parameters:\n      weight: 0.4  # 0.6 + 0.4 = 1.0\n\n# ⚠️  Acceptable: Weights don't sum to 1 (for task arithmetic)\nmodels:\n  - model: model_a\n    parameters:\n      weight: 0.8\n  - model: model_b\n    parameters:\n      weight: 0.8  # May boost performance\n```\n\n### 3. Method Selection\n\n```python\n# Choose merge method based on use case:\n\n# 2 models, smooth blend → SLERP\nmerge_method = \"slerp\"\n\n# 3+ models, simple average → Linear\nmerge_method = \"linear\"\n\n# Multiple task-specific models → Task Arithmetic or TIES\nmerge_method = \"ties\"\n\n# Want to reduce redundancy → DARE\nmerge_method = \"dare_ties\"\n```\n\n### 4. Density Tuning (TIES\u002FDARE)\n\n```yaml\n# Start conservative (keep more parameters)\nparameters:\n  density: 0.8  # Keep 80%\n\n# If performance good, increase sparsity\nparameters:\n  density: 0.5  # Keep 50%\n\n# If performance degrades, reduce sparsity\nparameters:\n  density: 0.9  # Keep 90%\n```\n\n### 5. Layer-specific Merging\n\n```yaml\n# Preserve base model's beginning and end\nmerge_method: passthrough\nslices:\n  - sources:\n      - model: base_model\n        layer_range: [0, 2]     # Keep first layers\n  - sources:\n      - model: merged_middle    # Merge middle layers\n        layer_range: [2, 30]\n  - sources:\n      - model: base_model\n        layer_range: [30, 32]   # Keep last layers\n```\n\n## Evaluation & Testing\n\n### Benchmark Merged Models\n\n```python\nfrom transformers import AutoModelForCausalLM, AutoTokenizer\n\n# Load merged model\nmodel = AutoModelForCausalLM.from_pretrained(\".\u002Fmerged-model\")\ntokenizer = AutoTokenizer.from_pretrained(\".\u002Fmerged-model\")\n\n# Test on various tasks\ntest_prompts = {\n    \"math\": \"Calculate: 25 * 17 =\",\n    \"code\": \"Write a Python function to reverse a string:\",\n    \"chat\": \"What is the capital of France?\",\n}\n\nfor task, prompt in test_prompts.items():\n    inputs = tokenizer(prompt, return_tensors=\"pt\")\n    outputs = model.generate(**inputs, max_length=100)\n    print(f\"{task}: {tokenizer.decode(outputs[0])}\")\n```\n\n### Common Benchmarks\n\n- **Open LLM Leaderboard**: General capabilities\n- **MT-Bench**: Multi-turn conversation\n- **MMLU**: Multitask accuracy\n- **HumanEval**: Code generation\n- **GSM8K**: Math reasoning\n\n## Production Deployment\n\n### Save and Upload\n\n```python\nfrom transformers import AutoModelForCausalLM, AutoTokenizer\n\n# Load merged model\nmodel = AutoModelForCausalLM.from_pretrained(\".\u002Fmerged-model\")\ntokenizer = AutoTokenizer.from_pretrained(\".\u002Fmerged-model\")\n\n# Upload to HuggingFace Hub\nmodel.push_to_hub(\"username\u002Fmy-merged-model\")\ntokenizer.push_to_hub(\"username\u002Fmy-merged-model\")\n```\n\n### Quantize Merged Model\n\n```bash\n# Quantize with GGUF\npython convert.py .\u002Fmerged-model --outtype f16 --outfile merged-model.gguf\n\n# Quantize with GPTQ\npython quantize_gptq.py .\u002Fmerged-model --bits 4 --group_size 128\n```\n\n## Common Pitfalls\n\n### ❌ Pitfall 1: Merging Incompatible Models\n\n```yaml\n# Wrong: Different architectures\nmodels:\n  - model: meta-llama\u002FLlama-2-7b  # Llama architecture\n  - model: mistralai\u002FMistral-7B   # Mistral architecture\n```\n\n**Fix**: Only merge models with same architecture\n\n### ❌ Pitfall 2: Over-weighting One Model\n\n```yaml\n# Suboptimal: One model dominates\nmodels:\n  - model: model_a\n    parameters:\n      weight: 0.95  # Too high\n  - model: model_b\n    parameters:\n      weight: 0.05  # Too low\n```\n\n**Fix**: Use more balanced weights (0.3-0.7 range)\n\n### ❌ Pitfall 3: Not Evaluating\n\n```bash\n# Wrong: Merge and deploy without testing\nmergekit-yaml config.yml .\u002Fmerged-model\n# Deploy immediately (risky!)\n```\n\n**Fix**: Always benchmark before deploying\n\n## Resources\n\n- **mergekit GitHub**: https:\u002F\u002Fgithub.com\u002Farcee-ai\u002Fmergekit\n- **HuggingFace Tutorial**: https:\u002F\u002Fhuggingface.co\u002Fblog\u002Fmlabonne\u002Fmerge-models\n- **LazyMergekit**: Automated merging notebook\n- **TIES Paper**: https:\u002F\u002Farxiv.org\u002Fabs\u002F2306.01708\n- **DARE Paper**: https:\u002F\u002Farxiv.org\u002Fabs\u002F2311.03099\n\n## See Also\n\n- `references\u002Fmethods.md` - Deep dive into merge algorithms\n- `references\u002Fexamples.md` - Real-world merge configurations\n- `references\u002Fevaluation.md` - Benchmarking and testing strategies\n\n\n",{"name":5,"tags":45,"author":47,"license":14,"version":48,"description":7,"dependencies":49},[32,19,20,30,29,28,27,26,25,24,46],"Arcee AI","Orchestra Research","1.0.0",[50,51,52],"mergekit","transformers","torch","main","f19b254e8975d0bfddb394686706106930d7964d","AI-Training\u002Fmodel-merging","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus","https:\u002F\u002Fgithub.com\u002Fendman100","2026-11-11 18:19:10",{"source":8,"skillName":5,"commands":60,"prompt":70,"zipAvailable":71},[61,64,67],{"tool":62,"command":63},"npx","npx skills add endman100\u002Fskill-router-nexus --skill model-merging",{"tool":65,"command":66},"bunx","bunx skills add endman100\u002Fskill-router-nexus --skill model-merging",{"tool":68,"command":69},"pnpm","pnpm dlx skills add endman100\u002Fskill-router-nexus --skill model-merging","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FAI-Training\u002Fmodel-merging\u002FSKILL.md",true,[73,79,83],{"path":74,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Fevaluation.md","REFERENCE","参考文档",11705,"https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FAI-Training\u002Fmodel-merging\u002Freferences\u002Fevaluation.md",{"path":80,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":81,"sourceHtmlUrl":82},"references\u002Fexamples.md",8813,"https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FAI-Training\u002Fmodel-merging\u002Freferences\u002Fexamples.md",{"path":84,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002Fmethods.md",9562,"https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FAI-Training\u002Fmodel-merging\u002Freferences\u002Fmethods.md",[88,112,150,172,181,205],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":92,"sourceHtmlUrl":93,"categories":94,"keywords":100,"publishedAt":40},"01M6MPCT5BXVER8HQZTW3QE9AS","create-master","基于佛教经典文献，生成特定高僧大德的 AI 教学角色","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FMetaphysics-and-Spirituality\u002FMaster-skill\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FMetaphysics-and-Spirituality\u002FMaster-skill\u002FSKILL.md",[95],{"categoryNo":96,"categoryName":97,"taxonomyType":98,"taxonomyTypeDesc":99},"01JBSEEDCAT000000000000039","教师与教育","PROFESSION","适用职业",[101,102,103,104,105,106,107,108,109,110,111],"create master","master","create","生成","true","webfetch","edit","write","read","grep","Bash",{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":116,"sourceHtmlUrl":117,"categories":118,"keywords":130,"publishedAt":40},"01M6M43AKE95Y64E1JRXEF5QQ3","writing-dna-skill","从至少 20 篇完整文章中蒸馏可复用的写作 DNA，分析语言、文章结构、选题逻辑、素材策略、认知框架和视觉风格，并生成 Writing-DNA.md；按该 DNA 写作时会读取全部蒸馏产物和 5 篇相关原文。用于中英文作者、账号、品牌或出版物的风格分析与一致性写作。 Distill reusable Writing DNA from at least 20 complete articles for Chinese or English authors, publications, brands, and accounts; use for language, structure, topic logic, source strategy, cognitive-frame, and visual-style analysis.","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fwriting-dna-skill\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fwriting-dna-skill\u002FSKILL.md",[119,124,127],{"categoryNo":120,"categoryName":121,"taxonomyType":122,"taxonomyTypeDesc":123},"01JBSEEDCAT000000000000018","写作与文案","SCENARIO","使用场景",{"categoryNo":125,"categoryName":126,"taxonomyType":122,"taxonomyTypeDesc":123},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":128,"categoryName":129,"taxonomyType":98,"taxonomyTypeDesc":99},"01JBSEEDCAT000000000000036","内容创作者",[131,132,133,134,135,136,137,138,139,140,141,142,143,104,144,145,146,147,148,149],"writing dna skill","DNA","writing","strategy","english","logic","visual","structure","chinese","reusable","use","style","distill","analysis","frame","source","for","at","complete",{"skillNo":151,"name":152,"nameZh":6,"description":153,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":154,"sourceHtmlUrl":155,"categories":156,"keywords":159,"publishedAt":40},"01M6M428TTCGQ4ME3KY99VN037","stop-slop","Remove AI writing patterns from prose. Use when drafting, editing, or reviewing text to eliminate predictable AI tells.","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fstop-slop\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fstop-slop\u002FSKILL.md",[157,158],{"categoryNo":120,"categoryName":121,"taxonomyType":122,"taxonomyTypeDesc":123},{"categoryNo":128,"categoryName":129,"taxonomyType":98,"taxonomyTypeDesc":99},[160,161,162,163,21,164,165,166,167,141,168,169,170,147,171,133],"slop","stop slop","stop","drafting","drafts","https","patterns","prose","remove","editing","text","content",{"skillNo":173,"name":174,"nameZh":6,"description":175,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":176,"sourceHtmlUrl":177,"categories":178,"keywords":179,"publishedAt":40},"01M6M41X0B7EBX42TK435DMGGR","shuorenhua","检查和清理中英文文本里的 AI 套路，适用于“去 AI 味”“说人话”“自然一点”“别像模板”“先标问题”这类改写和审稿需求；按场景控制力度，同时保留事实、术语、语域和责任主体。","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fshuorenhua\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fshuorenhua\u002FSKILL.md",[],[174,180],"文本",{"skillNo":182,"name":183,"nameZh":6,"description":184,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":185,"sourceHtmlUrl":186,"categories":187,"keywords":188,"publishedAt":40},"01M6M3ZD12WBEW5KXKDM4N6DFG","naming","Name products, SaaS, brands, open source projects, bots, and apps. Use when the user needs to name something, find a brand name, or pick a product name. Metaphor-driven process that produces memorable, meaningful names and avoids AI slop.","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fnaming-main\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fnaming-main\u002FSKILL.md",[],[183,189,190,191,192,193,141,194,109,146,195,196,197,198,111,199,200,201,202,21,203,204,160],"repo","websearch","product name","apps","bots","view","brand","pick","gh","projects","open","saas","open source","product","describe","ai slop",{"skillNo":206,"name":207,"nameZh":6,"description":208,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":209,"sourceHtmlUrl":210,"categories":211,"keywords":213,"publishedAt":40},"01M6M3YVXAFAAWJ7F6JMPFREYE","humanizer-zh","去除文本中的 AI 生成痕迹。适用于编辑或审阅文本，使其听起来更自然、更像人类书写。\n基于维基百科的\"AI 写作特征\"综合指南。检测并修复以下模式：夸大的象征意义、\n宣传性语言、以 -ing 结尾的肤浅分析、模糊的归因、破折号过度使用、三段式法则、\nAI 词汇、否定式排比、过多的连接性短语。","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fhumanizer-zh\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fendman100\u002Fskill-router-nexus\u002Fblob\u002Fmain\u002FWriting-and-Content\u002Fhumanizer-zh\u002FSKILL.md",[212],{"categoryNo":120,"categoryName":121,"taxonomyType":122,"taxonomyTypeDesc":123},[214,215,216,109,108,107,133,104,180,217,160,162],"humanizer","zh","humanizer zh","翻译"]