Prompt Examples
In the previous section, you learned a basic example of how to use prompts for large language models (LLMs).
In this section you will find more practical prompt examples covering different tasks. Important key concepts are introduced to help you design prompts in a targeted and effective way. You will learn how to formulate prompts for different application areas and get inspiration for your own experiments.
Text Summarization
This example shows how you can use a prompt - a targeted input instruction to a language model - to automatically summarize a text. Text summarization is a classic task in natural language processing and shows how powerful LLMs are at compressing information.
Imagine you want a brief, easy-to-understand overview of antibiotics. You could instruct the model with the following prompt:
Explain antibiotics.
A:Antibiotics are medicines used to treat bacterial infections. They work by killing bacteria or preventing them from multiplying, allowing the immune system to fight the infection. Antibiotics are usually administered as tablets, capsules, liquids, or sometimes intravenously. They do not help against viruses, and improper use can lead to resistance.The “A:” in the prompt indicates that an answer is expected at that point. With such formatting, you can steer the model and influence the structure of the output. In some cases this is particularly helpful, for example when you need consistent answers.
Suppose you want to condense the information even further. You can ask the model to summarize the explanation in a single sentence:
Antibiotics are medicines used to treat bacterial infections. They work by killing bacteria or preventing them from multiplying, allowing the immune system to fight the infection. Antibiotics are usually administered as tablets, capsules, liquids, or sometimes intravenously. They do not help against viruses, and improper use can lead to resistance.
Summarize the above in one sentence:Antibiotics are medicines used to treat bacterial infections, do not work against viruses, and can cause resistance if used incorrectly.Regardless of factual accuracy - which we will address in a later guide - this example shows how to give targeted instructions to obtain concise summaries. Feel free to experiment with your own prompts and observe how the results change.
Information Extraction
In this section you will learn how to use prompts to extract information from a text. Information extraction is a core task in natural language processing and is often used to filter facts or specific details from longer texts.
The following example shows how you can get the model to name a specific product from a paragraph:
Author contribution statements and acknowledgements in research papers should clearly and specifically state whether and to what extent authors used AI technologies such as ChatGPT in preparing their manuscript and in analysis. They should also state which LLMs were used. This will alert editors and reviewers to examine manuscripts more carefully for possible biases, inaccuracies, and improper source citations. Scientific journals should likewise be transparent about their use of LLMs, for example when selecting submitted manuscripts.
Name the product mentioned in the paragraph above that is based on large language models:The product based on large language models mentioned in the paragraph above is ChatGPT.This example shows how to ask targeted questions to filter relevant information from longer sections. You can further improve the results by phrasing the prompts even more precisely.
Source of the paragraph: van Dis et al. (2023)1
Question Answering
Here you will learn how to get precise answers to specific questions using targeted prompts. Structured question answering is one of the most important applications of LLMs - for research, support, or knowledge management.
A proven method is to clearly structure the prompt format: provide an instruction, supply context, and clearly mark the expected answer. The more specifically you describe the desired behavior, the more reliable the results.
Answer the following question based on the context below. Keep the answer short and precise. If you are unsure, respond with "Unsure about the answer."
Context: Teplizumab has its roots in a New Jersey pharmaceutical company called Ortho Pharmaceutical. There, scientists created an early version of the antibody called OKT3. Originally derived from mice, the molecule could bind to the surface of T cells and limit their cell-killing potential. In 1986, it was approved to prevent organ rejection after kidney transplants, making it the first therapeutic antibody approved for human use.
Question: What was OKT3 originally derived from?
Answer:Mice.Context from: Dolgin (2023)2
Text Classification
In this section you will learn how to use prompts to automatically classify texts - for example by sentiment or category. Text classification is a common task in practice, for example when analyzing customer feedback.
You can first instruct the model with a simple instruction:
Classify the text as neutral, negative, or positive.
Text: I think the food was okay.
Sentiment:NeutralThe model correctly classified the text as “Neutral.” If you expect a specific output format - for example the label in lowercase (“neutral”) - you can guide the model more precisely. Providing an example in the prompt helps here:
Classify the text as neutral, negative, or positive.
Text: I think the vacation is okay.
Sentiment: neutral
Text: I think the food was okay.
Sentiment:neutralThe example provided in the prompt helped the model recognize and produce the desired output format.
More specific prompts help avoid misunderstandings. Look at the following example, where a typo in the label was intentionally included:
Classify the text as nutral, negative, or positive.
Text: I think the vacation is okay.
Sentiment:NeutralThe model ignores the invented label “nutral” and uses the familiar label “Neutral” instead. If you want the model to actually use “nutral,” you should describe the labels or add more examples. Later on you will learn methods to address such challenges.
Conversation
In this section you will learn how to deliberately control the behavior and role of a language model. Especially for chatbots or conversational systems, it is important to give the model clear instructions on how to behave and communicate. This technique is known as role prompting.
Suppose you want to simulate an AI research assistant who responds in a technical and scientific manner:
The following is a conversation with an AI research assistant. The assistant's tone is technical and scientific.
Human: Hello, who are you?
AI: Good day. I am an AI research assistant. How can I help you today?
Human: Can you explain how black holes form?
AI:Certainly. Black holes are regions of spacetime with gravity so strong that nothing, not even light, can escape. They form when a very massive star collapses at the end of its life cycle and creates a singularity. The extreme gravity pulls in matter and radiation, forming the black hole.If you want the assistant to respond more simply and in a way that children can understand, you can adjust the behavior accordingly:
The following is a conversation with an AI research assistant. The assistant's answers should be easy for primary school children to understand.
Human: Hello, who are you?
AI: Hello. I am an AI research assistant. How can I help you?
Human: Can you explain how black holes form?
AI:Of course. A black hole forms when a large star runs out of fuel and collapses in on itself. The pull of gravity then becomes so strong that nothing can escape, not even light. That is why we call it a black hole.With additional examples and targeted instructions, you can make the conversation even more natural and application-oriented.
Code Generation
In this section you will see how prompts can be used to generate code automatically. Code generation is one of the most impressive capabilities of modern LLMs and is used, for example, in tools like Copilot.
First, try a simple prompt for a greeting program:
/*
Ask the user for their name and print "Hello".
*/let name = prompt("What is your name?");
console.log(`Hello, ${name}!`);You did not even have to specify the programming language - the model understood and completed the task.
With a bit more context, you can solve even more complex tasks. In the next example, you provide information about the database schema and generate a SQL query:
Table departments, columns = [DepartmentId, DepartmentName]
Table students, columns = [DepartmentId, StudentId, StudentName]
Create a MySQL query for all students in the Computer Science department.SELECT StudentId, StudentName
FROM students
WHERE DepartmentId IN (SELECT DepartmentId FROM departments WHERE DepartmentName = 'Computer Science');The model uses the provided database schema information and creates an appropriate query. With targeted prompts, you can tackle more complex programming tasks as well.
Reasoning
This section covers tasks that require logical reasoning or mathematical abilities. Such tasks are among the most challenging for large language models and show how far you can go with targeted prompt design.
LLMs can solve simple arithmetic problems but often reach their limits with more complex reasoning. Here is an example of a simple multiplication:
What is 9,000 \* 9,000?81,000,000Now a slightly more complex task:
The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82, 7, 1.
A:No, the odd numbers in this group add up to an odd number: 119.The result is not correct. With an improved prompt, you can guide the model toward a better approach:
The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82, 7, 1.
Solve the problem step by step: first identify the odd numbers, add them, and state whether the result is odd or even.Odd numbers: 15, 5, 13, 7, 1
Sum: 41
41 is an odd number.As you can see, a clearer instruction leads to a better result. Nevertheless, LLMs are not always error-free on such tasks. With additional examples and even more precise instructions, you can further improve accuracy. We will continue to expand this section with more examples for typical use cases.
van Dis, E. A. M., Bollen, J., Zuidema, W., van Rooij, R., & Bockting, C. L. (2023). ChatGPT: Five priorities for research. Nature, 614(7947), 224–226. https://doi.org/10.1038/d41586-023-00288-7 ↩︎
Dolgin, E. (2023). How a pioneering diabetes drug offers hope for preventing autoimmune disorders. Nature, 614(7948), 404–406. https://doi.org/10.1038/d41586-023-00400-x ↩︎