Playing with Prompts

May 24, 2023

Why?

  • Large Language Models are the latest hot topic, mainly thanks to ChatGPT.
  • Being able to correctly interact with an LLM is becoming an increasingly valuable skill
  • Prompt Engineering is an interesting field that allow us to better understand how LLMs work

In recent times, Large Language Models (LLMs) have gained tremendous popularity, and ChatGPT is among the leading ones. The capability to interact with LLMs is gaining more value. Prompt Engineering acts as an intriguing field, aiding us in comprehending the mechanisms of LLMs better. **

Basic principles

  • use delimiters and list to make the prompt more explicit
  • be clear about what are the "rules" and what is the content that needs to be evaluated
  • give the model more time to think, by splitting the prompt in multiple steps
  • ask the model to generate an answer for each step to increase consistency (chain-of-thoughts)

In order to enhance the performance of language models, there are several techniques that can be employed. One of the most effective is to use delimiters and lists to make the prompts clearer. By using these tools, the model is better able to distinguish between the rules and the content that needs to be evaluated, allowing it to generate more accurate responses. Another approach is to break the prompt down into multiple steps, asking the model to generate an answer for each step. This gives the model more time to consider its response and creates a more consistent chain-of-thoughts. By implementing these strategies, language models can be improved to better serve their intended purposes. **

A fairly reusable template

Even if the meta-prompt needs to be refined and adjusted depending on the specific task, we can generate a fairly generic template for generating prompts

Your job is to perform the following tasks; for each task generate a separate section:
1. <Read the actual prompt delimited by a unique marking (___)>
2. <Intermediary step>
3. <Generate the output applying a specific style>.
___
<The actual prompt>
___

Next steps

  • Divide each sub-step (thought) in a separate completion
  • Use another instance of the model to evaluate the output of the previous step
  • Implement the Tree of Thoughts Paper - Video Explanation

  • As we continue to develop our approach to problem-solving, there are a few areas I'm particularly interested in exploring further. Firstly, I believe that dividing each sub-step into a separate completion could be a game-changer. Secondly, I think it would be valuable to use another model to evaluate the output of each step. And finally, I'm excited to try implementing the Tree of Thoughts. **

    Some notes on this post

    • All the text is generated using OpenAi APIs with gpt-3.5-turbo as model
    • This is a work in progress, I'll update it as I explore about prompt engineering
    • All the text that have been generated by AI is marked with **; the original prompt and completion are hidden in a collapsible section. In each section I also provided the the list of my inputs (in small)

    I'm still not sure how the following components affect the model performance:

    • the size of the meta-prompt (compared with the size of the actual prompt)
    • the total length

    During the generation of this post I noticed that formatting characters (like * or - for a list) are tends to confuse the model. All the latest attempts were done using without any special formatting.

    All the example presented in this post used the LLM as a tool to transform and enhance the knowledge provided inside the actual prompt. Other experiments done with tasks that required knowledge provided by the model itself (not just understanding and rephrasing) seems to show that all the principles presented in this post are still valid.

    All the code used to interact with GPT is available on Github


Profile picture

Hi there! My name is Roberto and I am a Senior Software Engineer with more than 15 years of experience.

© 2024, Roberto Serra - github