AGENT SKILL

llamafactory

Use when fine-tuning, training, or doing LoRA/QLoRA on LLMs. Triggers on: 'fine-tune LLM', 'LoRA', 'QLoRA', 'llamafactory', 'llama factory', 'train model', 'SFT', 'RLHF', 'DPO', 'fine tuning', 'custom model', 'instruction tuning', 'finetuning'.

License 许可
Apache-2.0
最近更新
2026-11-14
Stars
★ 13
Forks
2

01 前言 Front Matter

name
llamafactory
description
Use when fine-tuning, training, or doing LoRA/QLoRA on LLMs. Triggers on: 'fine-tune LLM', 'LoRA', 'QLoRA', 'llamafactory', 'llama factory', 'train model', 'SFT', 'RLHF', 'DPO', 'fine tuning', 'custom model', 'instruction tuning', 'finetuning'.

03 SKILL.md 正文

LlamaFactory Skill

Fine-tune 100+ LLMs (Llama, Qwen, Gemma, Mistral...) với zero-code CLI hoặc Web UI. Source: hiyouga/LlamaFactory (71K⭐, Apache 2.0)

Install

pip install llamafactory
# hoặc với CUDA
pip install llamafactory[torch,metrics]

Workflow

Step 1 — Chuẩn bị dataset

Format Alpaca (phổ biến nhất):

[
  {
    "instruction": "Dịch câu sau sang tiếng Anh",
    "input": "Tôi yêu Việt Nam",
    "output": "I love Vietnam"
  }
]

Format ShareGPT (multi-turn):

[
  {
    "conversations": [
      {"from": "human", "value": "Bạn là ai?"},
      {"from": "gpt", "value": "Tôi là trợ lý AI."}
    ]
  }
]

Đăng ký dataset trong data/dataset_info.json:

{
  "my_dataset": {
    "file_name": "my_data.json",
    "formatting": "alpaca"
  }
}

Step 2 — Train với CLI (LoRA SFT)

llamafactory-cli train \
  --model_name_or_path Qwen/Qwen2.5-7B-Instruct \
  --stage sft \
  --do_train \
  --dataset my_dataset \
  --template qwen \
  --finetuning_type lora \
  --lora_rank 8 \
  --output_dir outputs/my-model \
  --num_train_epochs 3 \
  --per_device_train_batch_size 4 \
  --learning_rate 1e-4 \
  --fp16

Step 3 — Train với config YAML (khuyên dùng)

# train_config.yaml
model_name_or_path: Qwen/Qwen2.5-7B-Instruct
stage: sft
do_train: true
dataset: my_dataset
template: qwen
finetuning_type: lora
lora_rank: 8
output_dir: outputs/my-model
num_train_epochs: 3
per_device_train_batch_size: 4
gradient_accumulation_steps: 4
learning_rate: 1.0e-4
lr_scheduler_type: cosine
fp16: true
logging_steps: 10
save_steps: 500
llamafactory-cli train train_config.yaml

Step 4 — Chat với model sau training

llamafactory-cli chat \
  --model_name_or_path Qwen/Qwen2.5-7B-Instruct \
  --adapter_name_or_path outputs/my-model \
  --template qwen \
  --finetuning_type lora

Step 5 — Export / merge LoRA weights

llamafactory-cli export \
  --model_name_or_path Qwen/Qwen2.5-7B-Instruct \
  --adapter_name_or_path outputs/my-model \
  --export_dir outputs/merged-model \
  --finetuning_type lora \
  --export_size 4   # số GB mỗi shard

Step 6 — Web UI (không cần code)

llamafactory-cli webui
# Mở http://localhost:7860

Training approaches được support

Method Dùng khi
SFT (Supervised) Instruction following, task-specific
DPO Align với human preference (pairwise)
PPO RLHF với reward model
ORPO DPO không cần reference model
LoRA VRAM thấp, chỉ train adapter
QLoRA VRAM rất thấp (4-bit base model)
Full fine-tune Tất cả params, cần GPU lớn

Template cho các model phổ biến

qwen      → Qwen2/Qwen2.5
llama3    → Llama-3.x
gemma     → Gemma 2/3
mistral   → Mistral/Mixtral
phi       → Phi-3/4

Yêu cầu VRAM (ước tính LoRA)

Model size QLoRA LoRA
7B 8GB 16GB
13B 12GB 24GB
70B 48GB 80GB+

04 同仓库更多 Skills

Horonomos-laps
Horonomos-laps/Yana-AI

openai--sentry--sentry

Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

ito-basket-compare

Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

implementing-network-traffic-baselining

Build network traffic baselines from NetFlow/IPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly/daily traffic pattern profiling

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

detecting-evasion-techniques-in-endpoint-logs

Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

implementing-microsegmentation-with-guardicore

Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

ramdisk-tmpfs-patterns

暂无简介

★ 13