프롬프트를 설계하는 데 있어 옳거나 그른 방법은 없지만 모델 응답에 영향을 미치는 데 사용할 수 있는 일반적인 전략이 있습니다. 모델 성능 최적화를 위해서는 여전히 엄격한 테스트와 평가가 중요합니다.
대규모 언어 모델(LLM)은 언어 단위 간의 패턴과 관계를 배우기 위해 방대한 양의 텍스트 데이터에 대해 학습합니다. 일부 텍스트(프롬프트)가 제공되면 언어 모델은 정교한 자동 완성 도구와 같이 다음에 나올 내용을 예측할 수 있습니다. 따라서 프롬프트를 설계할 때 모델이 다음에 올 내용을 예측할 때 영향을 미칠 수 있는 다양한 요소를 고려하십시오.
프롬프트 엔지니어링 워크플로
프롬프트 엔지니어링은 모델 성능을 향상시킬 수 있는 테스트 기반의 반복 프로세스입니다.
프롬프트를 만들 때는 각 프롬프트의 목표와 예상 결과를 명확하게 정의하고 이를 체계적으로 테스트하여 개선할 부분을 파악할 수 있어야 합니다.
다음 다이어그램은 프롬프트 엔지니어링 워크플로를 보여줍니다.
효과적인 프롬프트를 만드는 방법
프롬프트의 효과에 궁극적으로 영향을 미치는 프롬프트의 두 가지 요소는 콘텐츠와 구조입니다.
콘텐츠:
태스크를 완료하려면 모델에 태스크와 관련된 모든 정보가 필요합니다. 이 정보에는 안내, 예시, 상황별 정보 등이 포함될 수 있습니다. 자세한 내용은 프롬프트의 구성요소를 참조하세요.
구조:
프롬프트에 필요한 모든 정보가 제공되더라도, 정보 구조를 제공하면 모델이 정보를 파싱하는 데 도움이 됩니다. 순서 지정, 라벨 지정, 구분 기호 사용 등이 모두 응답 품질에 영향을 줄 수 있습니다. 프롬프트 구조의 예시는 샘플 프롬프트 템플릿을 참조하세요.
프롬프트 구성요소
다음 표에서는 프롬프트의 필수 구성요소와 선택적 구성요소를 보여줍니다.
구성요소
설명
예시
목표
모델로 달성하려는 목표입니다. 구체적으로 설명하고 중요한 목표를 포함합니다. '미션' 또는 '목적'이라고도 합니다.
목표는 학생들에게 직접 답을 알려주지 않고 수학 문제를 풀 수 있게 도와주는 것입니다.
안내
당면한 태스크를 수행하는 방법에 대한 단계별 안내입니다. '태스크', '단계', '경로'라고도 합니다.
문제의 요점을 파악합니다.
학생이 어디에서 막혔는지 파악합니다.
문제의 다음 단계에 대한 힌트를 제공합니다.
선택적 구성요소
시스템 안내
태스크 집합에서 모델의 동작을 제어하거나 변경하는 작업이 포함될 수 있는 기술 또는 환경 지시문입니다. 대다수 모델 API의 경우 전용 매개변수에 시스템 안내가 지정됩니다.
시스템 안내는 Gemini 1.5 Pro에서만 사용할 수 있습니다.
프런트엔드 인터페이스의 코드 렌더링을 전문으로 하는 코딩 전문가입니다. 빌드하고자 하는 웹사이트의 구성요소를 설명할 때 빌드에 필요한 HTML과 CSS를 반환해야 합니다. 이 코드에 대한 설명을 제공하지 않습니다. UI 디자인 제안도 제공합니다.
Persona
모델이 맡은 역입니다. '역할' 또는 '비전'이라고도 합니다.
여기서 귀하는 학생의 수학 숙제를 도와주는 수학 강사입니다.
제약조건
모델이 할 수 있는 것과 할 수 없는 것을 포함하여 응답을 생성할 때 준수해야 하는 것에 대한 제한사항입니다. '가드레일', '경계' 또는 '컨트롤'이라고도 합니다.
학생에게 직접 답을 알려주지 마세요. 대신 다음 단계에서 문제 해결을 위한 힌트를 제공하세요. 학생이 전혀 감을 잡지 못하는 경우 문제 해결을 위한 자세한 단계를 알려주세요.
어조
응답의 어조입니다. 캐릭터를 지정하여 스타일과 어조에 영향을 줄 수도 있습니다. '스타일', '음성', '기분'이라고도 합니다.
친근하고 전문적으로 응답합니다.
컨텍스트
모델이 당면한 태스크를 수행하기 위해 참조해야 하는 정보입니다.
'배경', '문서' 또는 '입력' 데이터라고도 합니다.
학생의 수학 수업 계획 사본입니다.
퓨샷 예시
특정 프롬프트에 대한 응답 예시입니다. '예시' 또는 '샘플'이라고도 합니다.
input: 부피가 1 입방 미터인 상자에 들어갈 수 있는 골프 공의 개수를 계산하려고 합니다. 1 입방 미터를 입방 센티미터로 변환하여 입방 센티미터 단위의 골프 공 부피로 나누었지만 시스템에서 내 답이 틀렸다고 표시됩니다. output: 골프 공은 구형이며 한 공간에 효율적으로 딱 맞게 들어갈 수 없습니다. 계산 시 구의 최대 적재 효율성을 고려해야 합니다.
추론 단계
추론을 설명하도록 모델에 지시합니다. 이렇게 하면 경우에 따라 모델의 추론 기능이 향상될 수 있습니다. '싱킹 단계'라고도 합니다.
추론을 단계별로 설명합니다.
응답 형식
사용할 응답 형식입니다. 예를 들어 응답을 JSON, 테이블, 마크다운, 단락, 글머리기호 목록, 키워드, 엘리베이터 피치 등으로 출력하도록 모델에 지시할 수 있습니다. '구조', '프레젠테이션' 또는 '레이아웃'이라고도 합니다.
응답 형식을 마크다운으로 지정합니다.
요약
프롬프트 끝에서 프롬프트의 핵심 사항, 특히 제약조건과 응답 형식을 간결하게 반복합니다.
정답을 제시하지 말고 힌트를 제공합니다. 항상 마크다운 형식으로 응답 형식을 지정합니다.
보호 장치
봇의 미션에 근거한 질문을 제시합니다. '안전 규칙'이라고도 합니다.
해당 사항 없음
당면한 특정 태스크에 따라 일부 선택적 구성요소를 포함하거나 제외할 수 있습니다. 또한 구성요소 순서를 조정하고 응답에 미치는 영향을 확인할 수도 있습니다.
샘플 프롬프트 템플릿
다음 프롬프트 템플릿은 잘 구조화된 프롬프트의 예시를 보여줍니다.
<OBJECTIVE_AND_PERSONA>
You are a [insert a persona, such as a "math teacher" or "automotive expert"]. Your task is to...
</OBJECTIVE_AND_PERSONA>
<INSTRUCTIONS>
To complete the task, you need to follow these steps:
1.
2.
...
</INSTRUCTIONS>
------------- Optional Components ------------
<CONSTRAINTS>
Dos and don'ts for the following aspects
1. Dos
2. Don'ts
</CONSTRAINTS>
<CONTEXT>
The provided context
</CONTEXT>
<OUTPUT_FORMAT>
The output format must be
1.
2.
...
</OUTPUT_FORMAT>
<FEW_SHOT_EXAMPLES>
Here we provide some examples:
1. Example #1
Input:
Thoughts:
Output:
...
</FEW_SHOT_EXAMPLES>
<RECAP>
Re-emphasize the key aspects of the prompt, especially the constraints, output format, etc.
</RECAP>
[[["이해하기 쉬움","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-09-03(UTC)"],[],[],null,["# Overview of prompting strategies\n\n| To see an example of prompt design,\n| run the \"Intro to Prompt Design\" notebook in one of the following\n| environments:\n|\n| [Open in Colab](https://colab.research.google.com/github/GoogleCloudPlatform/generative-ai/blob/main/gemini/prompts/intro_prompt_design.ipynb)\n|\n|\n| \\|\n|\n| [Open in Colab Enterprise](https://console.cloud.google.com/vertex-ai/colab/import/https%3A%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fgenerative-ai%2Fmain%2Fgemini%2Fprompts%2Fintro_prompt_design.ipynb)\n|\n|\n| \\|\n|\n| [Open\n| in Vertex AI Workbench](https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https%3A%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fgenerative-ai%2Fmain%2Fgemini%2Fprompts%2Fintro_prompt_design.ipynb)\n|\n|\n| \\|\n|\n| [View on GitHub](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/prompts/intro_prompt_design.ipynb)\n\nWhile there's no right or wrong way to design a prompt, there are common strategies that\nyou can use to affect the model's responses. Rigorous testing and evaluation remain crucial for\noptimizing model performance.\n\nLarge language models (LLM) are trained on vast amounts of text data to learn the patterns and\nrelationships between units of language. When given some text (the prompt), language models can\npredict what is likely to come next, like a sophisticated autocompletion tool. Therefore, when\ndesigning prompts, consider the different factors that can influence what a model predicts comes\nnext.\n\n### Prompt engineering workflow\n\nPrompt engineering is a test-driven and iterative process that can enhance model performance.\nWhen creating prompts, it is important to clearly define the objectives and expected outcomes for\neach prompt and systematically test them to identify areas of improvement.\n\nThe following diagram shows the prompt engineering workflow:\n\nHow to create an effective prompt\n---------------------------------\n\nThere are two aspects of a prompt that ultimately affect its effectiveness:\n*content* and *structure*.\n\n- **Content:**\n\n In order to complete a task, the model needs all of the relevant information associated with\n the task. This information can include instructions, examples, contextual information, and so\n on. For details, see [Components of a prompt](#components-of-a-prompt).\n- **Structure:**\n\n Even when all the required information is provided in the prompt, giving the information\n structure helps the model parse the information. Things like the ordering, labeling, and the use\n of delimiters can all affect the quality of responses. For an example of prompt structure, see\n [Sample prompt template](#sample-prompt-template).\n\nComponents of a prompt\n----------------------\n\nThe following table shows the essential and optional components of a prompt:\n\nDepending on the specific tasks at hand, you might choose to include or exclude some of the\noptional components. You can also adjust the ordering of the components and check how that can\naffect the response.\n\nSample prompt template\n----------------------\n\nThe following prompt template shows you an example of what a well-structured prompt might look\nlike:\n\nBest practices\n--------------\n\nPrompt design best practices include the following:\n\n- [Give clear and specific instructions](/vertex-ai/generative-ai/docs/learn/prompts/clear-instructions)\n- [Include few-shot examples](/vertex-ai/generative-ai/docs/learn/prompts/few-shot-examples)\n- [Assign a role](/vertex-ai/generative-ai/docs/learn/prompts/assign-role)\n- [Add contextual information](/vertex-ai/generative-ai/docs/learn/prompts/contextual-information)\n- [Use system instructions](/vertex-ai/generative-ai/docs/learn/prompts/system-instructions)\n- [Structure prompts](/vertex-ai/generative-ai/docs/learn/prompts/structure-prompts)\n- [Instruct the model to explain its reasoning](/vertex-ai/generative-ai/docs/learn/prompts/explain-reasoning)\n- [Break down complex tasks](/vertex-ai/generative-ai/docs/learn/prompts/break-down-prompts)\n- [Experiment with parameter values](/vertex-ai/generative-ai/docs/learn/prompts/adjust-parameter-values)\n- [Prompt iteration strategies](/vertex-ai/generative-ai/docs/learn/prompts/prompt-iteration)\n\nPrompt health checklist\n-----------------------\n\nIf a prompt is not performing as expected, use the following\nchecklist to identify potential issues and improve the prompt's performance.\n\n### Writing issues\n\n- **Typos:** Check keywords that define the task (for example, *sumarize* instead of *summarize*), technical terms, or names of entities, as misspellings can lead to poor performance.\n- **Grammar:** If a sentence is difficult to parse, contains run-on fragments, has mismatched subjects and verbs, or feels structurally awkward, the model may not properly understand the prompt.\n- **Punctuation:** Check your use of commas, periods, quotes, and other separators, as incorrect punctuation can cause the model to misinterpret the prompt.\n- **Use of undefined jargon:** Avoid using domain-specific terms, acronyms, or initialisms as if they have a universal meaning unless they are explicitly defined in the prompt.\n- **Clarity:** If you find yourself wondering about the scope, the specific steps to take, or the implicit assumptions being made, the prompt is likely unclear.\n- **Ambiguity:** Avoid using subjective or relative qualifiers that lack a concrete, measurable definition. Instead, provide objective constraints (for example, \"write a summary of 3 sentences or less\" instead of \"write a brief summary\").\n- **Missing key information:** If the task requires knowledge of a specific document, company policy, user history, or dataset, make sure that information is explicitly included within the prompt.\n- **Poor word choice:** Check the prompt for unnecessarily complex, vague, or verbose phrasing, as it could confuse the model.\n- **Secondary review:** If the model continues to perform poorly, have another person review your prompt.\n\n### Issues with instructions and examples\n\n- **Overt manipulation:** Remove language outside of the core task from the prompt that attempts to influence performance using emotional appeals, flattery, or artificial pressure. While first generation foundation models showed improvement in some circumstances with instructions like \"very bad things will happen if you don't get this correct\", foundation model performance will no longer improve and in many cases will get worse.\n- **Conflicting instructions and examples:** Check for this by auditing the prompt for logical contradictions or mismatches between instructions or an instruction and an example.\n- **Redundant instructions and examples:** Look through the prompt and examples to see if the exact same instruction or concept is stated multiple times in slightly different ways without adding new information or nuance.\n- **Irrelevant instructions and examples:** Check to see if all of the instructions and examples are essential to the core task. If any instructions or examples can be removed without diminishing the model's ability to perform the core task, they might be irrelevant.\n- **Use of [\"few-shot\"](/vertex-ai/generative-ai/docs/learn/prompts/few-shot-examples)\n examples:** If the task is complex, requires a specific format, or has a nuanced tone, make sure there are concrete, illustrative examples that show a sample input and the corresponding output.\n- **Missing output format specification:** Avoid leaving the model to guess the structure of the output; instead, use a clear, explicit instruction to specify the format and show the output structure in your few-shot examples.\n- **Missing role definition:** If you are going to ask the model to act in a specific role, make sure that role is defined in the system instructions.\n\n### Prompt and system design issues\n\n- **Underspecified task:** Ensure that the prompt's instructions provide a clear path for handling edge cases and unexpected inputs, and provide instructions for handling missing data rather than assuming inserted data will always be present and well-formed.\n- **Task outside of model capabilities:** Avoid using prompts that ask the model to perform a task for which it has a known, fundamental limitation.\n- **Too many tasks:** If the prompt asks the model to perform several distinct cognitive actions in a single pass (for example, 1. Summarize, 2. Extract entities, 3. Translate, and 4. Draft an email), it is likely trying to accomplish too much. Break the requests into separate prompts.\n- **Non-standard data format:** When model outputs must be machine-readable or follow a specific format, use a widely recognized standard like JSON, XML, Markdown or YAML that can be parsed by common libraries. If your use case requires a non-standard format, consider asking the model to output to a common format and then using code to convert the output.\n- **Incorrect Chain of Thought (CoT) order:** Avoid providing examples that show the model generating its final, structured answer before it has completed its step-by-step reasoning.\n- **Conflicting internal references:** Avoid writing a prompt with non-linear logic or conditionals that require the model to piece together fragmented instructions from multiple different places in the prompt.\n- **Prompt injection risk:** Check if there are explicit safeguards surrounding untrusted user input that is inserted into the prompt, as this can be a major security risk.\n\nWhat's next\n-----------\n\n- Explore examples of prompts in the [Prompt gallery](/vertex-ai/generative-ai/docs/prompt-gallery).\n- Learn how to optimize prompts for use with [Google models](/vertex-ai/generative-ai/docs/learn/models) by using the [Vertex AI prompt optimizer (Preview)](/vertex-ai/generative-ai/docs/learn/prompts/prompt-optimizer).\n- Learn about [responsible AI best practices and Vertex AI's safety filters](/vertex-ai/generative-ai/docs/learn/responsible-ai)."]]