9148c358d0
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
5.8 KiB
5.8 KiB
id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
| id | title | category | status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | verification_status | tags | raw_sources | last_reinforced | github_commit | tech_stack | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| wiki-2026-0508-peft-parameter-efficient-fine-tu | PEFT (Parameter-Efficient Fine-Tuning) | 10_Wiki/Topics | verified | self |
|
none | A | 0.95 | applied |
|
2026-05-10 | pending |
|
PEFT (Parameter-Efficient Fine-Tuning)
매 한 줄
"매 frozen base + tiny trainable delta". 매 full fine-tuning 의 ~0.1-1% parameter 만 학습. 2026 standard: LoRA / QLoRA — 매 70B model 도 single 24GB GPU 에서 fine-tune 가능. HuggingFace
peftlibrary 의 사실상 표준.
매 핵심
매 동기
- Full FT: 70B model = 280GB (fp32) gradient + optimizer state → multi-A100 cluster 필요.
- Storage: 매 task 마다 full checkpoint 저장 시 비용 폭발.
- Catastrophic forgetting: 매 full FT 가 base capability 손상.
- PEFT: 매 base frozen, delta 만 학습 → 1 base + N tiny adapters.
매 family
- LoRA (Hu et al. 2021): low-rank decomposition
ΔW = BA, rank r=4-64. - QLoRA (Dettmers et al. 2023): 4-bit NF4 quantized base + LoRA adapters.
- Prefix Tuning (Li & Liang 2021): learnable prefix tokens prepended to keys/values.
- Prompt Tuning (Lester et al. 2021): learnable soft prompts at input.
- IA³ (Liu et al. 2022): scale activations via learned vectors (multiply, not add).
- Adapters (Houlsby et al. 2019): small bottleneck MLPs inserted between layers.
- DoRA (2024): magnitude + direction decomposition, LoRA 보다 우수.
매 LoRA 수학
W' = W + αBA/rwhereB ∈ R^{d×r},A ∈ R^{r×k}, r ≪ min(d,k).- Trainable:
2drparams instead ofdk. 매 d=k=4096, r=8 → 65k vs 16M (250× 감소). - Inference: 매 merge
W ← W + αBA/r→ zero overhead.
매 응용
- Domain adaptation (legal, medical LLM).
- Instruction tuning (Alpaca-style).
- Style transfer (FLUX LoRA for art style).
- Multi-tenant serving (1 base + N customer LoRAs).
💻 패턴
LoRA with peft library
from peft import LoraConfig, get_peft_model, TaskType
from transformers import AutoModelForCausalLM
base = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.1-8B")
config = LoraConfig(
task_type=TaskType.CAUSAL_LM,
r=16, lora_alpha=32, lora_dropout=0.05,
target_modules=["q_proj", "k_proj", "v_proj", "o_proj"],
)
model = get_peft_model(base, config)
model.print_trainable_parameters() # ~0.5% trainable
QLoRA (4-bit base + LoRA)
from transformers import BitsAndBytesConfig
import torch
bnb = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16,
bnb_4bit_use_double_quant=True,
)
base = AutoModelForCausalLM.from_pretrained(
"meta-llama/Llama-3.1-70B", quantization_config=bnb, device_map="auto",
)
model = get_peft_model(base, lora_config) # 70B on single 48GB GPU
Save / load adapter only
model.save_pretrained("./my-lora") # ~50MB, not 140GB
from peft import PeftModel
loaded = PeftModel.from_pretrained(base, "./my-lora")
Merge for inference
merged = model.merge_and_unload() # W ← W + αBA/r
merged.save_pretrained("./merged-model") # standard HF model, no peft dep
Multi-LoRA serving (vLLM)
# vLLM 0.6+ supports dynamic LoRA loading
from vllm import LLM, SamplingParams
from vllm.lora.request import LoRARequest
llm = LLM(model="meta-llama/Llama-3.1-8B", enable_lora=True, max_loras=8)
out = llm.generate(prompts, sampling_params,
lora_request=LoRARequest("customer-42", 1, "./customer-42-lora"))
DoRA (2024)
config = LoraConfig(r=16, lora_alpha=32, use_dora=True, # peft >= 0.10
target_modules=["q_proj", "v_proj"])
Prompt tuning
from peft import PromptTuningConfig, PromptTuningInit
config = PromptTuningConfig(
task_type=TaskType.CAUSAL_LM,
prompt_tuning_init=PromptTuningInit.TEXT,
num_virtual_tokens=20,
prompt_tuning_init_text="Classify sentiment:",
tokenizer_name_or_path="meta-llama/Llama-3.1-8B",
)
매 결정 기준
| 상황 | Approach |
|---|---|
| 1 GPU, large base (70B) | QLoRA |
| Multi-task, single base | LoRA + multi-adapter serving |
| Tiny VRAM, frozen base OK | Prompt tuning |
| Best quality, less compute saving | DoRA |
| Diffusion model style | LoRA (rank 4-32) |
| Production accuracy critical | Full FT (if 가능) |
기본값: QLoRA (4-bit NF4 + r=16 LoRA on q/k/v/o projections).
🔗 Graph
- 부모: Fine-Tuning
- 변형: LoRA · QLoRA · DoRA
- 응용: Fine-tuning · Domain-Adaptation
- Adjacent: LLM_Optimization_and_Deployment_Strategies · RLHF
🤖 LLM 활용
언제: 매 single GPU 에서 large model fine-tune, multi-tenant LoRA serving, rapid task iteration. 언제 X: 매 base model 의 fundamental capability 변경 필요 (continued pretraining → full FT or full pretraining).
❌ 안티패턴
- Rank too low: r=1-2 → underfitting. 매 r=8-32 starting point.
- Wrong target modules: only
q_proj/v_projskip → degraded. 매 all attention + MLP modules 가 best. - Forgetting alpha: 매 alpha=2r convention 무시 → unstable training.
- Saving full model:
model.save_pretrained()on PeftModel 만 saves adapter. Don't merge unnecessarily. - QLoRA + bf16 base: 매 NF4 quantization 의 redundant. 매 fp16 or bf16 base 둘 중 하나.
🧪 검증 / 중복
- Verified (HuggingFace
peftdocs, Hu et al. 2021 LoRA, Dettmers et al. 2023 QLoRA). - 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — PEFT family, LoRA/QLoRA patterns, decision matrix |