New Jobs Simplified, AI University
← Back to courses

Prompts & Prompt Engineering

System Prompts & Personas

This lesson covers the basics of system prompts, what they are, and how they are used in AI systems. We will also explore the importance of personas in prompts and how they can improve the quality of AI outputs.

Why It Matters

System prompts and personas matter in the real world of AI because they enable us to interact with AI systems in a more natural and intuitive way. By using specific prompts and personas, we can improve the quality of AI outputs and make them more relevant to our needs. This is particularly important in applications such as language translation, customer service, and content generation.

Key Points

System Prompts: A system prompt is a short input that an AI system uses to generate a response. It can be as simple as a few words or a complete question.
Basic Ingredients of a Prompt: A basic prompt typically consists of instruction, data, and output indicators. For example, "write a short story" is a basic prompt that instructs the AI to generate a short story, provides no data, and expects a story as output.
Advanced Prompt Components: Advanced prompts can include additional components such as context, tone, and style. For example, "write a short story in a sci-fi style" adds a tone and style component to the basic prompt.
Instruction-Based Prompting: Instruction-based prompting involves asking the AI to perform a specific task, such as classification, summarization, or generation.
Prompt Templates: Prompt templates are pre-defined formats for prompts that can be used to generate consistent and high-quality outputs.
Parallel Prompts: Parallel prompts involve generating multiple prompts simultaneously to improve the quality and diversity of outputs.
Conversational Prompts: Conversational prompts involve using a chat template to engage in a conversation with the AI.

Key Concepts

Prompt

A short input that an AI system uses to generate a response.

Persona

A character or personality that a prompt is written from.

Instruction-Based Prompting

Asking the AI to perform a specific task, such as classification, summarization, or generation.

Prompt Template

A pre-defined format for prompts that can be used to generate consistent and high-quality outputs.

Parallel Prompts

Generating multiple prompts simultaneously to improve the quality and diversity of outputs.

Code Examples

Creating a prompt template using the LangChain library

template = '''<s><|user|> {input_prompt}<|end|> <|assistant|>'''

Using a prompt template to generate a response

prompt = PromptTemplate(template, input_prompt='Hello, how are you?')
From the books
“be in a prompt? The Basic Ingredients of a Prompt An LLM is a prediction machine. Based on a certain input, the prompt, it tries to predict the words that might follow it. At its core (illustrated in …”
“using LLMs sequentially to get improved results. Eventually, we will even build up to advanced reasoning techniques. The Potential Complexity of a Prompt As we explored in the intro to prompt engineer…”
“Figure 6-9 illustrates a number of use cases in which instruction-based prompting plays an important role. We already did one of these in the previous example, namely supervised classification. Figure…”

Quick Quiz

1. What is a system prompt?

A) A short input that an AI system uses to generate a response.
B) A pre-defined format for prompts.
C) A character or personality that a prompt is written from.
D) A specific task that the AI is asked to perform.

2. What is instruction-based prompting?

A) Asking the AI to perform a specific task, such as classification, summarization, or generation.
B) Generating multiple prompts simultaneously to improve the quality and diversity of outputs.
C) Using a chat template to engage in a conversation with the AI.
D) Creating a prompt template using the LangChain library.

3. What is the purpose of a prompt template?

A) To improve the quality and diversity of outputs.
B) To generate consistent and high-quality outputs.
C) To engage in a conversation with the AI.
D) To ask the AI to perform a specific task.