How to Get Better Outputs with Anthropic's Claude AI Chatbots?

How to Get Better Outputs with Anthropic's Claude AI Chatbots?

By Albert Mao

Feb 11, 2024

This article explains the specifics of Claude LLM and offers practical tips and tricks for designing prompting techniques when working with Anthropic's latest Claude AI chatbots.

Developed by the San Francisco-based Anthropic team led by former OpenAI executives, the Claude AI chatbots are unique in many ways. While the prompting for Claude follows the same principles and logic as designing prompts for other AI chatbots, like ChatGPT, there are important differences that should be kept in mind for the best results. Keep reading to learn more about key prompting techniques that can help Claude deliver more accurate responses. 

Claude vs ChatGPT and other LLMs

Similar to ChatGPT and other large language models (LLM), Claude is an AI chatbot capable of natural, human-like conversations, as well as code-writing-summarization and multiple other tasks. With its 200K token context window, Claude 2.1 excels in processing long, complex documents and is able to read 150,000 words in one prompt. 

Claude is built as a conversational assistant based on a large language model. Acting in this role, Claude provides responses in the form of a dialogue between a User (Human) and an AI Assistant (Assistant). Meanwhile, Anthropic's API allows users to extend their prompt to both parts of the dialogue, including User input and questions as well as  Assistant responses. This allows to fine-tune the model's responses directly in the Assistant part of the API. Let's check other Claude differences by reviewing prompting techniques recommended by the developers.

Specific Tips for Getting Better Outputs with Claude

As a large language model, Claude works well with most popular prompting approaches, including:

Still, there are a few tricks specific to Claude, helping it to produce better output.

Use XML tags

Since Claude was fine-tuned to recognize XML tags within prompts, the developer suggests adding XML tags to give your prompt a better structure. Such structuring helps Claude to differentiate various parts of the prompt, which leads to higher accuracy in generating responses.

Here are examples of tags that can be used within your prompts for Claude AI chatbots:

  • <doc> ..</doc>

  • <text>  ..</text>

  • <question>..<>question>

and so on.

For the purposes of prompting for Claude, you can choose any name for your tags, such as "doc," "text," or anything else. The name of the tag does not matter as long as you enclose the relevant portion of the prompt using the <tagname> </tagname> format.

Provide Documents and Other Context Before Instructions

Anthropic prides itself on improving Claude's abilities to summarize long, complex documents that require high accuracy. At the same time,  developers underscore that Claude's superior document analytic capabilities can be fully invoked when the documents and context precede the instruction in the prompt.

Prompt example:

Here is a legal document for your review. Read the document carefully because you will need to answer a question about it.



What are the legal consequences for the breaches mentioned in the document?

Reduce the Verbosity of Claude's Responses

Claude 2.1. is known not only for its ability to analyze long documents but also for its propensity to produce unasked and verbose responses. To cut on the model's "chattiness," Anthropic suggests instructing Claude how to start its responses by expanding the prompt to the Assistant's part of the API, as shown below.

Prompt example:

When we insert <summarize> to the Assistant's role, we prevent Claude's verbosity and chatty tendencies, asking for a specific response. By keeping the <summarize> tag open without using the closing tag </summarize, we let the model proceed with the output. 

Note how the above prompt assigns Claude a persona and asks it to stay in that persona, which increases the model's chances to predict a more relevant answer. 

Prevent Hallucination by Letting the Model Admit It Has No Answer

As a helpful assistant, Claude might try to come up with a made-up answer even when it lacks the necessary information for a meaningful response. One of the methods to reduce these hallucinations is to let the model admit it has no answer in certain cases. For example, "Answer the question only if you know the answer. When you don't know the answer or cannot make a well-informed guess, say that you don't know."

Ask Claude to Think Before Answering

Anthropic specifically says that Claude works by sequence prediction. To help the model zero in on the most relevant context while making predictions working with long documents, the developers suggest a prompting technique referred to as "Give Claude Time to Think." In this method, the prompt instructs the model to create an intermediary response that is not shown to the user and draw upon it to provide a final answer. 

Prompt example:

Here is the FAQ document. Read the document carefully because you will need to answer a question about it.


Find the exact parts in the FAQ that are relevant to the user's question and write them inside<thinking> </thinking> XML tags. This is a space for you to write down relevant content that will not be shown to the user. 

Once you are done thinking, answer the question. Put your answer inside <answer><./answer> XML tags.

Learn More with VectorShift

The above prompting techniques can help elicit human-like reasoning abilities when working with Anthropic's Claude LLM and achieve accurate responses while asking the model to process long documentation. Meanwhile, building AI applications based on Claude can be greatly facilitated when working with no-code platforms like Vectorshift. Please don't hesitate to contact our team or request a free demo to learn more about best practices of implementing AI into your processes.

© 2023 VectorShift, Inc. All Rights Reserved.

© 2023 VectorShift, Inc. All Rights Reserved.

© 2023 VectorShift, Inc. All Rights Reserved.