프롬프트 엔지니어링이란? 컴퓨터와 대화하는 방법이고 컴퓨터에게 업무를 시키는 새로운 방식의 코딩이다.
사람한테도 말을 엄하게 하면 결과가 이상한 것처럼 컴퓨터한테도 훨씬 더 정확하게 이야기해야한다.
LLM Prompt Engineering
모델을 훈련(Training)이라는 것은 오랫동안 대규모의 데이터셋으로 데이터에있는 다양한 특징 혹은 패턴, 맥락정보를 오랜기간동안 공부를 하고 익히는 방법입니다. 그러니까 쉽게 이야기하면, 아무것도 모르는 아기가 이것저것 공부해서 천재가 되가는 과정이라고 생각하면됩니다. 여기에는 Finetunning, pretraining등이 포함됩니다. 반면에 이미 학습이 끝난, 그러니까 이미 훈련이 끝난 모델에 어떻게 하면 더 정확도 높은 답변을 뽑을 수 있을까? 잠깐 배우는 거 이것을 러닝(learning)이라고 부릅니다. 그래서 컨텍스트 안에 LLM이 배워야할 일부 정보를 주는 것을 러닝이라고 합니다. 그래서 아래 다양한 learning방법에 대해 살펴봅니다.
1. Zero shot learning
Zero shot learning은 Task에 대한 예시나 정보가 전혀 없이 모델이 풀어야할 문제(Task)를 입력하고 풀어야할 대상(prompt)를 입력하면 모델은 번역을 합니다. 한마디로 모델에 어떤 문제를 풀어야할지 예시정보가 없이 prompt로 명령하는 방법이라고 생각하면됩니다. zero shot으로 어느정도 성능이 나오기 위해서는 대규모의 모델 사이즈로 대규모의 다양한 데이터셋으로 학습을 시킨경우 어느정도 성능이 나옵니다.
2. One-shot learning
one-shot learning은 모델이 풀어야할 문제에 대한 예시를 하나만 예시로 두는 기법입니다.
3. Few-shot learning
Few-shot learning은 모델이 풀어야할 문제에 대한 예시를 하나만 두는 것이 아니라 2개 이상 예시를 모델한테 알려주는 기법입니다. 모델이 풀어야할 여러 예제들을 알려주게 되면 모델은 프롬프트에 대해 더 정확한 답변을 출력하게 됩니다.
4. Chain of Thought (생각의 사슬)
LLM에게 이런 방식으로 생각해라~라는 가이드를 주는 방식입니다. 이런 문제를 풀 때는 이런 단계로 풀면 되라는 가이드를 주는 기법입니다. 그 가이드를 통해서 새로운 문제가 왔을 때 이전에 줬던 가이드를 참고해서 그 방식대로 문제를 푸는 방법을 이야기합니다.
5. Zero Shot Chain of Thought
"Let's think step by step"이 문구만으로도 앞의 기술인 Chain of Thought만큼의 성능을 발휘하는 기법입니다. 문구 하나만 넣었을 뿐인데 llm모델은 인간이 사고하는 것과 같이 단계별로 해당 문제를 추론하는 것을 볼 수 있습니다!
zero shot chain of Thought저자들은 Let's think step by step문구외에 다른 template도 많이 시도를 했었는데요. zero shot 정확도는 17.7 턱없이 낮은 반면, Let's think step by step을 넣었을 때 정확도가 상당히 향상되는 것을 아래 예시를 통해 볼 수 있습니다. 그리고 내용에 전혀 관련없는 Abrakadabra!, It's beautiful day., By the way, I found a good restaurant nearby. 이런문장들은 오히려 zero shot보다도 성능이 좋지 않은 것을 볼 수 있습니다..
아래 예시는 zero shot만 했을 때, few-shot을 했을 때, few-shot의 예시를 2개 혹은 8개 넣었을 때의 변화를 결과로 정리한 표인데요. 확실히 zero shot일 때보다 few-shot을 했을 때, 성능이 올라가지만, 2개예시와 8개 예시의 정확도는 큰 차이가 없는 것을 보여줍니다. 그러니 결론은 few-shot을 하더라도 너무 많은 예시는 오히려 모델한테 큰 영향이 끼치지는 않구나 정도 이해할 수 있을 것 같습니다.
그 아래 실험은 zero shot에다가 cot기법을 덧붙혀서 실험한 결과인데 확실히, cot를 붙였을 때 안붙인 결과보다 훨씬 높은 정확도를 보이는 것을 알 수 있습니다. 위의 테이블에서는 2개예시와 8개예시의 차이가 별로 없었는데, cot를 붙이니 2개예시, 4개예시, 8개예시의 정확도가 좀씩 차이가 있는 것으로 확인됩니다. 그래서 결론적으로 few-shot에 8개 예시로 cot를 붙였더니 정확도가 가장 좋더라~ 라는 것을 논문 실험을 통해 확인해볼 수 있었습니다.
아주 기본적으로 쓰이는 프롬프트 엔지니어링(prompt engineering)기법들에 대해서 살펴보았는데요. 그 이후 포스팅에서는 더욱 더 심화된 프롬프트 엔지니어링 기법에 대해 살펴보도록하겠습니다.
그 외 여러 Prompt Engineering 기법들
- Self Consistency
- Meta-Reasoning over Multiple Chains
- Generated Knowledge Prompting
- Synthetic prompting
- Automatix Prompt Engineer (APE)
- Active-Prompt
- Directional Stimulus Prompting
- MRKL
- ReAct Prompting
- PAL (Program-Aided Language Models)
- Multimodal CoT
- Graph Prompting
- Prompt Ensembling
- ART (Automatic Reasoning and Tool-use)
- Self Evaluation
- Self Refine
- Automatic Prompt Engineer
'LLM' 카테고리의 다른 글
Copilot의 시대, Copilot stack에 대해 살펴보자~! (0) | 2023.11.18 |
---|---|
초간단 openai의 chatGPT API 발급받아보기~~!! (0) | 2023.11.03 |