| |

Prompting: Getting AI models to do what you want

In the world of artificial intelligence, making AI models do exactly what we want can be a real challenge. Despite their vast potential, crafting the perfect prompt to guide these models can be a daunting task.

The key to unlocking the true power of AI models lies in mastering the art of creating effective prompts. By refining our interactions and avoiding common pitfalls, we can steer AI models to produce the desired outcomes more consistently.

What is a prompt?

AI prompts are essential for interacting with AI models, as they serve as the starting point for the model’s thought process. They can range from simple, straightforward questions to more complex and nuanced downstream tasks that require the AI to synthesize information, draw inferences, or provide creative solutions. The quality and clarity of a prompt can greatly influence the output generated by the AI model, making it crucial to craft prompts that effectively convey the user’s intent and desired outcome.

Zero-shot prompting

Zero shot prompting visualized.

In zero-shot prompting, the AI model relies solely on its pre-existing knowledge and general understanding of language, as well as its ability to reason and infer from the information embedded within the large language of the prompt. This approach contrasts with few-shot and many-shot learning, where the model is given a limited or extensive number of examples, respectively, to help guide its responses.


Imagine you have a powerful AI language model like GPT-3, which has been trained on a large dataset containing text from various sources. You want the AI language models to provide a summary of a given article.

You could use zero-shot prompting by simply providing the AI model with the text of the article followed by a concise instruction, like “Please summarize the following article in three sentences:”. The AI model would then process the input text, extract the most important points, and generate a summary without having been trained explicitly on the task of summarizing articles.

This is possible because GPT-3, and similar AI models, have a large language model and wide range of text during their training, allowing them to generalize and perform new tasks, like summarization even without specific examples or prior training on that task.

One-shot prompting

One shot prompting visualized.

One-shot prompting is a technique used with AI models, where the model is given a task description and a single example to learn from and generate a response to a given prompt. The AI model uses this task description and example as a reference to understand the task and produce an appropriate output.

One-shot prompting strikes a balance between zero-shot prompting, which provides soft prompts with no examples, and few-shot or many-shot learning, which involves multiple examples to guide the model’s responses.


Let’s assume you are using ChatGPT, and you want it to convert temperatures from Fahrenheit to Celsius. Instead of providing multiple examples or no examples at all, you give the AI one example to learn from.

You could provide the following prompt:

A code example from OpenAI.

The AI model processes the example and learns that it is supposed to convert temperatures. It then uses this understanding to perform the requested conversion, providing an output like “68°F is approximately 20°C.”

In one-shot prompting, the AI model leverages its pre-existing knowledge and general understanding of language, combined with the provided example, to perform the task at hand. This approach can be particularly helpful when the model may struggle to infer the desired output using zero-shot prompting alone.

Few-shot prompting

Few shot prompting visualized

Few-shot prompting is a technique used with AI models in which the model is given only a small number of examples (usually between 2 and 10) to learn from and generate a response to a given prompt. These examples serve as a reference, enabling the model to better understand the task and produce more accurate outputs.

Few-shot prompting offers more guidance to the AI model than one-shot prompting, while still avoiding the need for extensive training data. It helps the model generalize from the few examples provided and apply that understanding to new, unseen prompts.

Example 1

You are using ChatGPT, and you want it to provide rhyming couplets based on a given theme. You could provide a few examples to guide the model:

A code sample from OpenAI.

By providing these examples, the AI model learns to create rhyming couplets based on a given theme and then generates a new couplet following the pattern, such as:

Example from OpenAI.

Example 2

You want the AI model to classify emails as spam or not spam. You can provide a few examples to guide the model:

A code sample from OpenAI.

With these examples, the AI model learns to differentiate between spam and not spam. It then classifies the given email subject, likely as “Spam.”

What is prompt engineering?

Prompt engineering visualized.

Prompt engineering is a crucial aspect of working with AI models as they are basically prompts designed by hand by humans, particularly those focused on natural language processing. It involves designing and optimizing prompts to improve an AI model’s performance, reliability, and usefulness, ensuring that generated outputs align with the user’s intent and desired outcome.

The process requires crafting clear, concise prompts while providing context and examples as needed. It often involves iterative refinement to identify the most effective prompt structure and phrasing for a given task. By mastering prompt engineering, users can obtain more accurate, relevant, and reliable results from AI models, leading to more efficient and productive interactions.

How does prompt engineering work?

The main goal of prompt engineering is to maximize the model’s performance, accuracy, and usefulness by carefully crafting prompts that convey the user’s intent and the desired outcome. This is achieved through several techniques and considerations, including providing clear instructions, sufficient context, and examples when necessary.


Imagine you’re using ChatGPT to give you a summary of a book. Instead of providing a vague or ambiguous prompt like “Tell me about this book,” you could use prompt engineering techniques to create a more effective prompt.

A better prompt might be: “Please provide a concise summary of the book ‘To Kill a Mockingbird’ by Harper Lee, including a description of its main themes and characters, in approximately 100 words.”

In this example, the prompt is clear, specific, and provides context. The AI model now has a better understanding of the task and can generate a more accurate and relevant summary.

Prompt engineering is an iterative process, requiring experimentation and refinement to find the most effective way to communicate the desired task to the AI model. By mastering prompt engineering, users can obtain more accurate, relevant, and reliable results from AI models, leading to more efficient and productive interactions with larger models.

Why is prompt engineering important?

Prompt engineering is a critical aspect of harnessing the full potential of AI models, particularly those focused on natural language processing. The importance of prompt engineering lies in its direct impact on the quality, accuracy, and relevance of the model’s output. A well-crafted prompt not only enhances the user experience but also addresses task complexity by providing appropriate guidance and clarity to the model. In doing so, it resolves ambiguity and improves overall efficiency, saving time and resources by reducing the number of iterations required to obtain the desired output.

Furthermore, prompt engineering allows for customization, enabling users to tailor the AI model’s responses according to their specific needs or preferences. This results in more personalized and contextually relevant outputs. Another crucial aspect of prompt engineering is its role in addressing ethical considerations. By crafting prompts with appropriate constraints and guidelines, AI models are prevented from generating potentially harmful, biased, or offensive content, aligning the outputs with ethical considerations and user expectations. In essence, prompt engineering is essential for optimizing interactions between users and AI models, ensuring that the generated outputs meet user expectations and cater to their specific needs, ultimately leading to more efficient and productive interactions.

What is prompt tuning?

Prompt tuning visualization.

Prompt tuning is a heavier-weight approach compared to prompt engineering, which involves refining the input given to the model in the form of prompts. By fine-tuning the AI model’s parameters, prompt tuning enables more targeted adjustments to the model’s behavior, leading to more accurate, relevant, and reliable outputs. Through prompt tuning, the model learns subtle adjustments to its internal representations, which helps it perform better on specific tasks or prompts without requiring extensive retraining or modification of the base model. In a more commercial sense, prompt tuning allows a company with limited data to tailor a massive model to a narrow task.

How does prompt tuning work?

Prompt tuning can be visualized as a guided communication process between a user and an AI model. Think of the AI as a highly knowledgeable, yet sometimes overly literal or verbose partner in a conversation. Your goal is to extract the most accurate, relevant, and concise information from the AI using carefully designed text prompts.

Begin with an initial prompt tuning. For example, if the user’s query is “What is prompt tuning?”, then modify the query to be more specific, e.g., “Explain the concept of prompt tuning in AI and its purpose.” After that analyze the AI’s response, and if necessary, modify the prompt again to get a more accurate or concise answer, e.g., “In two sentences, describe prompt tuning and its benefits in AI.”

Why is prompt tuning important?

Prompt tuning helps to overcome some of the inherent limitations of AI models, such as their tendency to be overly verbose or literal, by encouraging more focused and concise outputs. As AI technology continues to evolve and become increasingly integrated into various aspects of our lives, having a thorough understanding of prompt tuning will be essential in optimizing the performance of AI models, ultimately leading to more fruitful human-AI collaborations. By fostering this synergy, we can ensure that AI technology serves us in the most effective way possible, enhancing our productivity and facilitating better decision-making across a wide range of domains.

What is fine-tuning?

Visualization of AI fine tuning.

In model tuning, you fine tune the same model on different tasks. This gives you a few different models, with which you can’t necessarily batch inputs easily. Pre-trained models like GPT-3 are initially trained on vast amounts of data, learning language patterns, grammar, and acquiring general knowledge. However, these models may still struggle to perform optimally on specialized tasks or generate domain-specific responses.

Fine-tuning comes into play when users want to tailor the AI model to their specific needs. By providing a smaller, curated dataset that reflects the nuances of the task or industry in question, users can refine the AI model’s understanding and improve its performance in the target domain. This customization ensures that the AI model not only retains its vast general knowledge but also becomes proficient in handling unique, industry-specific requirements.

For instance, a company working in the pharmaceutical industry might fine-tune a language model on medical literature and pharmaceutical guidelines, enabling the AI to generate more accurate and reliable responses in that context. By leveraging fine-tuning, users can tap into the full potential of AI language models, transforming them into powerful tools that cater to their specific needs and challenges, ultimately leading to increased efficiency, better decision-making, and more successful AI deployments.

How does fine-tuning work?

The fine-tuning process itself involves training the AI model on this specialized dataset for a certain number of epochs, allowing the model to adjust its parameters and learn the patterns, terminology, and nuances unique to the user’s application. This training should be done carefully to avoid overfitting or underfitting, striking the right balance between retaining the model’s general knowledge and adapting it to the specific use case.

Once the fine-tuning process is complete, the AI model becomes a highly customized tool, proficient in the user’s target domain. This tailored model can then be deployed to tackle the user’s specific challenges, yielding more accurate, relevant, and reliable results than a general-purpose, pre-trained model could achieve. By embracing fine-tuning, users can unlock the true potential of AI technology, transforming it into a powerful ally that caters to their unique needs and demands, ultimately driving success and innovation in their domain.

Why is fine-tuning important?

By fine-tuning an AI model, users can ensure that the model generates more accurate, relevant, and reliable results in their specific context, which in turn leads to better decision-making, improved efficiency, and increased productivity. This customization process also allows the AI model to become more aligned with the user’s goals and objectives, making it a more effective and valuable asset in addressing their unique challenges.

Furthermore, fine-tuning can help mitigate some of the limitations or biases inherent in pre-trained models, which may have been influenced by the diverse and uncontrolled nature of the data they were initially trained on. By training the AI on a carefully curated, specialized dataset, users can guide the model towards more objective, reliable, and context-appropriate responses, ultimately enabling them to leverage the full power of AI technology in their specific domain, and drive innovation and scale to success.

What is prompt engineering vs. prompt tuning?

Prompt engineering vs prompt tuning visualized.

Prompt engineering and prompt tuning are two complementary approaches to optimizing AI performance and output. While both strategies focus on refining the interaction between the user and the AI, they differ in their specific objectives and techniques.

Prompt engineering is the art of designing effective input prompts to elicit desired responses from the AI model. This process often requires creativity and experimentation in formulating the prompt, as well as a deep understanding of the AI’s strengths and weaknesses. By adding context, clarifying expectations, and iteratively refining the prompt based on the AI’s responses, users can guide the AI towards generating more accurate, relevant, and context-aware results. Prompt engineering is especially useful when working with pre-trained models, as it allows users to obtain better outputs without having to modify the underlying model.

On the other hand, prompt tuning is a more advanced technique that involves fine-tuning the AI model itself, specifically targeting the model’s ability to generate desired responses for a given input prompt. Prompt tuning can be viewed as a subset of the broader fine-tuning process, with a focus on improving the AI model’s performance on specific prompts or prompt structures. By training the AI model on a specialized dataset containing examples of input prompts and their corresponding desired outputs, users can optimize the model’s behavior and improve its ability to handle similar prompts in the future.

Both prompt engineering and prompt tuning serve the ultimate goal of enhancing the AI’s performance and maximizing its potential for users. While prompt engineering is often quicker and requires less computational resources, prompt tuning can lead to more significant and lasting improvements in the AI’s behavior, making it a powerful tool for users seeking to tailor the AI model to their specific needs and challenges. In practice, users may choose to employ a combination of these techniques, leveraging their unique strengths to achieve the best possible results from their AI models.

What is prompt tuning vs. fine-tuning?

Prompt tuning vs. Fine tuning visualized.

Prompt tuning focuses on refining the input text prompts given to the AI model in order to elicit more accurate, relevant, and context-aware responses. This involves carefully crafting the prompts by adding context, clarifying expectations, and iteratively refining the input text based on the AI’s responses. The key advantage of prompt tuning is that it doesn’t require modifying the underlying AI model, making it a quicker and more resource-efficient approach. Prompt tuning is particularly beneficial when working with pre-trained models, as it enables users to extract better outputs without having to retrain or adapt the model itself.

Fine tuning, on the other hand, is the process of adapting a pre-trained AI model to perform better on specific tasks, domains, or applications by training it on a smaller, specialized dataset. This dataset reflects the nuances of the user’s target domain or task, allowing the AI model to learn the patterns, terminology, and context unique to that specific use case. Fine tuning requires more computational resources and time than prompt tuning, as it involves retraining the AI model and adjusting its parameters. However, it can lead to more significant and lasting improvements in the AI model’s prediction performance, making it a powerful tool for users seeking to tailor the AI model to their specific needs and challenges.

Which method is easiest?

Level of difficulty in using prompt engineering, prompt tuning, and fine tuning.

There is a clear progression in the level of machine learning expertise required as we explore the various methods to optimize AI models. Prompt engineering, which focuses on crafting effective input prompts, does not necessitate in-depth knowledge of the machine learning models, making it accessible for users with limited technical backgrounds.

As we move to more advanced techniques like prompt tuning and fine-tuning, a stronger understanding of machine learning becomes essential. Prompt tuning involves working with the AI model and supplying it with the desired prompts, while fine-tuning requires additional training of the original model on a specific dataset tailored to the user’s needs. Reinforcement learning from human feedback (RLHF), though not covered in this article, is the most complex method and demands expertise in designing mechanisms for collecting human feedback. As users progress through these techniques, they can harness the full potential of AI models by selecting the most appropriate method based on their unique challenges and technical proficiency.

Final thoughts

In conclusion, getting AI models to do what you want requires a combination of techniques tailored to your specific use case. For general tasks, zero-shot, one-shot, and few-shot prompting can provide valuable results without additional training. To further optimize performance, prompt engineering can help craft effective input prompts, while prompt tuning and fine-tuning enable customization of the AI model to suit specialized tasks or domains. The best method depends on your unique requirements: prompt engineering and prompting strategies are ideal for quick and resource-efficient optimization while fine-tuning offers deeper customization for more specialized needs. By understanding and leveraging these techniques, you can harness the full potential of AI models, transforming them into powerful tools that cater to your specific challenges and drive success in your domain.

Similar Posts