🎓 A1Learner
🔍
0 of 50 lessons completed

Prompt Engineering: Decomposition

Decomposition means breaking one big task into small prompts, each with one job. The small prompts run in order, and each one hands its answer to the next.

Step one: classify the message

The first prompt has one job. Name the kind of message.

Classify this customer message as tracking, return, policy, product or damaged item. Message: My mug arrived chipped. What do I do?

Step two: look up the facts

The second prompt has one job. State the policy for the kind of message.

The customer message is about a damaged item. The ShopStack damaged-item policy says a photo is required, and the customer can choose a replacement or a refund. State the policy in one sentence.

Step three: write the answer

The third prompt has one job. Turn the facts into a reply.

Write a short reply to a customer whose mug arrived chipped. The policy says a photo is required, and the customer can choose a replacement or a refund. Keep the reply to two sentences.

Example

Prompt 1: Classify this customer message as tracking, return, policy, product or damaged item. Message: I ordered the Hearthstone Desk Lamp yesterday and it still says processing. When will it ship? Prompt 2: The message is about an order that is still processing. Order 1043 belongs to Tom. It was placed yesterday and is still processing, not yet shipped. Delivery takes 2 to 4 business days. State the facts in one sentence. Prompt 3: Write a short reply to Tom using the facts above. Keep the reply to two sentences.

Key points

  • Decomposition splits a big task into small prompts.
  • Each small prompt has one job. One job is easier to get right than five.
  • A support reply splits into three jobs. Classify the message, look up the facts, then write the answer.
  • The answer from one prompt becomes the input of the next.
  • A mistake in one small prompt is easy to find. A mistake in one big prompt hides.

This example runs the three-step chain against the local model and shows the replies it gave. Each prompt has one job, and each answer feeds the next.

Note

Split at the natural joints. Classify, look up and answer are three natural joints for a support reply.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

What are the three steps of a support reply in this lesson?