Alex de Pablos
Technology

Maximizing GPT: Strategies and Tactics

Alex de Pablos Lopez4 min

Let’s see how to get the most out of generative language models, specifically GPT (Generative Pretrained Transformer) from OpenAI.

If you’re interested in artificial intelligence, and want to learn how to put it on your side, this post is for you. 🚀

What is GPT?

GPT is a generative language model developed by OpenAI. It is capable of generating text that is surprisingly coherent and relevant for a wide range of tasks. But, like any tool, there are ways to use it that can improve the results we get.

Strategies to Improve Results with GPT

Here I present six strategies that you can use to get better results from GPT

  1. Write Clear Instructions: GPT can’t read your mind. If the answers are too long, ask for short answers. If they are too simple, request expert-level writing. The less GPT has to guess what you want, the more likely you are to get it. At this point, it’s important to highlight that being explicit can significantly reduce the hallucinations of these systems, which is one of their biggest issues.
  2. Provide Reference Text: GPT can confidently make up false answers, especially when asked about esoteric topics or asked for quotes and URLs. Providing a reference text to GPT can help answer with fewer hallucinations.
  3. Break Down Complex Tasks into Simpler Subtasks: Just as it is good practice in software engineering to break down a complex system into a set of modular components, the same is true for tasks sent to GPT. Complex tasks tend to have higher error rates than simpler tasks.
  4. Give GPT Time to “Think”: If GPT is asked to multiply 17 by 28, it may not know immediately, but it can still work to get an answer. Asking for a chain of reasoning before an answer can help GPT reason its way to more reliable correct answers.
  5. Use External Tools: Compensate for GPT’s weaknesses by feeding it with the outputs of other tools. For example, a text retrieval system can inform GPT about relevant documents. A code execution engine can help GPT do math and run code.
  6. Test Changes Systematically: Improving performance is easier if you can measure it. In some cases, a modification to a prompt may achieve better performance on some isolated examples but lead to worse overall performance on a more representative set of examples.

Tactics to Improve Results with GPT

Each of the strategies mentioned above can be implemented with specific tactics. These tactics are intended to provide ideas for things you can try. They are by no means completely exhaustive, and you should feel free to try creative ideas not represented here.

Write Clear Instructions

Tactic: Include details in your query to get more relevant answers

To get a highly relevant answer, make sure requests provide any important detail or context. Otherwise, you’re leaving the model to guess what you mean.

Tactic: Ask the model to adopt a personality

The system message can be used to specify the personality that the model should adopt in its responses. For example, you can ask the model to include at least one joke or comment with a specific tone in each paragraph.

Tactic: Explicitly tell it that you don’t want it to make things up if it doesn’t know them

Simply tell it something like “If you don’t know the answer, say ‘I don’t know,’ but don’t make up an answer”. This obviousness significantly reduces the system’s rate of hallucination.

Provide reference text

Tactic: Instruct the model to respond using a reference text

If we can provide the model with reliable information that is relevant to the current query, then we can instruct the model to use the provided information to compose its response.

Break down complex tasks into simpler subtasks

Tactic: Use intent classification to identify the most relevant instructions for a user query

For tasks where many independent sets of instructions are needed to handle different cases, it may be beneficial to first classify the type of query and use that classification to determine what instructions are needed.

Give GPT Time to “Think”

Tactic: Instruct the model to elaborate its own solution before rushing to a conclusion

We sometimes get better results when we explicitly instructthe model to reason from basic principles before reaching a conclusion.

Use External Tools

Tactic: Use embedding-based search to implement efficient knowledge retrieval

A model can leverage external sources of information if we provide a way to dynamically search for information relevant to the question being asked.

Test Changes Systematically

Tactic: Evaluate the model’s outputs with reference to gold standard answers

Improving performance is only possible if you can measure it. Therefore, to be sure that a change is net positive for performance, it may be necessary to define a comprehensive test set.

Remember, learning is a journey, not a destination. So keep exploring, keep asking, keep learning. And while you do, don’t forget to enjoy the journey. See you in the next post, where we will continue to explore together the wonders and challenges of Technology. Until next time!