Glossary Background Image

No Bad Questions About ML

Definition of Chain-of-thought prompting

What is chain-of-thought prompting?

Chain-of-thought prompting is a technique that guides language models to think step-by-step before answering. The model can avoid errors and produce more accurate results by breaking down complex problems into smaller, more manageable steps.

The primary value is that it allows the model to focus on one part of the problem at a time, rather than trying to process everything simultaneously.

Types of chain-of-thought prompting

Chain-of-thought (CoT) prompting has evolved into various innovative variants, each tailored to address specific challenges and enhance the model’s reasoning capabilities. Here are common types:

  • Zero-shot chain-of-thought — Leverages inherent knowledge.
    It uses the model's existing knowledge to solve problems without specific training.
    Main benefit: Valuable when dealing with new or diverse problem types.

    Example:
    Problem: "Identify the animal in this image."
    Prompt: "Analyze the image carefully. Consider the animal's features, such as its size, shape, and color. What animal do you think it is?"

  • Automatic chain-of-thought — Automates prompt creation.
    It reduces manual effort in crafting effective prompts.
    Main benefit: Makes CoT more accessible for a wider range of tasks.

    Example:
    Problem: "Write a summary of the following text."
    Prompt: "First, identify the main topic. Then, summarize the key points. Finally, write a concise summary."

  • Multimodal chain of thought — Incorporates multiple modalities.
    It combines text and images for complex reasoning.
    Main benefit: Processes and integrates diverse information.

    Example:
    Problem: "Analyze this image and text to determine the advertised product."
    Prompt: "First, examine the image for visual cues. Then, read the text for relevant information. Finally, combine the visual and textual cues to identify the advertised product."

How to use chain-of-thought prompting?

The technique of using a chain of thought involves crafting prompts that encourage the model to think through the problem systematically.

There are some strategies for CoT prompting:

  • Explicit instructions:
    Directly guide the model by providing step-by-step instructions within the prompt.
    Example: "Solve this equation: 2x + 5 = 13. First, isolate the variable. Then, divide both sides by 2"
  • Implicit instructions:
    Use simple prompts like "Let's think step-by-step" to encourage the model to reason out loud.
    Example: "Solve this equation: 2x + 5 = 13. Let’s think step-by-step."
  • Demonstrative examples:
    Provide examples of similar tasks to guide the model’s reasoning.
    Example: "Here's how to solve a similar problem: 2 + 3 * 4 = 14. Now, let's apply the same steps to solve 5 + 2 * 6 = ?"

For more complex tasks, you can combine these strategies. For instance, provide a few-shot example with explicit instructions to guide the model's reasoning.

Key Takeaways

  • Chain-of-thought prompting guides language models to think step-by-step, breaking down complex problems into smaller parts to improve accuracy and avoid errors.
  • Zero-shot chain-of-thought leverages the model’s existing knowledge to solve problems without prior training on similar examples.
  • Automatic chain-of-thought in large language models reduces the effort needed to craft prompts by automating prompt creation, making it easier to apply this technique across various tasks.
  • Multimodal chain of thought combines text and images for more complex reasoning, such as analyzing an image and accompanying text to determine the product being advertised.
  • Using chain-of-thought prompting effectively involves crafting prompts that encourage systematic thinking. One approach is to use Explicit Instructions, where clear, step-by-step guidance is provided. Another approach is Implicit Instructions, using prompts like "Let's think step-by-step" to guide the model through a reasoning process without specific steps. Lastly, demonstrative examples can be used, where similar examples are provided to help the model understand how to approach the task.

More terms related to ML