Prompt Engineering — Better Prompts for ChatGPT

Venus
12 min readApr 12, 2023

--

A. Academic Writing Example

Prompt engineering is a crucial skill when working with ChatGPT. Crafting a prompt that provides enough information for the model to generate a meaningful response, while also avoiding common pitfalls like ambiguity, bias, or lack of context, is essential to achieve the best results. In this article, we will use academic writing as an example because it is a complex and structured form of writing that requires careful attention to detail and clear communication.

For the past few years, natural language processing (NLP) has been advancing rapidly, and one of the most exciting developments in this field has been the creation of large language models like ChatGPT. These models use machine learning algorithms to analyze large amounts of data and generate human-like responses to text-based prompts.

ChatGPT is a particularly impressive example of this technology, with over 175 billion parameters for GPT-3 and 100 trillion for GPT-4 that allow it to understand and respond to a wide variety of topics and styles of writing. In fact, the model has been used to generate everything from poetry to software code, and its capabilities are only improving as it continues to learn from new inputs.

But while ChatGPT is an incredibly powerful tool, getting the best results from it requires a bit of skill and expertise in prompt engineering. This involves crafting prompts that provide enough information for the model to generate a meaningful response, while also avoiding common pitfalls like ambiguity, bias, or lack of context.

To help you improve your own prompt engineering skills, I want to share some insights and techniques that I’ve been using to get good results from ChatGPT. In this example, I’ll focus on academic writing, as it’s a more complex and structured form of writing that requires careful attention to detail and clear communication.

Academic writing is a highly structured and precise form of writing that is characterized by its strict adherence to certain conventions and guidelines. These conventions include things like proper citation formats, logical organization, and precise language, which are essential to ensuring that the writing is clear, coherent, and well-supported.

In academic writing, it’s important to provide clear and well-organized arguments that are supported by evidence from credible sources. This requires a deep understanding of the subject matter, as well as the ability to communicate complex ideas in a clear and concise manner.

When working with ChatGPT to generate academic writing, it’s important to keep these conventions in mind and provide prompts that reflect them. For example, you might prompt ChatGPT with a question that asks for an explanation of a particular concept, such as “Can you explain the concept of cognitive dissonance and how it relates to social psychology?”

In this prompt, you’re not only providing ChatGPT with a clear topic to focus on, but also framing the question in a way that reflects the conventions of academic writing. By using precise and specific language, you’re signaling to ChatGPT that you’re looking for a detailed and well-supported explanation, rather than a general overview.

Another important aspect of academic writing is proper citation and referencing of sources. When using ChatGPT to generate academic writing, it’s essential to provide it with accurate and relevant sources of information to support its responses. This might include references to scholarly articles, research studies, or other credible sources that are relevant to the topic at hand.

When it comes to generating high-quality prompts for ChatGPT, it’s important to strike a balance between technical accuracy and readability. While technical language and jargon can be useful for communicating precise information, they can also be confusing or intimidating for readers who are less familiar with the subject matter.

To avoid these issues, it’s best to use clear and concise language that is accessible to a wide range of readers. This means avoiding overly complex or technical terminology, and instead focusing on simple, straightforward language that is easy to understand.

Similarly, it’s important to provide ChatGPT with enough context and background information to ensure that it understands the topic at hand. This might include providing relevant historical, cultural, or social context, as well as any relevant research studies, statistics, or other data that can help support its responses.

By providing this context, you can help ensure that ChatGPT is able to generate accurate and relevant responses that are tailored to the specific needs of your audience. Whether you’re writing for a technical or non-technical audience, providing clear and accessible prompts is essential for achieving the best possible results.

Here is the prompt I used:

Compose an academic essay of 1000 words exploring the chemical components and mechanisms of action of St. John’s Wort (Hypericum perforatum) and their potential implications for the treatment of mild depression or low mood. In your essay, draw from the following research papers: ‘Medical Attributes of St. John’s Wort (Hypericum perforatum)’, ‘Herb-Drug Interactions with St. John’s Wort (Hypericum perforatum): an Update on Clinical Observations’, ‘Hypericum perforatum: Pharmacokinetic, Mechanism of Action, Tolerability, and Clinical Drug-Drug Interactions’, ‘Hypericum Perforatum: A ‘Modern’ Herbal Antidepressant’, and ‘St. John’s wort (Hypericum perforatum L.): a review of its chemistry, pharmacology and clinical properties’. In particular, analyze the specific chemical compounds found in St. John’s Wort and their potential biological activities, as well as their mechanisms of action and how they may influence neurotransmitter systems implicated in depression. Additionally, evaluate the safety and potential side effects associated with St. John’s Wort use, as well as its effectiveness compared to other treatment options for mild depression or low mood. In writing your essay, please use the APA referencing style and provide a reference list at the end of the essay. Finally, provide recommendations for future research and potential clinical applications of St. John’s Wort in the treatment of depression.

Note how the above explanation was used in generating this example. There is a specific style mentioned as well as focus areas for the scientific essay, research papers, and formatting. I suggest you run this script yourself and notice the difference between a more in-depth prompt engineering versus casual prompt engineering.

When asked ‘why is the following prompt a good ChatGPT prompt’, this is what the bot replied:

This is a good prompt for ChatGPT because it specifies a clear topic and provides a detailed set of instructions and resources for the essay. The prompt is also academically focused, which aligns with ChatGPT’s training as a language model designed to generate text that can address scholarly and technical topics.

Additionally, the prompt is specific enough to guide the response, but also open-ended enough to allow for creativity and exploration in the essay. The inclusion of specific research papers as references provides a foundation for the essay and ensures that the information presented is reliable and up-to-date.

The prompt also requires the essay to address several key aspects of St. John’s Wort, including its chemical components and mechanisms of action, potential implications for the treatment of mild depression or low mood, safety and potential side effects, and effectiveness compared to other treatment options.

Finally, the prompt asks for recommendations for future research and potential clinical applications of St. John’s Wort, which encourages critical thinking and analysis. The requirement to use the APA referencing style and provide a reference list at the end of the essay ensures that the essay is well-organized and follows standard academic writing conventions. Overall, the prompt is an excellent example of a well-crafted and engaging writing prompt that is suited to ChatGPT’s capabilities.

In case you were wondering, this is what GPT-3 gave me as a result of my prompt:

If you want to engineer similar prompts, here is a simple guide:

  • Define the topic of your prompt: Choose a specific topic that you want the AI to generate content on. This could be anything from science and technology to history and literature.
  • Identify the key research papers: Find relevant research papers and articles that you want the AI to reference in the prompt. These could be academic papers, scientific studies, or any other relevant sources.
  • Identify the specific focus areas: Identify the specific focus areas that you want the AI to cover in the prompt. For example, in the St. John’s Wort prompt, the focus areas include the chemical components, mechanisms of action, safety, and potential clinical applications of St. John’s Wort.
  • Specify the required length and referencing style: Indicate the required length of the prompt and the referencing style to be used. For example, the St. John’s Wort prompt requires a 1000-word essay in APA referencing style.
  • Provide clear instructions: Write clear and concise instructions for the AI to follow. Make sure to specify what information you want the AI to cover and how you want it to be presented.
  • Test, edit, and refine the prompt: Review the generated prompt and make any necessary edits and refinements to ensure that it meets your requirements.

Remember to always fact-check your article before publishing if this is for anything else other than testing ChatGPT’s capabilities.

B. Website Example

Continuing on from our discussion about prompt engineering, let’s explore how easy it can be to generate high-quality prompts for more technical subjects. To illustrate this point, we’ll use the example of a simple frontend page for a portfolio website.

When it comes to creating a portfolio website, there are a number of technical considerations to keep in mind. For example, you’ll need to decide on the best framework or platform to use, as well as choosing the right design elements and layout for your site.

To generate high-quality prompts for this type of project, it’s important to break the process down into smaller, more manageable steps. This might involve starting with simple questions like “What is the purpose of my portfolio website?” or “What design elements do I want to include in my site?”

From there, you can gradually build up your prompts to cover more technical considerations like CSS styling, JavaScript functionality, and responsive design. By providing ChatGPT with clear and concise prompts at each stage of the process, you can help ensure that it generates accurate and relevant responses that meet your specific needs.

Throughout the process, it’s important to keep in mind the principles of effective prompt engineering that we discussed earlier. This means using clear and concise language, avoiding overly complex terminology, and providing enough context and background information to ensure that ChatGPT understands the topic at hand.

Here is the prompt I used this time:

Write HTML and CSS code to create a simple portfolio website with the following pages:

  1. Home page: This page should include a brief introduction about you and your work. It should also include links to your social media profiles and any other relevant websites.
  2. Portfolio page: This page should showcase your work. It should include a grid of thumbnail images of your projects that link to individual project pages.
  3. About page: This page should provide more information about you, including your education, skills, and experience.
  4. Contact page: This page should include a simple contact form that visitors can fill out to get in touch with you.

The website should have a navy background and use modern colors that complement it. The design should be clean and minimalist.

Use HTML and CSS to create the layout and styling of each page. Use appropriate tags and classes to structure your code in a semantic way. Ensure that the website is responsive and can be viewed on different devices.

To prove it works, here is what ChatGPT understands about this prompt and why it thinks it’s a good prompt:

This is a good prompt because it provides clear and specific instructions for what the website should include, its color scheme, and design. It also outlines the required pages for the website, which will give the person creating it a clear idea of what content they need to include.

The prompt also specifies that HTML and CSS should be used to create the website, which is a common web development technology. Additionally, the requirement that the code should be structured in a semantic way ensures that the website will be accessible and easily understood by search engines and assistive technologies.

Furthermore, the prompt requires that the website should be responsive and viewable on different devices. This is an essential aspect of modern web design, as more people use mobile devices to access the internet.

And this is the result of the prompt:

if you get cut off by the word limit you can always ask for the bot to continue like I did here:

Notice, it gives extra instructions on how to link the HTML and CSS pages.

If you want to engineer similar prompts here is what you can do:

  • Be specific: Give clear and concise instructions for what the task or prompt requires.
  • Provide details: Include any necessary details, such as the required color scheme, design style, or programming languages to be used. This will help ChatGPT to create a more cohesive and effective end product.
  • Outline requirements: List the required components or pages that should be included in the end product, such as specific website pages or software features.
  • Specify technology: If applicable, specify what programming languages or software tools should be used to complete the task.
  • Focus on accessibility: If relevant, specify any requirements for accessibility, such as making sure the end product is responsive and viewable on different devices, or ensuring that the code is structured in a semantic way.
  • Be concise: Write clear and straightforward prompts that are easy to understand. Avoid using overly complex language or convoluted sentence structures.
  • Test your prompt: Run the prompt a few times through ChatGPT and make alterations until it matches the desired result.

In conclusion, successful prompt engineering requires a careful balance of technical accuracy, readability, and context. By using clear and concise language, avoiding overly complex terminology, and providing enough background information, you can help ensure that ChatGPT generates accurate and meaningful responses that meet the needs of your audience. And remember, the key to success is practice and experimentation, so keep refining your prompts and testing them out until you achieve the results you’re looking for.

Yes, this article was written with the help of ChatGPT, and I’m grateful for its assistance in helping me share these insights with you.

--

--

No responses yet