Alex de Pablos
Software engineering

Exploring ChatGPT Prompt Engineering for Developers

Alex de Pablos Lopez21 min

Welcome to my exploration of the course “ChatGPT Prompt Engineering for Developers“. This course, presented by Andrew Ng and Isa Fulford, offers a deep dive into the world of Large Language Models (LLMs) and their applications.

In this article, we’ll delve into key concepts such as the difference between base LLMs and instruction-tuned LLMs, guidelines for effective prompt engineering, and the iterative process of prompt development. We’ll also explore exciting applications of LLMs, including summarizing text, inferring topics and sentiments, transforming text, and even building your own custom chatbot. Let’s embark on this journey to discover the transformative potential of LLMs in the realm of software development.

As a software developer, this course piqued my interest by unveiling a new frontier of possibilities in software engineering using LLMs.

Understanding Base LLM and Instruction Tuned LLM

A key concept introduced early in the course is the distinction between base Large Language Models (LLMs) and instruction-tuned LLMs. A base LLM, trained on a vast corpus of text data, is skilled at predicting the next word in a sentence. For instance, if you prompt a base LLM with “Once upon a time there was a unicorn”, it might complete the sentence with something like “that lived in a magical forest with all unicorn friends.”

However, if you ask it a direct question like “What is the capital of France?”, it might not provide the straightforward answer you’re expecting. This is because base LLMs are not explicitly trained to answer questions or follow instructions. They are trained to predict the next word in a sentence based on patterns they’ve learned from the training data. As a result, they might provide a creative or unexpected continuation of the sentence, rather than the factual answer “Paris”.

Base LLM vs Instruction Tuned LLM

This is where instruction-tuned LLMs come into play. These models are trained to follow instructions, making them more likely to provide direct and accurate answers to queries. So, if you ask an instruction-tuned LLM “What is the capital of France?”, it’s much more likely to give you the correct answer: “The capital of France is Paris.” These models are further refined using a technique called RLHF (Reinforcement Learning from Human Feedback), enhancing their helpfulness, honesty, and reducing the likelihood of outputting problematic text.

Whether you’re building a chatbot, a text summarizer, or a language translator, knowing when to use a base LLM or an instruction-tuned LLM can significantly impact the success of your project.

Guidelines for Prompt Engineering

The second module of the course dives into the guidelines for effective prompt engineering. Isa Fulford presents two key principles for writing prompts: writing clear and specific instructions, and giving the model time to think. Let’s explore these principles in more detail.

Prompt engineering guide

Writing Clear and Specific Instructions

The first principle is to write clear and specific instructions. This is crucial for guiding the model towards the desired output and reducing the chance of irrelevant or incorrect responses. Here are some tactics to achieve this:

  1. Use Delimiters: Delimiters are punctuation marks that separate specific pieces of text from the rest of the prompt. They can be triple backticks, quotes, XML tags, or section titles. Delimiters make it clear to the model what text it should focus on and can help avoid prompt injections, where a user might give conflicting instructions.
  2. Ask for a Structured Output: If you want to make parsing the model outputs easier, ask for a structured output like HTML or JSON. This can lead to more detailed and relevant outputs.
  3. Check Whether Conditions are Satisfied: If the task makes assumptions that aren’t necessarily satisfied, tell the model to check these assumptions first. If they’re not satisfied, the model should indicate this and stop short of a full task completion attempt.
  4. Few-Shot Prompting: This involves providing examples of successful executions of the task you want performed before asking the model to do the actual task. This can help the model understand the context and the desired output better.

Giving the Model Time to Think

The second principle is to give the model time to think. If a model is making reasoning errors by rushing to an incorrect conclusion, you should try reframing the query to request a chain or series of relevant reasoning before the model provides its final answer.

Specify the Steps Required to Complete a Task

Breaking down the task into specific steps and instructing the model to follow these steps can help the model understand the task better and produce more accurate results. For instance, if you want the model to summarize a text, translate the summary into French, list each name in the French summary, and output a JSON object, you can specify these steps in the prompt. This way, the model knows exactly what it needs to do and in what order.

Let’s look at an example. In the course, Isa provides a paragraph describing the story of Jack and Jill. She then asks the model to perform the following actions:

  1. Summarize the text.
  2. Translate the summary into French.
  3. List each name in the French summary.
  4. Output a JSON object that contains the French summary and the number of names.

By specifying these steps, the model successfully completes the task, providing a summary, a translation, a list of names, and a JSON object.

Instruct the Model to Work Out Its Own Solution

Sometimes, we get better results when we explicitly instruct the models to reason out its own solution before coming to a conclusion. This is similar to giving a person time to work out a complex math question before asking for the answer.

For example, in the course, Isa presents a scenario where a student provides a solution to a math problem. The model is asked to determine if the student’s solution is correct. However, without working out the problem itself, the model incorrectly agrees with the student’s solution.

To rectify this, Isa instructs the model to work out its own solution to the problem first, and then compare its solution to the student’s solution. With this approach, the model correctly identifies that the student’s solution is incorrect.


These examples underscore the importance of providing clear and specific instructions to the model and allowing it ample time to ‘think’. By following these principles, you can guide the model towards the desired output and reduce the chance of irrelevant or incorrect responses.

Model Limitations

It’s important to be aware of the limitations of the LLMs. Even though the language model has been exposed to a vast amount of knowledge during its training process, it has not perfectly memorized the information it’s seen. This means that it might try to answer questions about obscure topics and can make things up that sound plausible but are not actually true. These fabricated ideas are known as hallucinations.

One tactic to reduce hallucinations is to ask the model to first find any relevant quotes from the text and then ask it to use those quotes to answer questions. Having a way to trace the answer back to the source document can be helpful in reducing hallucinations.

In addition to the limitations already mentioned, it’s important to know that large language models like ChatGPT do not have access to real-time or proprietary information. They can’t provide the latest news, stock market updates, or confidential data from a specific organization. They only know what they were trained on, and they can’t access or retrieve personal data unless it has been shared with them in the course of the conversation. Now, the plugins are valuable tools that provide this kind of access to the LLM itself so that when chatGPT integrates them, they can manage real-time information which is actually provided by the plugins.

Furthermore, these models don’t understand their own outputs in the way humans do. They generate responses based on patterns they’ve learned, but they don’t comprehend the meaning of those responses. Lastly, while they can generate text that might seem like personal advice or opinions, it’s crucial to remember that these are not truly their own beliefs or advice. They don’t have personal experiences or emotions, and any advice given should be considered with this in mind.

Iterative Prompt Development: A Key to Effective Applications

In the world of Large Language Models (LLMs), there’s a crucial concept that stands out: iterative prompt development. As Andrew Ng explains in the course, the perfect prompt for an application is rarely achieved on the first attempt. Instead, it’s a process of continuous refinement and improvement, much like the process of training a machine learning model.

The process starts with an idea for a task you want the LLM to complete. You then write a prompt that is clear, specific, and, if necessary, gives the model time to think. After running the prompt, you evaluate the result. If it doesn’t meet your expectations, you refine the prompt based on the shortcomings of the previous result. This cycle repeats until you arrive at a prompt that works well for your application.

This iterative process is essential because there’s no one-size-fits-all prompt. The effectiveness of a prompt depends on the specific task and application. Therefore, the key to successful prompt engineering is not about knowing the perfect prompt, but about having a good process for developing prompts that are effective for your specific application.

As a software developer, this concept resonates with me. It’s similar to how we iteratively develop and refine code until it meets our requirements. This approach to LLMs opens up a new realm of possibilities for building software applications. For instance, we can use LLMs to summarize technical fact sheets, generate product descriptions, or even output structured data like HTML or JSON. The potential applications are vast and exciting.

Reflecting on this, I realize that the principles of iterative prompt development can be applied to our daily work. Whether we’re writing code, designing systems, or even communicating with our team, the idea of starting with a first attempt, evaluating the result, and then refining based on feedback is a powerful approach to problem-solving.

Summarizing Text: A Powerful Application of LLMs

One of the most exciting applications of Large Language Models (LLMs) is their ability to summarize text. In our fast-paced world, where information overload is a common challenge, the ability to quickly summarize and understand the essence of a piece of text is invaluable.

Andrew Ng demonstrates this capability in the course using the example of summarizing product reviews. If you’re building an e-commerce website with a large volume of reviews, having a tool to summarize lengthy reviews can give you a way to quickly glance over more reviews and get a better sense of what your customers are thinking.

The process starts with writing a prompt that instructs the model to generate a short summary of a product review. You can also specify the maximum word count for the summary. The result? A concise summary that captures the key points of the review.

But what if you want the summary to focus on a specific aspect of the review? For instance, if you want to give feedback to the shipping department, you can modify the prompt to focus on any aspects that mention shipping and delivery of the product. Similarly, if you want to give feedback to the pricing department, you can instruct the model to focus on any aspects relevant to the price and perceived value.

Sometimes, instead of summarizing, you might want to extract specific information from the text. For instance, if you want to extract relevant information for the shipping department, you can instruct the model to do so, and it will provide a summary that focuses solely on the shipping details.

This capability of LLMs can be incredibly useful in a workflow where you need to summarize multiple pieces of text. For instance, if you have hundreds of reviews on your website, you can use LLMs to generate short summaries of these reviews, allowing you or someone else to browse the reviews much more quickly. If a particular summary catches your interest, you can then delve into the original, longer review.

As a software developer, I find this application of LLMs particularly exciting. It’s not hard to imagine how this could be integrated into our daily work, whether it’s summarizing meeting notes, customer feedback, or even code reviews. There are countless potential applications, and I’m excited to explore them further.

Inferring Topics and Sentiments: A New Approach to Content Analysis

One of the most fascinating applications of Large Language Models (LLMs) is their ability to infer topics and sentiments from a piece of text. This capability opens up a new approach to content analysis, making it possible to quickly understand the main themes or sentiments in a document without having to read it in its entirety.

Andrew Ng showcases this feature in his course using several examples. One of the most compelling is the analysis of product reviews. If you’re building an e-commerce website with a large volume of reviews, having a tool to infer the sentiment of lengthy reviews can give you a way to quickly understand what your customers are thinking. By asking the model to classify the sentiment of a review, you can get a concise output, such as “positive” or “negative”, that captures the overall tone of the review.

But the power of LLMs goes beyond simple sentiment analysis. You can also use them to infer specific emotions expressed in the text. For instance, if you want to understand whether a customer is expressing anger or delight, you can modify the prompt to focus on these specific emotions. This can be incredibly useful for customer support organizations, as understanding the emotional state of a customer can guide the approach to customer service.

Another fascinating application is the ability to infer topics from a piece of text. Given a long piece of text, such as a news article or a blog post, you can ask the model to determine the topics being discussed. This can be incredibly useful for understanding the main themes in a document. For example, Andrew Ng presents this capacity using a fictitious newspaper article. By asking the model to determine five topics that are being discussed in the text, the model successfully extracts a list of topics that the article is about.

Furthermore, you can also use this capability to determine whether a specific topic is covered in a text. For instance, if you’re interested in NASA and you want to know whether a news article covers this topic, you can ask the model to determine this. If the topic includes NASA, you can then delve into the article for more details.

As a software developer, these applications of LLMs are particularly relevant. They can be used to infer the main topics in a piece of code, a technical document, or even a meeting transcript. They can also be used to understand the sentiment or specific emotions expressed in user feedback or team communications. This can help us quickly understand the main themes, focus our attention on the most relevant parts, and respond more effectively to our users’ needs.

Transforming Text with Large Language Models

Large language models can be used to transform text, a capability that opens up a wide array of applications. From translating text between languages to correcting grammar and spelling, transforming text is a powerful tool in the world of natural language processing.

LLMs can also be used for tasks like paraphrasing text, converting text to speech, or generating creative writing. For instance, you could use an LLM to paraphrase a complex technical document into simpler language, making it more accessible to a broader audience. Similarly, you could use an LLM to convert written text into a format suitable for speech synthesis, enabling the creation of audiobooks or voice assistants. In the realm of creative writing, LLMs can be used to generate story ideas, write poetry, or even draft scripts for plays or movies. These examples highlight the versatility of LLMs in transforming text, opening up a wide array of possibilities for their application.

Translation Tasks

Other exciting applications of large language models is their ability to translate text between languages. These models have been trained on a vast amount of text from the internet, which includes content in many different languages. This training imbues the models with the ability to translate between hundreds of languages to varying degrees of proficiency.

For example, if you want to translate the English phrase “Hi, I would like to order a blender” into Spanish, you can simply prompt the model with “Translate the following English text to Spanish: ‘Hi, I would like to order a blender'”. The model will then output the translated text: “Hola, me gustaría pedir una licuadora”.

Tone Transformation

The tone of a piece of writing can vary greatly depending on the intended audience. For instance, the way you would write an email to a colleague or a professor would be quite different from how you would text a friend. LLMs like ChatGPT can help produce text in different tones. For example, you can ask the model to translate a casual message into a more formal business letter format.

Format Transformation

Large language models are also adept at translating between different formats, such as JSON to HTML, XML, and Markdown. This can be particularly useful when you need to convert data between different formats for various applications.

Spell Check and Grammar Checking

Another popular use for large language models is spell check and grammar checking. This can be especially useful when working in a non-native language. The model can proofread and correct a piece of text, making it easier to ensure that your writing is clear and error-free.

Wrapping Up

In the realm of software development, the transformative capabilities of large language models hold immense potential. Envision a scenario where we can seamlessly translate technical documentation into multiple languages, making it accessible to a global team. Or consider the possibility of instantly converting data formats to suit our specific needs in a project, saving us hours of manual work.

Moreover, the ability to proofread and correct text can be a game-changer in our communication. Whether it’s refining the language in our emails, improving the clarity of our code comments, or ensuring our project documentation is error-free, this feature can significantly enhance the quality of our written communication.

The power of models like ChatGPT lies in their versatility and adaptability. As we continue to explore and understand their capabilities, we are opening up new avenues for efficiency and innovation in our work. The future of software development with AI looks promising, and I’m thrilled to be part of this journey.

Expanding: Generating Longer Texts with Large Language Models

The concept of ‘Expanding’ involves using a large language model (LLM) to generate a longer piece of text from a shorter input. This could be an email, an essay, or any other form of extended text based on a given topic or set of instructions.

However, it’s crucial to remember that while LLMs can generate longer pieces of text, they don’t have the ability to create new, factual information that wasn’t in their training data. They can’t conduct research or access real-time data, so any information they generate is based on patterns they’ve learned during training. This is why it’s important to always verify the information generated by LLMs, especially when using them for tasks that require up-to-date or factual information.

It’s important to note that while there are many positive uses, there can also be problematic ones, such as generating spam. Therefore, it’s important to use these capabilities responsibly and in ways that genuinely help people.

Personalized Email Responses

One of the examples Isa Fulford shows in this module of the course was generating a personalized email response to a customer review. Given the sentiment of the review, the LLM can craft a custom response. For instance, if the sentiment is positive or neutral, the model can thank the customer for their review. If the sentiment is negative, the model can apologize and suggest that they reach out to customer service. The model can also incorporate specific details from the review to make the response more personalized.

Playing with Temperature

Another concept we explored in this module is the ‘temperature’ parameter of the LLM. This parameter allows us to control the degree of randomness in the model’s responses. A lower temperature (e.g., 0) makes the model more deterministic and likely to choose the most probable next word, while a higher temperature (e.g., 0.7) makes the model’s output more diverse and creative.


Wrapping up, expanding with LLMs can be a powerful tool for generating longer pieces of text based on shorter inputs. However, it’s crucial to use this capability responsibly. When generating text that will be shown to users, transparency is key. Users should be aware that the text they’re seeing was generated by AI.

Applying LLMs to Software Development

As a developer, the power of LLMs as a tool for quickly building software applications is exciting. The scope for applications is extensive, from creating chatbots to summarizing text, inferring information, transforming data, and more.

Building Your Own Custom Chatbot with Large Language Models

In the world of AI, one of the most exciting applications is the ability to create a custom chatbot using a large language model (LLM). This chatbot can be tailored to perform a variety of tasks, from taking orders at a restaurant to providing customer service. The possibilities are endless, and the best part is that it requires only a modest amount of effort to set up.

The key to creating a custom chatbot is understanding how to use the OpenAI chat completions format effectively. This format allows the model to take a series of messages as input and return a model-generated message as output. This makes it easy to create multi-turn conversations, but it can also be used for single-turn tasks without any conversation.

One of the most important components of the chat completions format is the system message. This message sets the behavior and persona of the assistant, acting as a high-level instruction for the conversation. It’s like whispering in the assistant’s ear, guiding its responses without the user being aware of the system message.

Let’s illustrate this with an example where we construct an automated chatbot, “OrderBot”, designed to streamline the collection of user prompts and assistant responses for a pizza restaurant. The system message in this case might be something like, “You are OrderBot, an automated service to collect orders for a pizza restaurant. You first greet the customer, then collect the order, and then ask if it’s a pick-up or delivery. Make sure to clarify all options, extras, and sizes to uniquely identify the item from the menu. You respond in a short, very conversational, friendly style.”

As the conversation progresses, the model has the information it needs to determine what to do next. For example, if a customer asks, “How much is a large pepperoni pizza?”, the model can respond accurately because it has the context it needs from the system message and previous user messages.

A significant advantage of this approach is its allowance for a high degree of customization. By tweaking the system message, you can change the behavior of the chatbot and get it to act as different personas with different knowledge. You could create a chatbot that speaks like Shakespeare, a chatbot that talks like a pirate, or anything else you can imagine.

The potential applications of this technology are vast. I can see countless ways this could be integrated into our daily work. Whether it’s automating customer service interactions, taking orders for a restaurant, or even providing personalized recommendations, the possibilities are endless. It’s an exciting time to be in the field of AI, and I can’t wait to see what we’ll be able to accomplish with these tools in the future.

If you’re curious and want to learn how to create a chatbot using GPT-3, I recommend this insightful article by Cobus Greyling.


Beyond order-taking bots for restaurants, there are numerous other potential applications for custom chatbots. For instance, you could create a virtual assistant bot that helps users manage their schedules, set reminders, or find information online. Tutoring bots could provide personalized learning experiences, offering explanations and practice problems in various subjects. Mental health bots could provide supportive conversations, mindfulness exercises, or resources for further help. These examples illustrate the wide range of possibilities for custom chatbots, demonstrating the potential of LLMs to revolutionize various industries and fields.

Try it yourself!

To help you get a hands-on understanding of the concepts discussed in this course, I’ve created a public GitLab repository that contains code examples from the course.

In this repository, you’ll find code snippets that demonstrate key concepts such as prompt engineering, iterative prompt development, and various applications of Large Language Models. Feel free to clone the repository, run the code, and experiment with it to deepen your understanding of these concepts.

The best way to learn is by doing. So, don’t hesitate to get your hands dirty with the code and try out these fascinating AI capabilities for yourself!”

Remember, learning is a journey, not a destination. So keep exploring, keep questioning, keep learning. And while you’re at it, don’t forget to enjoy the ride! See you in the next post, where we’ll continue to unravel the mysteries of software engineering together. Until next time!