Few-Shot Prompting for Sentiment Analysis on Amazon Bedrock

AIF-C01 By islever Editorial Last updated

Short answer

A Provide examples of text passages with corresponding positive or negative labels in the prompt followed by the new text passage to be classified.

Question

A company wants to use a large language model (LLM) on Amazon Bedrock for sentiment analysis. The company wants to classify the sentiment of text passages as positive or negative.
Which prompt engineering strategy meets these requirements?
  1. Provide examples of text passages with corresponding positive or negative labels in the prompt followed by the new text passage to be classified. Correct Answer
  2. Provide a detailed explanation of sentiment analysis and how LLMs work in the prompt.
  3. Provide the new text passage to be classified without any additional context or examples.
  4. Provide the new text passage with a few examples of unrelated tasks, such as text summarization or question answering.

Key Takeaways

Few-shot prompting improves LLM accuracy by providing concrete examples of desired input-output pairs, guiding the model's behavior more effectively than zero-shot or irrelevant context.

Learn why few-shot prompting is the optimal strategy for sentiment analysis using large language models on Amazon Bedrock, ensuring accurate classification through labeled examples.

Common mistake: Choosing Option C (Zero-shot) because it seems simpler; however, without examples, the model may struggle with consistent classification boundaries compared to the guided approach of few-shot prompting.

Expert Analysis

The question asks for the prompt engineering strategy that meets the requirement of classifying sentiment using an LLM on Amazon Bedrock. The key constraint is the need for accurate classification of positive or negative sentiments.

Option A suggests providing examples of text passages with corresponding labels (few-shot prompting). Few-shot learning provides context and patterns, significantly improving model performance on specific tasks like sentiment analysis by demonstrating the expected input-output format and logic. This aligns with best practices for foundation models where explicit instructions alone may be insufficient for nuanced tasks.

Option B involves providing a detailed explanation of how LLMs work. This is irrelevant to the task of sentiment classification and wastes token context without guiding the model's output format or logic for this specific use case.

Option C suggests providing only the text passage without context (zero-shot prompting). While zero-shot can work for simple tasks, it often yields less consistent results than few-shot for specific classification boundaries, especially when precise labeling is required. It lacks the guidance provided by examples.

Option D includes examples of unrelated tasks. This introduces noise and confusion, potentially leading the model to prioritize the unrelated task patterns over the sentiment analysis goal, thereby degrading performance.

Therefore, Option A is the correct strategy as it leverages few-shot prompting to guide the model effectively.

Official Reference

https://docs.aws.amazon.com/bedrock/latest/userguide/prompting.html

This link opens the official vendor documentation in a new tab.

Exam Strategy

When asked about prompt engineering strategies for specific tasks, look for options that provide context or examples. Few-shot prompting is generally superior to zero-shot for complex or nuanced tasks because it reduces ambiguity. Avoid options that introduce irrelevant information or lack sufficient guidance.

Frequently Asked Questions

What is few-shot prompting?

Few-shot prompting is a technique where you provide the LLM with a few examples of the task (input-output pairs) in the prompt before asking it to perform the task on new data.

Why not use zero-shot prompting for sentiment analysis?

While zero-shot can work, few-shot provides clearer guidance and consistency by showing the model exactly what kind of labels and formatting are expected, reducing errors.

More AIF-C01 FAQ →

Community Votes

A
100%

100% of anonymous learners picked answer A. Votes are pick records left by other test-takers — they are not the verified answer.

Discussion 8 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 8

  1. Moon 👍 5 Answered A
    A: Provide examples of text passages with corresponding positive or negative labels in the prompt followed by the new text passage to be classified. Explanation: This strategy is known as few-shot prompting, where the prompt includes a few examples of labeled data (text passages with positive or negative sentiment) before asking the model to classify the new text passage. This helps the large language model (LLM) understand the task and align its output with the desired format. Why not the other options? B: Provide a detailed explanation of sentiment analysis and how LLMs work in the prompt: Explaining the concept of sentiment analysis is unnecessary for the model, as it does not improve the model's ability to classify text. C: Provide the new text passage to be classified without any additional context or examples: Without examples, the LLM might not correctly infer the task or format of the output, leading to inconsistent or incorrect results.
  2. Jessiii 👍 4 Answered A
    Provide examples of text passages with corresponding positive or negative labels in the prompt followed by the new text passage to be classified: This approach uses few-shot learning, where you give the model clear examples of text passages labeled with sentiment (positive or negative). By providing these examples in the prompt, the model is better able to understand the task and generalize it to classify the new text passage correctly. This is a common and effective strategy for tasks like sentiment analysis.
  3. jove 👍 4 Answered A
    Explanation: By providing examples of text passages along with their corresponding sentiment labels (positive or negative), the model can learn from these examples how to classify the sentiment of the new text passage effectively
  4. Johnny0107 👍 2 Answered A
    This approach is known as few-shot prompting, where you include a few labeled examples to guide the model on how to classify sentiment.
  5. 65703c1 👍 2 Answered A
    A is the correct answer
Show 3 more comments
  1. Gianiluca 👍 1 Answered A
    This approach uses few-shot learning, which is highly effective with large language models. By providing examples of text passages with their corresponding sentiment classifications, the LLM learns the context and pattern needed to classify the new passage.
  2. 85b5b55 👍 1 Answered A
    Set the proper label with a few examples to the prompts
  3. VIJAY K T 👍 1 Answered A
    A is correct

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Practice All AIF-C01 Questions

Access 100 questions with complete answers and detailed explanations.

View Full AIF-C01 Practice Test →

← Back to AIF-C01 Study Guide