Prompt Is Model Performance
In prj_category_llm, prompt engineering consumed more time than anything else across 48 commits. LLM category classification accuracy varies by more than 20% depending on the prompt.
Prompt Evolution
flowchart LR
A[v1: 단순 지시] --> B[v2: 예시 추가]
B --> C[v3: 카테고리 트리 제공]
C --> D[v4: RAG 기반]
D --> E[v5: Chain-of-Thought]
style A fill:#ffcdd2
style E fill:#c8e6c9
v1: Simple Instruction (~65% accuracy)
상품명: "{product_name}"
이 상품의 카테고리를 대분류 > 중분류 > 소분류 형태로 분류해주세요.
v2: Few-shot Examples (~75% accuracy)
예시:
- "나이키 에어맥스 90" → 패션 > 남성신발 > 운동화
- "삼성 갤럭시 S24" → 디지털/가전 > 휴대폰 > 스마트폰
상품명: "{product_name}"
카테고리를 분류해주세요.
v3: Category Tree Injection (~82% accuracy)
Include the full category taxonomy in the prompt. Token cost increases, but accuracy improves significantly.
v4: RAG-based (~88% accuracy)
Use vector search to retrieve existing products similar to the input product name, then pass them as reference context.
v5: Chain-of-Thought (~92% accuracy)
다음 순서로 생각해주세요:
1. 상품의 주요 용도를 파악하세요
2. 대분류를 결정하세요
3. 중분류를 결정하세요
4. 소분류를 결정하세요
5. 각 단계의 근거를 설명하세요
상품명: "{product_name}"
Key Takeaways
- Require structured output: Specify JSON format explicitly
- Include negative examples: "This is NOT X" style examples
- Define category boundaries: Provide clear criteria for commonly confused categories
- Tune temperature: For classification tasks,
temperature=0is optimal