Lesson 3: Prompts or How to Communicate with ChatGPT More Effectively

Today we will dive into an interesting and important process called "creating prompts." What exactly is a prompt? How do you properly compose a prompt? And what is prompt-engineering? Let's figure it out together.

What is a prompt?

A prompt, in the context of working with ChatGPT, is an introductory phrase or instruction that you provide to the model to start a conversation or perform a task. The prompt plays a crucial role as it sets the context and determines the direction of the interaction.

One could imagine that ChatGPT is like a train conductor, and the prompt is the station from which the journey begins. You set the starting point (prompt), and your subsequent requests are like waypoints that the conductor must follow.

Prompts can be very diverse. It could be a simple question, such as: "What is quantum physics?". Or it could be a more complex construction that sets a specific style of response, for example: "Describe quantum physics as if you were the author of a children's book". In the latter case, the model will try to simplify concepts and use a more playful and relaxed language in its responses.

However, it's important to remember that, although the prompt serves as a starting point for the model, ChatGPT assesses the entire previous context of the dialogue when generating responses. This means that the model takes into account not just the prompt, but also all subsequent questions and answers when formulating its response. It's important to consider this when crafting a dialogue.

For example:

"Write a story about a knight who travels the world in search of treasures from forgotten civilizations." — here we provide the model with the initial context and directions about the kind of story we want to see:

How to use them?

The use of prompts is both an art and a science, requiring some practice. Understanding the structure of a prompt and its key elements plays a crucial role in this process:

  • Topic: Determine what your prompt should be about. This will help narrow the focus and make your task more understandable for the AI.

  • Role: Define the role the AI should play. For example, it could "pretend" to be a lawyer, an analyst, a copywriter, etc.

  • Format: Decide on the format in which you want to receive the response. It could be a dialogue, a story, a review, a list, and so on.

  • Audience: Consider the interests and preferences of your audience to make the prompt as appealing as possible for them.

  • Constraints: Determine if there are any constraints that need to be considered when creating the prompt (for example, text length, complexity level, etc.).

Besides these elements, the following recommendations will help you make your prompts more effective:

  • Be specific: The more precise and detailed your instruction is, the more accurate and detailed the model's response will be. If you ask the model to "tell a story," it can go in any direction. But if you ask to "tell a story about a young pirate searching for lost treasure in the Southern Seas," you are more likely to get a more interesting and engaging tale.

  • Use information-rich prompts: This is particularly helpful when you want to elicit a more in-depth and detailed response. For example, instead of asking "What is quantum physics?", you might ask, "What are the fundamental principles of quantum mechanics, and how do they differ from classical physics?"

  • Specify desired style or format: If you want the response to be in a certain style or format, state this in your prompt. For instance, you may request the model to "Write a poem about a sunrise" or "Tell a brief story about love in the style of a drama."

  • Experiment: Don't be afraid to try different phrasings or approaches in your prompts. This will help you better understand how the model responds to various instructions and allow you to refine your skills in crafting effective prompts.

For example, let's ask, "Imagine you're a scientist, answer the question 'How big is the universe?'". Response:

Remember that it's important to be patient and ready for the fact that not every prompt will work perfectly on the first try. It's a process of exploration and learning, and the more you practice, the better you become.

Prompt engineering

Prompt engineering is the process of optimizing prompts to maximize the quality and accuracy of the responses you receive from AI. Instead of simply tossing questions and hoping for the best, prompt engineering requires careful reflection and a creative approach to formulating questions and tasks.

When we talk about prompt-engineering, we refer to the creation of prompts that provide clear guidance for ChatGPT. This can mean defining a specific context, indicating the expected format of the response, or providing more detailed instructions that AI can use to generate more accurate answers.

For instance, if you simply asked ChatGPT to "write a story," the results could be entirely random and unpredictable because the AI may not understand the context or expected parameters of your request. However, if you used prompt-engineering to frame your request, for example, "Write a short story about a sea captain who encounters the curse of the ancient seas," then the result would be more specific and in line with your expectations.

Prompt engineering involves not just the formulation of prompts, but also the application of various techniques such as personalization and managing the level of detail. This allows for defining the role ChatGPT should play, the level of detail of the response, and the form in which it should be presented:

  • Personalization: Define the role ChatGPT should play. For example, if you want AI to act as a writer and compose a chapter of a detective novel in the style of Agatha Christie, specify this in the prompt. Defining the AI's role will help you obtain a result that best meets your expectations.

  • Level of Detail: Choose the level of detail for the response. If you need an overview, indicate this in the prompt. If you need details, also specify this.

  • Creative Approach: If you need to create something creative or unusual, indicate this in the prompt. ChatGPT is capable of creating stories, jokes, puzzles, poems, and more.

  • Experimenting with Prompts: With more advanced versions of AI, such as GPT-4, you can experiment with more complex and dynamic prompts, including long prompts, prompts with multiple questions, or conditional constructions.

Prompt engineering is both an art and a science. It requires practice and creativity, but once you master it, you can fully utilize the capabilities of AI to solve your tasks.

Example of Prompt Creation

  1. Analysis: Your audience is readers of a popular science magazine who are interested in cosmology.

  2. Idea: You want to generate an article about black holes.

  3. Main Idea: "Explain the concept of black holes in an accessible manner, assuming that the audience has basic knowledge of physics."

Response:

  1. Development: The prompt might look like this: "Write an article about black holes that is accessible to readers of a popular science magazine, assuming they have a basic understanding of physics."

Answer:

  1. Testing: Next, we will test the prompt on ChatGPT, evaluate the results obtained, and, if necessary, make adjustments.

In this lesson, we have learned what prompts are and how to use them, as well as being introduced to the basics of prompt-engineering. These are key components for effective communication with ChatGPT. Now, try it yourself!

Practical Assignment

Task:

Come up with and write your own prompt for ChatGPT using the principles of prompt-engineering.

Instruction:

1. Choose a topic on which you would like to get a response from ChatGPT. It can be any question or task that you would like to solve with the help of AI.

  1. Use the principles of prompt-engineering that we discussed in this lesson to formulate your prompt. Specify the theme, role, format, audience, and any potential constraints.

  2. Write your prompt and see how ChatGPT reacts to it.

Example:

Task: I want ChatGPT to write an article about the latest trends in artificial intelligence for my technology blog.

Prompt: "You are an experienced technology journalist specializing in the field of artificial intelligence. Write an informative and engaging article for my technology blog that discusses the latest trends in this field. The article should be accessible to a broad audience not specialized in this area and consist of approximately 500 words."

Response:

Thus, you have defined the topic (latest trends in AI), the role (technology journalist), the format (informative article), the audience (readers of a technology blog who are not experts in the field of AI), and the constraints (article length – about 500 words). This prompt provides ChatGPT with clear direction and helps it generate useful and engaging content.

Last updated