프롬프트란 무엇인가요? - Amazon Bedrock

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

프롬프트란 무엇인가요?

프롬프트는 사용자가 제공하는 특정 입력 세트로, Amazon Bedrock의 LLM이 주어진 태스크 또는 명령에 대해 적절한 응답 또는 출력값을 생성하도록 안내합니다.

User Prompt: Who invented the airplane?

이 프롬프트에서 쿼리하면 다음과 같은 출력을 Titan 제공합니다.

Output: The Wright brothers, Orville and Wilbur Wright are widely credited with inventing and manufacturing the world's first successful airplane.

(프롬프트 출처: AWS, 사용 모델: Amazon Titan Text)

프롬프트의 구성 요소

프롬프트 하나에는 LLM으로 수행하려는 태스크 또는 명령, 태스크의 컨텍스트(예: 관련 도메인에 대한 설명), 데모 예제, Amazon Bedrock에서 LLM이 응답에 사용할 입력 텍스트 등 여러 가지 구성 요소가 포함됩니다. 사용 사례, 데이터 가용성, 태스크에 따라 프롬프트는 이러한 하나 이상의 구성 요소를 조합해야 합니다.

리뷰 요약을 요청하는 Titan 다음 예제 프롬프트를 생각해 보십시오.

User Prompt: The following is text from a restaurant review: “I finally got to check out Alessandro’s Brilliant Pizza and it is now one of my favorite restaurants in Seattle. The dining room has a beautiful view over the Puget Sound but it was surprisingly not crowded. I ordered the fried castelvetrano olives, a spicy Neapolitan-style pizza and a gnocchi dish. The olives were absolutely decadent, and the pizza came with a smoked mozzarella, which was delicious. The gnocchi was fresh and wonderful. The waitstaff were attentive, and overall the experience was lovely. I hope to return soon." Summarize the above restaurant review in one sentence.

(프롬프트 출처: AWS)

이 프롬프트에 따라 레스토랑 리뷰를 한 줄로 간결하게 요약하여 Titan 응답합니다. 리뷰는 필요에 따라 주요 사실을 언급하고 주요 요점을 전달합니다.

Output: Alessandro's Brilliant Pizza is a fantastic restaurant in Seattle with a beautiful view over Puget Sound, decadent and delicious food, and excellent service.

(사용 모델: 아마존 Titan 텍스트)

이러한 유형의 출력값에는 Summarize the above restaurant review in one sentence라는 명령과 I finally got to check out ...이라는 리뷰 텍스트가 모두 필요했습니다. 둘 중 하나가 없다면 모델은 분별력 있는 요약을 생성하기에 충분한 정보를 갖지 못합니다. '명령'은 LLM에게 무엇을 해야 하는지 알려주는 역할을 하며, 텍스트는 LLM을 작동시키는 '입력값'입니다. '컨텍스트'(The following is text from a restaurant review)는 출력값을 공식화할 때 입력값을 사용하도록 모델을 안내하는 추가 정보와 키워드를 제공합니다.

아래 예제에서 Context: Climate change threatens people with increased flooding ... 텍스트는 LLM이 Question: What organization calls climate change the greatest threat to global health in the 21st century?”라는 질문에 답하는 '태스크'를 수행하는 데 사용할 수 있는 '입력'입니다.

User prompt: Context: Climate change threatens people with increased flooding, extreme heat, increased food and water scarcity, more disease, and economic loss. Human migration and conflict can also be a result. The World Health Organization (WHO) calls climate change the greatest threat to global health in the 21st century. Adapting to climate change through efforts like flood control measures or drought-resistant crops partially reduces climate change risks, although some limits to adaptation have already been reached. Poorer communities are responsible for a small share of global emissions, yet have the least ability to adapt and are most vulnerable to climate change. The expense, time required, and limits of adaptation mean its success hinge on limiting global warming. Question: What organization calls climate change the greatest threat to global health in the 21st century?

(프롬프트 출처: https://en.wikipedia.org/wiki/Climate_change)

AI21 Labs프롬프트에 제공된 컨텍스트에 따라 올바른 조직 이름을 포함한 쥬라기 응답.

Output: The World Health Organization (WHO) calls climate change the greatest threat to global health in the 21st century.

(사용 모델: AI21 Labs Jurassic-2 Ultra v1)

퓨샷 프롬프팅 vs. 제로샷 프롬프팅

몇 가지 예시를 제공하면 LLM이 출력값을 더욱 잘 보정하여 사용자의 기대치를 충족하는 데 유용할 수 있습니다. 이를 퓨샷 프롬프팅 또는 컨텍스트별 학습이라고도 합니다. 여기서 '샷'은 예시 입력값과 원하는 출력값이 한 쌍을 이루는 것을 뜻합니다. 설명하자면, 우선 아래의 예시는 제로샷 감정 분류 프롬프트입니다. 여기에서는 프롬프트 텍스트에 입력-출력 쌍의 예가 제공되지 않았습니다.

User prompt: Tell me the sentiment of the following headline and categorize it as either positive, negative or neutral: New airline between Seattle and San Francisco offers a great opportunity for both passengers and investors.

(프롬프트 출처: AWS)

Output: Positive

(사용 모델: 아마존 Titan 텍스트)

다음은 감정 분류 프롬프트의 퓨샷 버전입니다.

User prompt: Tell me the sentiment of the following headline and categorize it as either positive, negative or neutral. Here are some examples: Research firm fends off allegations of impropriety over new technology. Answer: Negative Offshore windfarms continue to thrive as vocal minority in opposition dwindles. Answer: Positive Manufacturing plant is the latest target in investigation by state officials. Answer:

(프롬프트 출처: AWS)

Output: Negative

(사용 모델: 아마존 Titan 텍스트)

다음 예시에서는 Anthropic Claude 모델을 사용합니다. AnthropicClaude모델을 사용할 때는<example></example> 태그를 사용하여 데모 예제를 포함하는 것이 좋습니다. 또한 예제에서 H:A: 같은 서로 다른 구분 기호를 사용하여 전체 프롬프트에서 구분 기호 Human:Assistant:와 혼동되는 걸 방지하는 것이 좋습니다. 마지막 몇 장의 예제에서는 최종 A: 예제를 생략하고 대신 답을 Anthropic Claude 생성하라는 메시지가 표시된다는 점에 유의하세요. Assistant:

User prompt: Human: Please classify the given email as "Personal" or "Commercial" related emails. Here are some examples. <example> H: Hi Tom, it's been long time since we met last time. We plan to have a party at my house this weekend. Will you be able to come over? A: Personal </example> <example> H: Hi Tom, we have a special offer for you. For a limited time, our customers can save up to 35% of their total expense when you make reservations within two days. Book now and save money! A: Commercial </example> H: Hi Tom, Have you heard that we have launched all-new set of products. Order now, you will save $100 for the new products. Please check our website. Assistant: Output: Commercial

(프롬프트 출처: AWS, 사용된 모델:) Anthropic Claude

프롬프트 템플릿

프롬프트 템플릿은 교환 가능한 콘텐츠가 포함된 프롬프트의 형식을 지정합니다. 프롬프트 템플릿은 분류, 요약, 질문 응답 등과 같은 다양한 사용 사례에 LLM을 사용할 수 있도록 해주는 '레시피'입니다. 프롬프트 템플릿에는 지침, 퓨샷 예제, 정해진 사용 사례에 적합한 특정 컨텍스트 및 질문이 포함될 수 있습니다. 아래 예제는 Amazon Bedrock 텍스트 모델을 사용하여 퓨샷 감정 분류를 수행하는 데 사용할 수 있는 템플릿입니다.

Prompt template: """Tell me the sentiment of the following {{Text Type, e.g., “restaurant review”}} and categorize it as either {{Sentiment A}} or {{Sentiment B}}. Here are some examples: Text: {{Example Input 1}} Answer: {{Sentiment A}} Text: {{Example Input 2}} Answer: {{Sentiment B}} Text: {{Input}} Answer:"""

Amazon Bedrock에서 LLM을 사용할 경우 사용자는 이 템플릿을 복사한 후 붙여 넣을 수 있습니다. 이렇게 하면 사용자의 고유한 텍스트와 퓨샷 예제가 입력되어 프롬프트가 완료됩니다. 이 섹션에서는 추가 템플릿이 제공됩니다.

참고

이중 중괄호 {{ and }}는 템플릿에서 데이터별 정보를 입력할 위치를 표시하며, 이를 프롬프트 텍스트에 포함해서는 안 됩니다.

API 호출을 통한 Amazon Bedrock LLM 사용에 대한 중요 참고 사항

API 직접 호출을 통해 Amazon Bedrock에서 LLM에 액세스할 경우, 이전 상호 작용이 현재 프롬프트에 포함되어 있지 않는 한 이전 프롬프트와 이전 요청이 리콜되지 않는다는 점에 유의하세요. 이는 대화식 상호 작용이나 후속 요청에 필요할 수 있습니다.

Amazon Bedrock 텍스트 플레이그라운드 대신 API 호출을 사용하여 Anthropic Claude 모델에 액세스하는 경우 프롬프트를 대화형 스타일로 래핑하여 원하는 응답을 얻을 수 있습니다 (TitanText 및 AI21 Labs Jurassic 모델 패밀리의 경우 필요하지 않음). 아래 예제에서는 대화식 프롬프트를 보여줍니다.

User prompt: Human: Describe where sea otters live in two sentences. Assistant: Output: Here is a two sentence description of where sea otters live: Sea otters live in the northern Pacific Ocean along the coasts of Russia, Alaska, Canada, and the continental United States. They prefer coastal habitats like rocky shores, kelp forests, and estuaries where they have access to shallow, nearshore waters.

(프롬프트 출처:, 사용된 모델:) AWSAnthropic Claude

프롬프트의 주요 내용이 \n\nHuman: {{Main Content}}\n\nAssistant:처럼 래핑되어 있는지 확인합니다. AnthropicClaude모델의 경우 API를 통해 전송되는 프롬프트에는\ n\ n Human: 및 가 포함되어야 합니다. \n\nAssistant:

대화형 모드를 켜려면 모델에 메시지를 Titan 표시할 때의 User: {{}} \n Bot: 형식을 사용할 수 있습니다.