오늘은 해커톤 프로젝트 개발에 집중하느라 정말 짧게 공부했다. 프로젝트가 생각보다 진도가 나가지 않아서, 하루를 프로젝트에 온전히 투자했다. 오늘은 프롬프트 엔지니어링에 대해 알아봤는데, 일단 옵시디언에 정리한 내용을 그대로 복붙하고 나중에 수정하겠다. 사실 개발 목적으로 알아봤지만, 실생활에서 적용하기에도 괜찮은 가이드인 것 같다는 생각이 들었다.
다음 주에는 SQLD 시험이 있고, 그 다음 주에는 대망의 해커톤 행사가 있다. 그렇다 보니 당분간 TIL은 옵시디언에 정리한 내용을 옮겨 적는 정도로만 쓰게 될 것 같다.. 공부에 3~4시간, 블로그에 글 쓰는 데에 거의 3~4시간이 걸리다보니, 그동안 온전히 개발에 투자할 시간이 많지 않았다. 나도 이왕 쓰는 거 최대한 정성껏 쓰고 싶은데, 어쩔 수 없이 당분간은 다른 것들에 좀 많은 시간을 투자하고자 한다.
What's a good name for a flower shop that specializes in selling bouquets of dried flowers? Create a list of 5 options with just the names.
<프롬프트>
Valid fields are cheeseburger, hamburger, fries, and drink.
Order: Give me a cheeseburger and fries
Output:
```
{
"cheeseburger": 1,
"fries": 1
}
```
Order: I want two burgers, a drink, and fries.
Output:
<응답>
```
{
"hamburger": 2,
"drink": 1,
"fries": 1
}
```
Output:은 후술할 응답 prefix에 해당모델에게 해야 할 일 또는 하지 말아야 할 일을 지시하는 부분.
예시) Summarize this text in one sentence:
응답 형식을 지정함. 표, 글머리 기호 목록, 키워드, 문장, 문단 등의 형식으로 요청
예시) All questions should be answered comprehensively with details, unless the user requests a concise response specifically.
모델은 예시의 패턴과 관계를 식별해 이를 응답 생성 시 참고함
프롬프트에는 항상 퓨샷 프롬프트를 포함하는 것이 좋음
Below are some examples showing a question, explanation, and answer format:
Question: Why is the sky blue?
Explanation1: The sky appears blue because of Rayleigh scattering, which causes
shorter blue wavelengths of light to be scattered more easily than longer red
wavelengths, making the sky look blue.
Explanation2: Due to Rayleigh scattering effect.
Answer: Explanation2
Question: What is the cause of earthquakes?
Explanation1: Sudden release of energy in the Earth's crust.
Explanation2: Earthquakes happen when tectonic plates suddenly slip or break
apart, causing a release of energy that creates seismic waves that can shake the
ground and cause damage.
Answer: Explanation1
Now, Answer the following question given the example formats above:
Question: How is snow formed?
Explanation1: Snow is formed when water vapor in the air freezes into ice
crystals in the atmosphere, which can combine and grow into snowflakes as they
fall through the atmosphere and accumulate on the ground.
Explanation2: Water vapor freezes into ice crystals forming snow.
Answer:
적절한 예시의 개수를 고르는 것이 필요함
예시가 너무 많음 -> 과적합 우려
예시가 너무 적음 -> 원하는 대답 나오지 않을 수 있음
모든 예시에서 일관된 형식을 보장하도록 함. 특히 XML 태그, 공백, 줄바꿈, 예시 구분자에 주의
하면 안되는 것보단 해야 하는 것을 지시하는 것이 더 원하는 대답을 얻을 확률이 높음
Don't end haikus with a question:
Haiku are fun
A short and simple poem
Don't you enjoy them?
Always end haikus with an assertion:
Haiku are fun
A short and simple poem
A joy to write
모델이 문제를 해결하기 위해 필요한 정보를 컨텍스트로 프롬프트에 포함
<예시>
Answer the question using the text below. Respond with only the text provided.
Question: What should I do to fix my disconnected wifi? The light on my Google Wifi router is yellow and blinking slowly.
Text:
Color: Slowly pulsing yellow
What it means: There is a network error.
What to do:
Check that the Ethernet cable is connected to both your router and your modem and both devices are turned on. You might need to unplug and plug in each device again.
Color: Fast blinking yellow
What it means: You are holding down the reset button and are factory resetting this device.
What to do:
If you keep holding down the reset button, after about 12 seconds, the light will turn solid yellow. Once it is solid yellow, let go of the factory reset button.
Color: Solid yellow
What it means: Router is factory resetting.
What to do:
This can take up to 10 minutes. When it's done, the device will reset itself and start pulsing white, letting you know it's ready for setup.
Color: Solid red
What it means: Something is wrong.
What to do:
Critical failure. Factory reset the router. If the light stays red, contact Wifi customer support.
<응답>
Check that the Ethernet cable is connected to both your router and your modem and both devices are turned on. You might need to unplug and plug in each device again.
Slowly pulsing yellow에 해당하는 부분의 What to do를 대답하는 것을 볼 수 있음Prefix는 프롬프트 컨텐츠에 추가하는 단어 또는 구문으로 붙이는 위치에 따라 3가지 용도로 사용
영어, 프랑스어 (두 언어의 구분)JSON: (출력이 JSON 형식이어야 함)Classify the text as one of the following categories.
- large
- small
Text: Rhino
The answer is: large
Text: Mouse
The answer is: small
Text: Snail
The answer is: small
Text: Elephant
The answer is:
Text:The answer is:복잡한 프롬프트를 더 간단한 프롬프트 여러 개로 나누기
topK: 가장 확률이 높은 토큰 k개 중 다음 토큰들을 선택함topP: 확률의 합이 topP와 같아질 때까지 토큰들을 선택함stop_sequence: 컨텐츠 생성을 중지하도록 지시하는 중지 시퀀스를 설정생성 모델은 텍스트 응답을 두 단계에 걸쳐 생성