Fine-tuning vs RAG vs Prompt Engineering: Cost-Effective LLM Customization Strategies
"Don't we have to fine-tune an LLM to customize it for our domain?" — The answer to this question is usually "no." Pick the wrong method and you can spend tens of millions of won and still not get the results you want.
The Fundamental Differences Among the Three Approaches
| Method | What it changes | When it applies |
|---|---|---|
| Prompt engineering | Input format | On every call |
| RAG | Knowledge the model references | On every call (external retrieval) |
| Fine-tuning | The model weights themselves | At training time (one-off) |
Cost Structure Comparison
Prompt Engineering
# Few-shot 추가 시 토큰 비용 증가 계산
base_tokens = 100
fewshot_tokens = 500
calls_per_day = 10_000
daily_extra_cost = (fewshot_tokens - base_tokens) * calls_per_day * (3.00 / 1_000_000)
print(f"Few-shot 추가 일일 비용: ${daily_extra_cost:.2f}") # ~$12/dayTotal cost: 1–3 million won in development + 300,000–1 million won per month in operations
RAG
docs_count = 100_000
avg_chunk_tokens = 500
embedding_cost_per_1m = 0.02 # text-embedding-3-small
initial_embedding_cost = docs_count * avg_chunk_tokens * embedding_cost_per_1m / 1_000_000
print(f"초기 임베딩 비용: ${initial_embedding_cost:.2f}") # ~$1
daily_queries = 5_000
context_tokens_per_query = 2_000
monthly_context_cost = daily_queries * 30 * context_tokens_per_query * (3.00 / 1_000_000)
print(f"월 컨텍스트 비용: ${monthly_context_cost:.2f}") # ~$900Total cost: 5–20 million won in development + 500,000–3 million won per month in operations
Fine-tuning
training_tokens = 1_000_000
training_cost_per_1m = 25.00 # GPT-4o mini fine-tuning 기준
training_cost = training_tokens * training_cost_per_1m / 1_000_000
print(f"훈련 비용: ${training_cost:.2f}") # $25
# 하지만 데이터 수집·정제가 진짜 비용
# 1,000개 Q&A 쌍 생성: 엔지니어 2주 = 약 300~500만 원
# 파인튜닝 모델은 기본 모델보다 추론 비용이 2배 비쌈Total cost: 5–30 million won for data construction + training + higher operating costs
When to Choose What
When to choose prompt engineering:
✓ You need a fast prototype
✓ You only need to control output format
✓ Budget is tight
When to choose RAG:
✓ You need up-to-date information or internal documents
✓ Source tracing matters
✓ Knowledge is updated frequently
When to choose fine-tuning:
✓ You need to lock in a specific style or format completely
✓ You need extreme low-latency optimization
✗ If the goal is knowledge injection → RAG is almost always betterA Combined Strategy Is Best
# 실전 조합: 고객 지원 봇
# 1단계: 프롬프트 엔지니어링으로 응답 형식·톤 고정
# 2단계: RAG로 최신 제품 정보·FAQ 검색
# 3단계: Fine-tuning은 불필요
system_prompt = """당신은 [회사명] 고객 지원 전문가입니다.
- 항상 정중하고 공감하는 톤을 유지하세요
- 제공된 참고 문서만 기반으로 답변하세요"""
def answer_customer(question):
context = vector_search(question, top_k=3)
response = llm.chat([
{"role": "system", "content": system_prompt},
{"role": "user", "content": f"참고 문서:
{context}
질문: {question}"}
])
return responseIn the next post, we'll cover how to actually calculate ROI for AI projects and report it to leadership.
Final Decision Table by Requirement
| Core requirement | First choice | Signal to move to the next step |
|---|---|---|
| Correcting answer format and tone | Prompt engineering | When the prompt exceeds 2,000 tokens and failure cases still keep repeating |
| Answers grounded in internal docs and up-to-date information | RAG | When retrieval quality is good but domain voice and format still aren't sticking |
| Internalizing domain-specific voice and taxonomy | Fine-tuning | — (last resort) |
| Citations and source attribution required | RAG | FT cannot invent sources — keep RAG |
| Offline / low-latency small models | Small-model FT | If knowledge updates frequently, FT alone is a poor fit → combine with RAG |
Operating principle: Climb the ladder in the order prompt → RAG → FT, and also check whether you can climb back down. Fine-tuning is the only option where data rebuild and retraining costs keep recurring, so introduce it only after you've documented that the problem truly cannot be solved with prompting or retrieval. That's how you prevent a cost disaster.
Nodelog는 모든 콘텐츠의 내용과 출처를 공개 전에 검토합니다. 환경(OS·버전)에 따라 결과가 달라질 수 있는 기술 정보는 공식 문서와 함께 확인하며, 검토 기준과 정정 원칙은 편집 정책에서 안내합니다. 오류를 발견하시면 이메일로 제보해 주세요 — 확인 후 신속히 정정합니다.
Comments
Be the first to comment.