AI Personal Learning
and practical guidance

Anthropic Tips Engineering Course - Chapter 6: Thinking Step by Step

academic program

How would you fare if someone woke you up out of the blue and immediately asked you several complex questions that you had to answer right away? Probably not as well as if you had time to think before answering.

Guess what? Claude is the same.


Giving Claude time to think progressively sometimes makes his answers more accurate., especially for complex tasks. However.Thinking must be externalized. You can't ask Claude Thinking but only outputting answers - in this case, thinking doesn't actually happen.

typical example

In the movie review tip below, the human reader can easily see that the second sentence contradicts the first. But Claude takes the word "irrelevant" too literally.

Example:

Enter:
Prompt
User: Is the sentiment of this movie review positive or negative?

This movie blew me away with its novelty and originality. In unrelated news, I have been living under a rock since 1900.

Output:
Claude's response
The sentiment of this movie review is positive.

The review mentions that the movie "blew me away with its novelty and originality", which indicates a very positive and enthusiastic response to the movie.

The second part of the review's statement about living under a rock since 1900 may be humorous or self-deprecating, but it does not negate the overall positive feelings about the film's qualities in the review.

To enhance Claude's answer, let'sAllow Claude to think before he answers.. We can help Claude process and think through the task by clearly listing the steps he needs to perform. Together with a bit of character prompting, this can give Claude a deeper understanding of the comments.

Example:

Input:
System Prompt
You are an astute reader of movie reviews.

Prompt
User: Is the sentiment of this review positive or negative? First, write the best argument for each side in the  and  XML tags, and then answer.

This movie blew me away with its novelty and originality. In completely unrelated news, I've been living under a rock since 1900.

Output:
Claude's Response
<positive-argument
- The comment implies that the movie has novelty and originality, which can be seen as positive qualities.
- The commenter's reference to living under a rock since 1900 can be interpreted as a humorous self-referential comment suggesting that the concept of the film may not be as novel or groundbreaking as it may initially appear, showing openness and self-awareness.
</positive-argument

<negative-argument
- The reviewer's admission that he has been living under a rock since 1900 suggests a lack of knowledge of recent trends and developments in the film industry, which may undermine the credibility of his assessment of the film's "novelty and originality".
- The sarcastic tone of the comment about living under a rock suggests that the reviewer may have viewed the movie as less original or creative and more mediocre.
</negative-argument

Based on the review, the sentiment seems to be more on the negative side. The reviewer's self-deprecating acknowledgement of his or her limited perspective and the underlying sarcasm in the tone suggests that they may not have found the movie as fresh and original as initially claimed.

Claude is sometimes sensitive to sequences.This example demonstrates the boundaries of Claude's ability to understand nuanced text when we swap the order of arguments from the previous example toNegative first, then positiveThis will change Claude's overall assessment to positive.

In most (but not all, confusingly) cases, theClaude is more likely to choose the second option., probably because its known from training data on the network that the second option is more likely to be correct.

Example:

Input:
Prompt
User: Is the sentiment of this comment negative or positive? First, please write the best argument for each side in the  and  XML tags, and then answer.

This movie blew me away with its novelty and originality. In completely unrelated news, I've been living under a rock since 1900.

Output:
Claude's Response
<negative-argument
The reviewer claims that the movie "shook them up", which may be seen as hyperbole, suggesting a lack of objectivity or critical analysis. In addition, the reviewer's admission that they have been living "under a rock" since 1900 calls into question their familiarity with contemporary cinema and may undermine the credibility of their assessment.
</negative-argument

<positive-argument
Reviewers' enthusiasm for the movie's "novelty and originality" suggests positive feelings, implying that the movie offers a unique and engaging experience. Reviewers' self-deprecating comments about living "under a rock" could be interpreted as a lighthearted acknowledgement of their limited exposure to modern cinema, which may make their praise of the film's innovative qualities even more compelling.
</positive-argument

Based on this review, the sentiment appears to be positive. The reviewer's praise of the film's "novelty and originality" and phrases such as "blew me away" suggest that they were extremely impressed with the film, even though the reviewer admits to having limited exposure to contemporary cinema.

Getting Claude to think can change Claude's answer from wrong to right. This is very simple in many cases where Claude makes a mistake!

Let's go through an example of a wrong answer by Claude and see how we can fix it by getting Claude to think progressively.

Example:

Input:
Prompt
User: Name a famous movie starring an actor born in 1956.

Output:
Claude's answer
This is a famous movie starring an actor born in 1956:

The Shawshank Redemption (1994), starring Tim Robbins. Tim Robbins was born on 10/31/1958.

Let's fix that by asking Claude to think progressively, this time using the  Tags.

Example:

Input:
Prompt
User: Name a famous movie starring an actor born in 1956. First think of some actors and their birth years in the  tag, then give your answer.

Output:
Claude's answer
Here is a brainstorm of some actors and their birth years:

<brainstorm
- Tom Hanks (1956)
- Denzel Washington (1954)
- Julia Roberts (1967)
- Harrison Ford (1942)
- Meryl Streep (1949).
</brainstorm

A famous movie starring an actor born in 1956 is:

Forrest Gump, starring Tom Hanks.

If you're ready to work on the chapter exercises, click on the links below. If you want to try any of the examples in this lesson, scroll down!

practice

Exercise 6.1 - Sorting Email

In this exercise, we will instruct Claude to categorize email into the following categories:
(A) Pre-sale issues
(B) Damaged or defective items
(C) Billing issues
(D) Other (please explain)

In the first part of the exercise, the yellow (color) The prompt in the highlighted prompt template box is changed to have Claude output the correct categorization, and the Output classification only. Your answer needs to include the correctly chosen letter (A - D) with parentheses, and the category name.

See "Correct Categorization" in Column K to find out which emails should go into which category. If your prompt produces the correct answer, Claude's response will change to greenerThe

Tip: Use techniques such as foresight that you learned in this chapter! Remember.Thinking only counts when it is epiphenomenal!

Example:

Input:
Prompt Template
User: Please categorize this email as follows:{{EMAIL}}

Do not include any additional words other than category.

<categories
(A) Pre-sales questions
(B) Damaged or defective items
(C) Billing issues
(D) Other (please explain)
</categories
Assistant: (

Variables:
Input - {{EMAIL}}
---
Hi - my Mixmaster 4000 is making strange noises when operating. And it smells a bit smoky and plastic, like burnt out electronics. I need to replace it.
---
Can I use my Mixmaster 4000 to mix paint, or is it only for mixing food?
---
I've been canceling for 4 months now, why am I still being charged every month! What the heck is going on?
---
I'm not good with computers, how did I get here. Help.

Output:
Claude's response
---.
B) Damaged or defective items
---
D) Other
---
C) Billing Issues
---
D) Other (seeking technical support)

Correct Categorization
---
B
---
D or A
---
C
---
D

Additional questions: It's time to think like a data scientist! Why is the second email the hardest to categorize correctly? If categorization is controversial for humans, then Claude is likely to be difficult to categorize as well!

Exercise 6.2 - Formatting Mail Sorting

In this exercise, we will refine the output of the above prompts to get the formatted answers we expect.

Use your favorite output formatting technique so that Claude wraps only the correctly sorted letters in " " tags. If you forget the correct letter for each email, refer to the exercise above.

If your prompt produces the correct answer, Claude's response will turn green. For example, the answer to the first e-mail should contain the exact string "B".

Tip: As a first step, copy the final correct version of the prompt from Exercise 1 into the Highlighted Prompt Template box below. Then edit and refine your initial prompt from there.

Attention: In this exercise, you can see Claude is a powerful cue assessment tool in Sheets. Using replacements, you can easily check how a cue behaves in multiple contexts by modifying only one cue and getting multiple responses from Claude. Here, we evaluated four instances of the cue, but you can easily extend this evaluation to any number of lines desired.

Example:

Input:
Prompt Template
User: Please categorize this email in the following category: {{EMAIL}}

Do not include any additional words other than category. Please think step-by-step before replying.

<categories
(A) Pre-sale questions
(B) Damaged or defective items
(C) Billing problems
(D) Other (please explain)
</categories

Answer only with the letters wrapped in the  tag, e.g. B.

Variables:
Enter {{EMAIL}}
---
Hi -- My Mixmaster 4000 is making strange noises when I operate it. It also kind of smokes and smells plastic, like the electronics are burning. I need a replacement part.
---
Can I use my Mixmaster 4000 to mix paint, or is it only good for mixing food?
---
I've been waiting 4 months for my monthly fee to end after canceling! What the heck is going on?
---
How did I get here? I'm not good with computers. Help.

Output:
Claude's response.
---
Step-by-step analysis of the email:
1. the email is about a problem with the Mixmaster 4000 product, indicating that it is a damaged or defective item.
2. the email does not mention pre-sales issues, billing issues or other topics.

B
---
In order to categorize this email, I will consider the following:

1. the email is inquiring about the intended use of a product, i.e., the Mixmaster 4000. this suggests that this is a pre-sales question, and not related to damaged or defective items or billing issues.

A
---
Based on the content of the email, the appropriate category is:

C
---
Analyze the content of the email:
- The e-mail makes no mention of pre-sale problems, damaged or defective items, or billing issues.
- The e-mail expresses a general lack of computer skills and a need for help.

Based on the information provided, the appropriate category is:

D
AI Easy Learning

The layman's guide to getting started with AI

Help you learn how to utilize AI tools at a low cost and from a zero base.AI, like office software, is an essential skill for everyone. Mastering AI will give you an edge in your job search and half the effort in your future work and studies.

View Details>
May not be reproduced without permission:Chief AI Sharing Circle " Anthropic Tips Engineering Course - Chapter 6: Thinking Step by Step

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish