Sign In
프롬프트 작성팁

프롬프트와 구분 기호

Sujin_Kang
Category
Empty
Status
Empty
Assignee
Empty

>> '프롬프트' 와 '구분 기호'

기호만 잘 사용해도 답변의 품질이 달라진다.
프롬프트 작성에서 기호 사용은 중요합니다. 구조화 때문인데요.
구조가 명확해지면, 모델이 불필요한 중복 설명을 하거나 엉뚱한 부분을 답변하는 확률이 줄어듭니다. 사용자가 어떤 기대 형식을 가지고 있는지도 모델에게 분명하게 전달할 수 있어요. 보안 측면에서도, 사용자 입력을 구분자로 묶어 프롬프트 주입 공격을 예방하기도 합니다.
이런 기호를 구분자 (Delimiters) 라고 합니다.
구분자란?
프롬프트 내부에서 서로 다른 부분을 명확히 구별하기 위해 사용하는 특수 문자열이나 기호. """ (트리플 따옴표), ` (트리플 백틱), --- (트리플 대시), <...> (각종 꺾쇠 괄호 또는 XML 태그) 등.
→ 구분자 사용은 프롬프트 엔지니어링의 기본 기법입니다. OpenAI 와 Anthropic 등의 모델사에서는 프롬프트에 기호 사용을 권장합니다.
✅ 구분자 사용이 LLM 응답 품질에 미치는 영향과 관련 연구
최근 2-3년간 프롬프트 형식이 LLM에 미치는 연구들이 진행되고 있습니다. 소형언어 모델일 수록 프롬프트의 형식이 LLM에 성능에 미치는 영향이 큽니다.
Sclar (2023): 의미는 동일하고 표현이 다른 프롬프트 성능 편차 심함 입증.
Voronov (2024): 프롬프트 템플릿을 잘못 선택하면 가장 성능이 좋은 모델도 정답률이 떨어짐을 입증.
He 등(2024): GPT 시리즈 모델의 프롬프트 표기법에 따라 성능차 심함 입증

기호를 언제 사용하면 좋을까?

1.
텍스트 블록이 많은 경우
긴 문장이나 여러 섹션을 다루는 경우, ###, --- 등을 활용해 구분하기.
2.
질문과 답변을 명확히 분리하고 싶을 때
“질문: ... 답변: ...” 형태의 프롬프트에서 구분자를 넣으면 답변이 더 깔끔해짐
3.
목록, 변수, 옵션 등을 강조하고 싶을 때
대괄호 [ ] 또는 중괄호 { }로 명시해주면 모델이 데이터를 받아들이는 방식이 개선됨
4.
규칙적인 포맷 요구
JSON 형태, 목록 형태 등 특정 형식을 요구할 때는 { }, [ ] 등 구분자 사용 필수

자주 쓰는 기호 사용법

### (샾 기호, 세 개)

목적: 텍스트 내 큰 구분을 만들어 주거나, 섹션(Section)을 분리할 때 사용
사용 예시:
“### 요약(Summary) ###”
“### 주의사항 ###”
→ 프롬프트에서 긴 텍스트를 다룰 때, ###로 섹션을 나눠주면 모델이 각 섹션을 독립적으로 인식할 수 있어요. 예를 들어, 지문이 길고 그 뒤에 문제를 낼 때, ### 문제 ###와 같은 방식을 쓰면 문제 구간을 명확히 분리할 수 있습니다.
🧷
장점
시각적으로 한 덩어리씩 구분되어 구조가 명확해짐
모델이 ‘지금부터 중요한 구문이 시작된다’고 인식하기 쉽다

[ ] (대괄호)

목적: 특정 텍스트를 구분하거나, 옵션, 변수 등을 표시할 때 사용, 혹은 제목을 만들어 줄 때 사용
사용 예시:

“[사용자 입력] 내용을 여기에 넣어주세요.”
“명령을 실행할 때 [옵션]을 적용해 주세요.”

→ 프롬프트에서 대괄호를 사용할 때는 “질문[1], 질문[2], 질문[3]” 등처럼 목록을 묶어주거나, 사용자 입력 값을 명확하게 표시해주는 것입니다. 이를 통해 모델이 “이 부분이 반드시 필요하구나” 하고 더 명확하게 인식하게 됩니다.
🧷
장점
텍스트와 텍스트 사이에 구체적인 범위를 지정해주어 의미가 명료해짐


{ } (중괄호)

목적: 텍스트 내에서 변수나 속성, JSON 형태의 구조를 표시할 때 활용
사용 예시:

“JSON 형식으로 결과를 반환해 주세요. 예: { “name”: “수진”, “age”: 30 }”
“다음과 같은 키워드를 포함해 주세요: {키워드1}, {키워드2}”
→ 프롬프트 엔지니어링에서 중괄호는 종종 JSON 형태의 구조 데이터를 표현할 때 사용해요.
예를 들어, ChatGPT 같은 모델에 “다음 정보를 JSON으로 보내줘” 라고 요청하면서 { } 구문 안에 키-값 형태로 구성해달라고 지정하면, 모델이 좀 더 안정적으로 JSON 형식을 유지해서 응답하는 경우가 많습니다.
🧷
장점
JSON, 파라미터, 속성 등 구조화된 표현을 명시적으로 만들 수 있음
스크립트나 코드처럼 구체적인 형식을 전달할 때 유용

--- (하이픈 세 개)

목적: 텍스트 구분선(Rule)처럼 사용, 또는 섹션 나누기
사용 예시:

“--- 요약 ---”
“질문: ... 답변: ... --- 추가 예시 ---”

→ ‘하이픈 세 개’는 MarkDown 문법에서 구분선(Horizontal Rule) 역할을 하거나, 의미적으로도 “이 지점에서 내용이 끊겨요”라는 신호로 자주 써요. ChatGPT와 같은 모델은 이러한 형태를 확인하면, “이 전후로 내용이 다른 섹션이구나”라고 이해하는 데 도움이 돼요.
🧷
장점
구분선처럼 보기 좋아, 가독성 향상
분리된 섹션이라는 것을 직관적으로 표현 가능


-> (화살표)

목적: 순서 혹은 결과를 나타내는 화살표로 사용, “이후에”라는 연속성을 표현
예시:
“단계별 절차를 설명해 주세요: 1) 설치 -> 2) 구성 -> 3) 실행”
“키워드 -> 상세 설명 순서로 답변해 주세요.”
→ 화살표(->)는 A에서 B로 이어진다는 흐름이나, 단계적 혹은 원인과 결과를 나타낼 때 종종 사용됩니다. 모델과의 대화를 구조화할 때 “어떤 대상 -> 그 대상에 대한 설명” 식으로 작성하면, 응답을 받을 때도 해당 형식이 유지되는 경향이 높습니다.
🧷
장점
흐름, 단계, 인과관계 등을 직관적으로 표현
문장을 길게 풀어쓰지 않고 간단히 구조화하기 좋아, 토큰 절감 및 효용 향상

프롬프트에 기호를 사용한 예시

예시 1. 코드 오류 설명 프롬프트
### 질문 ### [1] 다음 코드를 실행하면 발생할 수 있는 오류가 무엇인지 알려주세요. [2] 오류를 해결하는 방법도 함께 안내해주세요. ### 가이드라인 ### - 답변 시 간결하게 요약한 뒤, 예시 코드를 함께 제공해 주세요. - 오류 메시지는 {에러 메시지} 형태로 표기해 주세요. ### 예시 ### 코드 예시: ```python print("Hello World")
/code
예시 2. OpenAI 메타 프롬프트 생성 프롬프트
from openai import OpenAI client = OpenAI() META_PROMPT = """ Given a task description or existing prompt, produce a detailed system prompt to guide a language model in completing the task effectively. # Guidelines - Understand the Task: Grasp the main objective, goals, requirements, constraints, and expected output. - Minimal Changes: If an existing prompt is provided, improve it only if it's simple. For complex prompts, enhance clarity and add missing elements without altering the original structure. - Reasoning Before Conclusions**: Encourage reasoning steps before any conclusions are reached. ATTENTION! If the user provides examples where the reasoning happens afterward, REVERSE the order! NEVER START EXAMPLES WITH CONCLUSIONS! - Reasoning Order: Call out reasoning portions of the prompt and conclusion parts (specific fields by name). For each, determine the ORDER in which this is done, and whether it needs to be reversed. - Conclusion, classifications, or results should ALWAYS appear last. - Examples: Include high-quality examples if helpful, using placeholders [in brackets] for complex elements. - What kinds of examples may need to be included, how many, and whether they are complex enough to benefit from placeholders. - Clarity and Conciseness: Use clear, specific language. Avoid unnecessary instructions or bland statements. - Formatting: Use markdown features for readability. DO NOT USE ``` CODE BLOCKS UNLESS SPECIFICALLY REQUESTED. - Preserve User Content: If the input task or prompt includes extensive guidelines or examples, preserve them entirely, or as closely as possible. If they are vague, consider breaking down into sub-steps. Keep any details, guidelines, examples, variables, or placeholders provided by the user. - Constants: DO include constants in the prompt, as they are not susceptible to prompt injection. Such as guides, rubrics, and examples. - Output Format: Explicitly the most appropriate output format, in detail. This should include length and syntax (e.g. short sentence, paragraph, JSON, etc.) - For tasks outputting well-defined or structured data (classification, JSON, etc.) bias toward outputting a JSON. - JSON should never be wrapped in code blocks (```) unless explicitly requested. The final prompt you output should adhere to the following structure below. Do not include any additional commentary, only output the completed system prompt. SPECIFICALLY, do not include any additional messages at the start or end of the prompt. (e.g. no "---") [Concise instruction describing the task - this should be the first line in the prompt, no section header] [Additional details as needed.] [Optional sections with headings or bullet points for detailed steps.] # Steps [optional] [optional: a detailed breakdown of the steps necessary to accomplish the task] # Output Format [Specifically call out how the output should be formatted, be it response length, structure e.g. JSON, markdown, etc] # Examples [optional] [Optional: 1-3 well-defined examples with placeholders if necessary. Clearly mark where examples start and end, and what the input and output are. User placeholders as necessary.] [If the examples are shorter than what a realistic example is expected to be, make a reference with () explaining how real examples should be longer / shorter / different. AND USE PLACEHOLDERS! ] # Notes [optional]
/code
예시 3. Claude CS Feedback 프롬프트
Our CS team is overwhelmed with unstructured feedback. Your task is to analyze feedback and categorize issues for our product and engineering teams. Use these categories: UI/UX, Performance, Feature Request, Integration, Pricing, and Other. Also rate the sentiment (Positive/Neutral/Negative) and priority (High/Medium/Low). Here is an example: <example> Input: The new dashboard is a mess! It takes forever to load, and I can’t find the export button. Fix this ASAP! Category: UI/UX, Performance Sentiment: Negative Priority: High</example> Now, analyze this feedback: {{FEEDBACK}}
프롬프트 “최적 템플릿”은 모델이나 과제마다 제각기 다릅니다.
한 모델에서 잘 먹힌 형식을 다른 모델(심지어 같은 계열의 모델)에게 적용해도 효과가 없거나 악화 될 수 있습니다.
모든 모델에게 통하는 보편적인 구분자 형식은 존재 하지 않습니다.
그래서 프롬프트는 시도와 경험이 중요합니다.

>> 기호 사용 관련 대표 연구 논문 및 주요 내용

Sclar et al. (ICLR 2024) – “How I learned to start worrying about prompt formatting”: 프롬프트 형식 변화에 대한 LLM의 민감도를 정량화한 연구. 의미가 동일한 프롬프트라도 콜론 개수, 줄바꿈 등 형식상의 사소한 차이로 결과가 천차만별이 될 수 있음을 보여주었고, 일부 모델에서는 최대 76%p 성능 차이까지 관찰.
https://arxiv.org/abs/2310.11324


Voronov et al. (Findings of ACL 2024) – “Mind Your Format: Towards Consistent Evaluation of In-Context Learning Improvements”: few-shot 프롬프트 템플릿 간의 성능 변화를 대규모로 실증. 프롬프트 템플릿에 따라 모델 성능 순위가 뒤바뀌는 현상을 확인했으며, 형식을 잘못 고르면 최첨단 모델도 출력이 랜덤 추측 수준으로 떨어질 수 있다고 밝힘.
He et al. (ArXiv 2024) – “Does Prompt Formatting Have Any Impact on LLM Performance?”: OpenAI GPT-3.5 및 GPT-4를 대상으로 프롬프트 포맷팅(Plain vs. Markdown vs. JSON vs. YAML)의 영향을 측정. GPT-3.5-Turbo 모델의 경우 프롬프트를 Markdown 형식에서 일반 텍스트로 바꾸기만 해도 성능이 크게 향상되는 등 (예: FIND 데이터셋에서 큰 폭의 정확도 상승) 포맷에 매우 민감.
#promptengineering #prompttemplate #delimeters #llmprompting #prompt #structuredprompt #프롬프트작성법
Subscribe to 'sujin-prompt-engineer'
Subscribe to my site to be the first to receive notifications and emails about the latest updates, including new posts.
Join Slashpage and subscribe to 'sujin-prompt-engineer'!
Subscribe
7
👍
28
😍
9
S
shofar
감사합니다
🍀
1
J
Jean_Browwn
사소한 것 같지만, 이 사소한 것들이 만나서 정확한 의미를 만든다는 것이 중요하다고 생각됩니다 :)
🍀
1
T
Two_Jay
정말 감사합니다 :)
🍀
1
N
Noel
감사합니다!
Joon-hee
불찰주야 늘 감사드립니다.
이성국
감사합니다.
서민탁
아낌없이 퍼 주시는 박사님, 늘~ 감사하고 고마운 마음 드립니다.
See latest comments