Lavanya.ai
AI • Growth • Startups • Building
PROMPT ENGINEERING
Prompt Engineering
GenAI Enterprise Accelerator Master Class
LAVANYA.AI
Industry leading partnerships
Streamlined End-to-End ML & LLM Workflow
Technology
AI Developer Platform
Customers
1000+ Enterprises & AI Leaders
Leadership
Community & Ecosystem
Ecosystem >50,000 repo & framework integrations
Investors
Weights & Biases
Mission: Build the best tools for AI developers
Series C: $250m in funding
W&B Models
W&B Weave
W&B Core
Are you using GenAI today personally?
LAVANYA.AI
Are you exploring GenAI as a company?
LAVANYA.AI
Are you using GenAI in production?
LAVANYA.AI
Prototype To Production
Nov 4
Foundations of Prompting, RAG systems, Agents
Nov 25
Evaluate and Productionize AI Systems
Dec 16
Build and deploy a GenAI app end-to-end
LAVANYA.AI
Community
8
LAVANYA.AI
Ask Qs!
???
9
LAVANYA.AI
GenAI Accelerator was transformational for our team. Weights & Biases' depth of knowledge on GenAI is unmatched—it's clear why nearly every foundation model is built on their platform. Highly recommended for anyone serious about leveraging GenAI in their business.”
We will help you train your teams on GenAI best practices
James Cham
Partner, Bloomberg Beta
We will help you build production quality applications
The support we’ve received from Weights & Biases has been exceptional. They have been invaluable as thought partners and guides throughout our journey. Their deep expertise not only allowed us to anticipate potential roadblocks well in advance but also equipped us with well-considered solutions. Thanks to their guidance, we were able to bring the product to market more swiftly and with fewer challenges.”
Weave
Deliver GenAI with confidence
Monitor
Collaborate
Evaluate
Build
David Rogier
CEO, MasterClass
Prompt Engineering
1
Agenda
PE – Play
2
RAG
3
RAG – Play
4
Feedback
5
LAVANYA.AI
AI
Machine Learning
Deep Learning
LLMs
GenAI
Foundation Models
LAVANYA.AI
What’s so exciting?
LAVANYA.AI
LLMs massively expedite the ability for anyone to quickly build useful applications
LAVANYA.AI
Getting great results from LLMs doesn’t require knowledge of deep learning models, programming, math or statistics.
LAVANYA.AI
Democratization of AI
Foundation
Model Builder
ML
Engineer
Software
Developer
1000s
100,000s
10,000,000s
LAVANYA.AI
Your IP is all the things you tried along the way
LAVANYA.AI
These models are like zip files
compressing the knowledge of the entire internet
LAVANYA.AI
Transformers 🤿
LAVANYA.AI
2017
LAVANYA.AI
Self Attention
LAVANYA.AI
Multi-Headed Attention
LAVANYA.AI
Tokenization
LAVANYA.AI
Tokenizers
25
LAVANYA.AI
How much information can be included in a prompt depends on the model’s context length.
Context is memory
CONTEXT WINDOW
LENGTH
TOKEN
LAVANYA.AI
How much information can be included in a prompt depends on the model’s context length.
Context is memory
LAVANYA.AI
Fine-Tuning
Updating the weights of some or all layers of the pre-trained model to adapt it to the new task
Prompt Engineering
Prompt engineering is temporary learning during inference.
It lets us communicate with an LLM to steer its behavior without updating the model weights
RAG
For tasks that require latest knowledge after the model pretraining time cutoff or access to private knowledge base
LAVANYA.AI
Zero Shot & Few Shot Learning
LAVANYA.AI
Steer Behavior With Prompts
30
Q: Are whales fish?
A:
Model Output: No, whales are not fish. Whales are mammals. Here are some key differences between whales (mammals) and fish:
Breathing: Whales breathe air through lungs and must come to the surface to breathe. Fish, on the other hand, extract oxygen from water through their gills.
Body Temperature: Whales are warm-blooded, meaning they can regulate their body temperature internally. Fish are cold-blooded and their body temperature varies with the environment.
Reproduction: Whales give birth to live young and nurse them with milk. Most fish lay eggs, although there are some fish that give birth to live young.
Skin: Whales have smooth skin with a layer of blubber underneath for insulation. Fish have scales covering their bodies.
Movement: Whales move their tails up and down when swimming, while fish move their tails side to side.
These distinctions categorize whales as mammals and not fish.
Steer Behavior With Prompts
Q: Are whales fish?
A: No
Q: Are pig-nosed turtle mammals?
A:
Model Output: No
LAVANYA.AI
Steer Behavior With Prompts
Q: Are whales fish?
A: No, they're mammals.
Q: Are pig-nosed turtle mammals?
A:
Model Output: No, they're reptiles
Q: Are whales fish?
A: No
Q: Are pig-nosed turtle mammals?
A:
Model Output: No
LAVANYA.AI
Few-Shot Prompting
33
Classify the text delimited by triple backticks into one of the following classes.
Classes: {desired_tags}
Text: ```{ticket_text1}```
Class: question
Text: ```{ticket_text2}```
Class: type_bug
<...more examples here>
Text: ```{ticket_text}```
Class:
LAVANYA.AI
Each example in the prompt is a shot.
More powerful models
...need fewer examples
...to have better performance
LAVANYA.AI
Prompting with examples = better performance
Is prompting
useful on its own?
35
2. Clean the data – sheet
3. Ask questions – ChatGPT
1. Get the data – docs
LAVANYA.AI
Let’s try it!
Prompt
Structure
LAVANYA.AI
LAVANYA.AI
System &
User Prompts
SYSTEM
The system role sets the behavior of the assistant
ASSISTANT
ChatGPT (LLM) receives the prompt and returns the completions
USER
The user (You) sends the prompts and receives the completions
System
User
Assistant
context
prompt
response
LAVANYA.AI
System prompt
= task description
User prompt
= the task
LAVANYA.AI
System prompt = task description
User prompt = task
LAVANYA.AI
Is all context equal?
Temperature adjusts how adventurous the model is with its word choices by reshaping the probability landscape
High ~ Chatbots: Makes responses more varied and human-like, enhancing engagement
Low ~ Code Generation: Produces more predictable and stable outputs, reducing errors.
LAVANYA.AI
Temperature
nat.dev
42
Best
Practices
LAVANYA.AI
LAVNYA.AI
Write clear and explicit instructions
LAVANYA.AI
Use delimiters to clearly indicate distinct parts of the input
Specify the Output Format
LAVANYA.AI
Ask the model to adopt a persona
LAVANYA.AI
Provide examples
LAVANYA.AI
Bring your own texts as context
LAVANYA.AI
Ask the model if it missed anything on previous passes
LAVANYA.AI
Break complex tasks into simpler subtasks
LAVANYA.AI
Give the model time to think
❌
✅
LAVANYA.AI
Few-Shot
Show it reasoning examples
Chain of Thought
LAVANYA.AI
o1 from OpenAI
LAVANYA.AI
Project
LAVANYA.AI
Project
56
Data analysis with ChatGPT
LAVANYA.AI
Challenge
(10 mins)
57
2. Go to ChatGPT
1. Get the data wandb.me/class-data
Question Ideas
Gumption
LAVANYA.AI
Limited Context
We can’t feed it all our data
How do we judge if it’s right?
Rigorous evaluations for all expected use cases
How did it get better?
Save prompts, models
LAVANYA.AI
Challenges
RAG
LAVANYA.AI
Thank You
Learn more at lavanya.ai
2 Prompt Engineering
GenAI Enterprise Accelerator Master Class
Prompt Engineering
Industry leading partnerships
Streamlined End-to-End ML & LLM Workflow
Technology
AI Developer Platform
Customers
1000+ Enterprises & AI Leaders
Leadership
Community & Ecosystem
Ecosystem >50,000 repo & framework integrations
Investors
Weights & Biases
Mission: Build the best tools for AI developers
Series C: $250m in funding
W&B Models
W&B Weave
W&B Core
Are you using GenAI today personally?
64
Are you exploring GenAI as a company?
65
Are you using GenAI
in production?
66
Prototype To Production
Nov 4
Foundations of Prompting, RAG systems, Agents
Nov 25
Evaluate and Productionize AI Systems
Dec 16
Build and deploy a GenAI app end-to-end
Community
68
wandb.me/discord
ACCELERATOR.CC
Ask Qs!
69
GenAI Accelerator was transformational for our team. Weights & Biases' depth of knowledge on GenAI is unmatched—it's clear why nearly every foundation model is built on their platform. Highly recommended for anyone serious about leveraging GenAI in their business.”
We will help you train your teams on GenAI best practices
James Cham
Partner, Bloomberg Beta
We will help you build production quality applications
The support we’ve received from Weights & Biases has been exceptional. They have been invaluable as thought partners and guides throughout our journey. Their deep expertise not only allowed us to anticipate potential roadblocks well in advance but also equipped us with well-considered solutions. Thanks to their guidance, we were able to bring the product to market more swiftly and with fewer challenges.”
Weave
Deliver GenAI with confidence
Monitor
Collaborate
Evaluate
Build
David Rogier
CEO, MasterClass
Prompt Engineering
1
Agenda
PE – Play
2
RAG
3
RAG – Play
4
Feedback
5
GENAI ACCELERATOR
73
AI
Machine Learning
Deep Learning
LLMs
GenAI
Foundation Models
ACCELERATOR.CC
What’s so exciting?
LLMs massively expedite the ability for anyone to quickly build useful applications.
ACCELERATOR.CC
Getting great results from LLMs doesn’t require knowledge of deep learning models, programming, math or statistics.
ACCELERATOR.CC
Democratization of AI
Foundation
Model Builder
ML
Engineer
Software
Developer
1000s
100,000s
10,000,000s
ACCELERATOR.CC
Your IP is all the things you tried along the way
ACCELERATOR.CC
These models are like zip files
compressing the knowledge of the entire internet
ACCELERATOR.CC
ACCELERATOR.CC
Transformers 🤿
2017
ACCELERATOR.CC
Self Attention
ACCELERATOR.CC
Multi-Headed Attention
Tokenization
ACCELERATOR.CC
85
ACCELERATOR.CC
How much information can be included in a prompt depends on the model’s context length.
ACCELERATOR.CC
Context is memory
Context Window
Length
Token
How much information can be included in a prompt depends on the model’s context length.
ACCELERATOR.CC
Context is memory
ACCELERATOR.CC
Fine-Tuning
Updating the weights of some or all layers of the pre-trained model to adapt it to the new task
Prompt Engineering
Prompt engineering is temporary learning during inference.
It lets us communicate with an LLM to steer its behavior without updating the model weights
RAG
For tasks that require latest knowledge after the model pretraining time cutoff or access to private knowledge base
ACCELERATOR.CC
Zero Shot & Few Shot
Learning
Steer Behavior With Prompts
90
Q: Are whales fish?
A:
Model Output: No, whales are not fish. Whales are mammals. Here are some key differences between whales (mammals) and fish:
Breathing: Whales breathe air through lungs and must come to the surface to breathe. Fish, on the other hand, extract oxygen from water through their gills.
Body Temperature: Whales are warm-blooded, meaning they can regulate their body temperature internally. Fish are cold-blooded and their body temperature varies with the environment.
Reproduction: Whales give birth to live young and nurse them with milk. Most fish lay eggs, although there are some fish that give birth to live young.
Skin: Whales have smooth skin with a layer of blubber underneath for insulation. Fish have scales covering their bodies.
Movement: Whales move their tails up and down when swimming, while fish move their tails side to side.
These distinctions categorize whales as mammals and not fish.
Steer Behavior With Prompts
Q: Are whales fish?
A: No
Q: Are pig-nosed turtle mammals?
A:
Model Output: No
ACCELERATOR.CC
Steer Behavior With Prompts
Q: Are whales fish?
A: No, they're mammals.
Q: Are pig-nosed turtle mammals?
A:
Model Output: No, they're reptiles
Q: Are whales fish?
A: No
Q: Are pig-nosed turtle mammals?
A:
Model Output: No
ACCELERATOR.CC
Few-Shot Prompting
93
Classify the text delimited by triple backticks into one of the following classes.
Classes: {desired_tags}
Text: ```{ticket_text1}```
Class: question
Text: ```{ticket_text2}```
Class: type_bug
<...more examples here>
Text: ```{ticket_text}```
Class:
ACCELERATOR.CC
Each example in the prompt is a shot.
More powerful models
...need fewer examples
...to have better performance
ACCELERATOR.CC
Prompting with examples = better performance
Is prompting
useful on its own?
95
2. Clean the data – sheet
3. Ask questions – ChatGPT
1. Get the data – docs
ACCELERATOR.CC
Let’s try it!
ACCELERATOR.CC
Prompt Structure
ACCELERATOR.CC
System &
User Prompts
System
The system role sets the behavior of the assistant
Assistant
ChatGPT (LLM) receives the prompt and returns the completions
User
The user (You) sends the prompts and receives the completions
System
User
Assistant
context
prompt
response
ACCELERATOR.CC
System prompt
= task description
User prompt
= the task
ACCELERATOR.CC
System prompt = task description
User prompt = task
ACCELERATOR.CC
Is all context equal?
Temperature adjusts how adventurous the model is with its word choices by reshaping the probability landscape
High ~ Chatbots: Makes responses more varied and human-like, enhancing engagement
Low ~ Code Generation: Produces more predictable and stable outputs, reducing errors.
ACCELERATOR.CC
Temperature
nat.dev
102
ACCELERATOR.CC
Best Practices
ACCELERATOR.CC
Write clear and explicit instructions
ACCELERATOR.CC
Use delimiters to clearly indicate distinct parts of the input
ACCELERATOR.CC
Specify the Output Format
ACCELERATOR.CC
Ask the model to adopt a persona
ACCELERATOR.CC
Provide examples
ACCELERATOR.CC
Bring your own texts as context
ACCELERATOR.CC
Ask the model if it missed anything on previous passes
ACCELERATOR.CC
Break complex tasks into simpler subtasks
ACCELERATOR.CC
Give the model time to think
❌
✅
Few-Shot
Chain of Thought
ACCELERATOR.CC
o1 from OpenAI
ACCELERATOR.CC
ACCELERATOR.CC
Project
116
Data Analysis with ChatGPT
PROJECT
Challenge
(10 mins)
117
1. Get the data wandb.me/class-data
2. Go to ChatGPT
Question Ideas
Gumption
ACCELERATOR.CC
Challenges
Limited Context
We can’t feed it all our data
How do we judge if it’s right?
Rigorous evaluations for all expected use cases
How did it get better?
Save prompts, models
RAG
Community
120
wandb.me/discord
ACCELERATOR.CC
Keep the learning going!
@lavanyaai
lavanya@wandb.com
121
ACCELERATOR.CC
Thank You
lavanya@wandb.com
Resources
ACCELERATOR.CC
Prompt Engineering
Prompt engineering is temporary learning during inference.
It lets us communicate with an LLM to steer its behavior without updating the model weights.
Language models can learn the desirable behavior from examples in the prompt, even if this desirable behavior is different from what the model was originally trained to do.
In-context learning allows a model to update its behaviors with new information without retraining.
This significantly reduces the rate of a model going stale.
Prompting Techniques
ACCELERATOR.CC
Many model providers claim that well-crafted system prompts can improve performance.
But why would system prompts boost performance compared to user prompts?
The model pays attention to the system prompt more because:
ACCELERATOR.CC
System prompts >> User prompts
ACCELERATOR.CC
Prompt Engineering
ACCELERATOR.CC
Contexts & Prompts
How much information can be included in a prompt depends on the model’s context length limit.
ACCELERATOR.CC
Context is memory
ACCELERATOR.CC
Best Practices
Explain, without ambiguity, what you want the model to do
Ask the model to adopt a persona
Provide examples
Specify the output format
ACCELERATOR.CC
Tactics for RAG
Prompting to make RAG efficient
ACCELERATOR.CC
Use inner monologue or a sequence of queries to hide the model’s reasoning process
Use inner monologue
ACCELERATOR.CC
Instruct the model to work out its own solution before rushing to a conclusion
Give the model time to think