프롬프트에 좋은 대답이 어떤 것인지 모델에 보여주는 예시를 포함할 수 있습니다. 모델은 예시의 패턴과 관계를 식별한 후 응답을 생성할 때 이를 적용합니다. 예시가 포함된 프롬프트를 퓨샷 프롬프트라고 하며 예시를 제공하지 않는 프롬프트를 제로샷 프롬프트라고 합니다. 퓨샷 프롬프트는 모델 응답의 출력 형식 지정, 문구, 범위 지정 또는 일반적인 패턴을 규제하는 데 자주 사용됩니다. 모델이 초점을 좁히고 더 정확한 결과를 생성할 수 있도록 구체적이고 다양한 예시를 사용합니다.
프롬프트에 퓨샷 예시를 포함하면 프롬프트의 신뢰성과 효과를 높일 수 있습니다.
하지만 항상 퓨샷 예시에 명확한 안내를 제공해야 합니다. 명확한 안내가 없으면 모델이 예시에서 의도하지 않은 패턴이나 관계를 선택하여 결과가 나쁠 수 있습니다.
이 전략의 핵심 사항은 다음과 같습니다.
프롬프트에 프롬프트-응답 예시를 포함하면 모델이 응답하는 방법을 배울 수 있습니다.
XML과 유사한 마크업을 사용하여 예시를 마크업합니다.
포함할 프롬프트 수를 실험해 보세요. 모델에 따라 모델 동작을 변경하는 데 효과적이지 않은 예시가 너무 적습니다. 예시가 너무 많으면 모델이 과적합하게 될 수 있습니다.
여러 예시에 일관된 형식 사용
제로샷 프롬프트와 퓨샷 프롬프트 비교
다음 제로 샷 프롬프트는 모델에 텍스트에서 기술 사양을 추출하고 JSON 형식으로 출력하도록 요청합니다.
Extract the technical specifications from the text below in JSON format.
Google Pixel 7, 5G network, 8GB RAM, Tensor G2 processor, 128GB of storage, Lemongrass
사용 사례에 소문자 키 이름과 같은 특정 형식이 필요하다고 가정해 보겠습니다. 프롬프트에 JSON 형식을 지정하는 방법을 모델에 보여주는 예시를 포함할 수 있습니다. 다음 퓨샷 프롬프트에서는 JSON 키가 소문자인 출력 형식을 보여줍니다.
Extract the technical specifications from the text below in a JSON format.
<EXAMPLE>
INPUT: Google Nest Wifi, network speed up to 1200Mpbs, 2.4GHz and 5GHz frequencies, WP3 protocol
OUTPUT:
{
"product":"Google Nest Wifi",
"speed":"1200Mpbs",
"frequencies": ["2.4GHz", "5GHz"],
"protocol":"WP3"
}
</EXAMPLE>
Google Pixel 7, 5G network, 8GB RAM, Tensor G2 processor, 128GB of storage, Lemongrass
이 예시에서는 XML과 유사한 형식을 사용하여 프롬프트 구성요소를 구분합니다. XML과 유사한 형식을 사용하여 퓨샷 프롬프트 형식을 최적화하는 방법을 자세히 알아보려면 프롬프트 구조를 참조하세요.
최적의 예시 수 찾기
프롬프트에서 가장 원하는 결과를 제공할 예시 수를 실험해볼 수 있습니다. Gemini와 같은 모델은 종종 몇 가지 예시를 사용하여 패턴을 선택하지만, 원하는 결과를 얻기 위한 예시 수에 대해 실험해야 할 수 있습니다. 동시에 너무 많은 예시를 포함하면 모델이 예시에 대한 응답에 과적합하게 될 수 있습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-09(UTC)"],[],[],null,["# Include few-shot examples\n\nYou can include examples in the prompt that show the model what a good response looks like. The\nmodel attempts to identify patterns and relationships from the examples and applies them when\ngenerating a response. Prompts that contain examples are called *few-shot* prompts, while\nprompts that provide no examples are called *zero-shot prompts*. Few-shot prompts are\noften used to regulate the output formatting, phrasing, scoping, or general patterning of model\nresponses. Use specific and varied examples to help the model narrow its focus and generate more\naccurate results.\n\nIncluding few-shot examples in your prompts helps make them more reliable and effective.\nHowever, you should always accompany few-shot examples with clear instructions. Without clear\ninstructions, models might pick up one unintended patterns or relationships from the examples, which\ncan lead to poor results.\n\nThe key points to this strategy are as follows:\n\n- Including prompt-response examples in the prompt helps the model learn how to respond.\n- Use XML-like markup to markup the examples.\n- Experiment with the number of prompts to include. Depending on the model, too few examples are ineffective at changing model behavior. Too many examples can cause the model to overfit.\n- Use consistent formatting across examples\n\nZero-shot versus few-shot prompts\n---------------------------------\n\nThe following zero-shot prompt asks the model to extract the technical specifications from\ntext and output it in JSON format:\n\nSuppose that your use case requires specific formatting, such as using lowercase key names. You can include\nexamples in the prompt that shows the model how to format the JSON. The following few-shot prompt\ndemonstrates an output format where the JSON keys are lowercase:\n\nNote that the example uses XML-like formatting to separate the components of the prompt. To\nlearn more about how to optimally format few-shot prompts using XML-like formatting, see\n[Structure prompts](/vertex-ai/generative-ai/docs/learn/prompts/structure-prompts).\n\nFind the optimal number of examples\n-----------------------------------\n\nYou can experiment with the number of examples to provide in the prompt for the most desired\nresults. Models like Gemini can often pick up on patterns using a few examples, though you\nmay need to experiment with what number of examples leads to the desired results. At the same time,\nif you include too many examples, the model might start to\n[overfit](https://developers.google.com/machine-learning/glossary#overfitting)\nthe response to the examples.\n\nWhat's next\n-----------\n\n- Explore more examples of prompts in the [Prompt gallery](/vertex-ai/generative-ai/docs/prompt-gallery)."]]