[00:00]
Did you know that an AI processes
[00:01]
language and responds better when you
[00:03]
ask the right way? Let's learn
[00:09]
how. Today, I'm going to teach you what
[00:12]
you need to know about large language
[00:14]
models or LLMs and how to interact with
[00:16]
them with prompt engineering. Prompts
[00:19]
are what power LLM to make us more
[00:21]
productive in our work. When you
[00:23]
understand the power of prompting and
[00:25]
its limitations, you can do even more
[00:28]
faster. I'm Cadesha and I'm so excited
[00:31]
that you're here with me today. Let's
[00:33]
dive right
[00:36]
in. Before we get into prompt
[00:38]
engineering, we should understand more
[00:40]
of what LLMs are under the hood. Large
[00:43]
language models are a type of AI that
[00:45]
are trained on large, hence the name,
[00:48]
amounts of text data to understand and
[00:50]
generate humanlike language. They work
[00:53]
by predicting the next word in a
[00:54]
sentence based on the context of the
[00:57]
words that came before it, making their
[00:59]
responses relevant and coherent to
[01:01]
humans that use them. You can think of
[01:03]
it as an ultra smart autocomplete. There
[01:06]
are three things you really need to know
[01:08]
to understand LLMs. Context, tokens, and
[01:13]
limitations. Think of context as a
[01:16]
surrounding information that helps an
[01:17]
LLM understand what you're talking
[01:19]
about. Just like in a conversation with
[01:22]
a friend, the more context you have, the
[01:25]
more the conversation will make sense.
[01:27]
In the world of LLMs, text is broken
[01:30]
down into units of tokens. A token can
[01:33]
be a word, a part of a word, or even a
[01:36]
single letter. The AI model processes
[01:39]
tokens to generate responses. The number
[01:42]
of tokens you use with an LLM can impact
[01:44]
its response. Too few tokens and it may
[01:47]
lack context, but too many and it might
[01:50]
get
[01:51]
overwhelmed. While LLMs are powerful,
[01:54]
they aren't all powerful. They don't
[01:57]
truly understand language like humans
[01:59]
do. They rely on patterns and
[02:02]
probabilities that were in the data they
[02:04]
trained on. We won't get into the
[02:06]
training side of things in this episode,
[02:09]
but hopefully this quickly explains why
[02:11]
we need a diverse and broad training set
[02:14]
for the best
[02:15]
responses. Models are never perfect, so
[02:18]
they sometimes provide incorrect or
[02:20]
nonsensical answers, sometimes called
[02:24]
hallucinations. You can work with LM's
[02:26]
power and limitations by combining
[02:28]
everything into a prompt. A prompt gives
[02:31]
the model context via tokens and works
[02:34]
around the model's potential limitations
[02:36]
so that the model can give you a
[02:38]
response. For example, if you prompt an
[02:41]
LLM with write a JavaScript function to
[02:44]
calculate the factorial of a number, it
[02:47]
will use its training to give you a
[02:48]
function that accomplishes that task.
[02:51]
Depending on how the model was trained,
[02:53]
it may understand your prompt
[02:55]
differently and output different code.
[02:58]
This is why you may see different
[02:59]
outputs from various models out in the
[03:02]
world like OpenAI's GPT, Anthropics
[03:05]
Claude, Google's Gemini, and so on and
[03:07]
so forth. These are all trained
[03:10]
differently and understand an output
[03:12]
differently as a
[03:14]
result. So now we know what a prompt is,
[03:17]
but what is prompt engineering?
[03:20]
Honestly, it's just a term for crafting
[03:23]
prompts. Just like how clear
[03:25]
instructions can help a friend complete
[03:26]
a task exactly how you want, a
[03:29]
well-crafted prompt can help an LLM
[03:31]
understand and deliver what you're
[03:32]
looking for, good prompt engineering can
[03:35]
drastically improve the quality and
[03:38]
relevance of the outputs you get from an
[03:40]
LLM. Now, let's talk about some key
[03:43]
components of effective prompting. An
[03:46]
effective prompt is clear and precise.
[03:49]
Ambiguity can confuse the model, so
[03:52]
don't forget that an effective prompt
[03:55]
also gives enough context. You want to
[03:58]
provide enough background information to
[04:00]
get the job done without overwhelming
[04:02]
the model with unnecessary detail. And
[04:06]
don't forget, you can always iterate and
[04:08]
refine your prompts. If you ask for
[04:10]
something and you don't get what you
[04:12]
expect, tweak your language. Now,
[04:16]
imagine you're using GitHub Copilot and
[04:18]
you say, "Write a function that will
[04:20]
square numbers in a list." At first
[04:23]
glance, this sentence isn't too bad. But
[04:26]
let me ask you, what language should the
[04:29]
function be written in? Do you want to
[04:31]
include negative numbers? Will the input
[04:33]
ever have non- numbers? Should it affect
[04:36]
the given list or return a new list?
[04:39]
Let's refine our prompt a bit. So we can
[04:41]
say write a Python function that takes a
[04:44]
list of integers and returns a new list
[04:47]
where each number is squared excluding
[04:49]
any negative numbers. Do you see the
[04:52]
difference? This prompt is clear and
[04:54]
specific about the language we want to
[04:56]
use, what the function should do, what
[04:59]
constraints there are, and the expected
[05:01]
input type. By giving GitHub Copilot
[05:04]
more context, the output will be more
[05:06]
relevant to exactly what we want from
[05:08]
it. In summary, prompt engineering is
[05:11]
really about being a good communicator
[05:13]
with the computer. Very similar to
[05:15]
coding. By crafting your prompts
[05:18]
thoughtfully, you can harness the full
[05:20]
power of tools like GitHub Copilot to
[05:23]
make your experience smoother and more
[05:25]
efficient. Now, as you're working with
[05:28]
GitHub Copilot and other LLM tools, you
[05:31]
may run into times where you're not
[05:32]
getting the output you hoped for. The
[05:35]
problem isn't always because you're not
[05:37]
specific enough. Here are some things
[05:39]
you might be running into and how you
[05:40]
can improve them. Prompt confusion.
[05:43]
Sometimes we mix multiple requests or
[05:45]
aren't clear enough which can lead to
[05:47]
confusing outputs. For example, we might
[05:50]
highlight something in VS Code and say
[05:52]
fix the errors in this code and optimize
[05:55]
it. Is the AI supposed to fix the errors
[05:57]
or optimize it first? What should it
[06:00]
optimize for? Speed, memory,
[06:03]
readability? To solve this, break it
[06:06]
down. Separate your asks in the prompt.
[06:10]
First, fix the errors in the code
[06:12]
snippet. Then, optimize the fixed code
[06:16]
for better performance. Building out a
[06:18]
prompt iteratively will make it more
[06:20]
likely that you get the final result
[06:21]
that you want because each step of the
[06:24]
way has been thought through. We've
[06:26]
discussed that tokens are units of words
[06:28]
or partial words that a model can
[06:30]
handle. It's important to remember that
[06:33]
there's a limit to how many tokens a
[06:35]
given model can handle at once. If your
[06:38]
prompt is too long or the expected
[06:40]
output is very extensive, the LLM might
[06:43]
start hallucinating, cut itself off, and
[06:46]
only give you a partial response or just
[06:48]
fail entirely. You want to keep your
[06:50]
prompts concise. Similarly to before,
[06:54]
you will want to iterate on smaller
[06:55]
parts, but also only provide necessary
[06:59]
context. Does the LLM need your entire
[07:02]
code file to work or can it just use a
[07:04]
few lines of code in a certain function?
[07:07]
Instead of asking for it to generate an
[07:09]
entire application, could you ask it to
[07:11]
make each component step by step? And
[07:15]
finally, we often assume that the LLM
[07:18]
knows more than it does. If you say,
[07:20]
"Add authentication to my app," does it
[07:23]
know what your app even does? Does it
[07:25]
know which technologies you might want
[07:27]
to use? When doing a prompt like this,
[07:30]
you need to explicitly state your
[07:32]
requirements, outline your specific
[07:35]
needs, mention best practices if needed,
[07:37]
and be ready to iterate again with edge
[07:41]
cases and restraints. By stating all
[07:44]
your requirements, you help ensure that
[07:46]
the LLM doesn't overlook critical
[07:48]
aspects of your request when it
[07:50]
generates the output. We've gone over a
[07:53]
lot in this section. Prompt engineering
[07:56]
is an art and a science and you'll get
[07:58]
better with practice. As a quick
[08:01]
overview, when you're working with
[08:03]
GitHub Copilot or any other LLM tool,
[08:06]
you use tokens to give the model context
[08:09]
given any limitations it might have.
[08:11]
Your prompts should be clear, concise,
[08:14]
and precise for the best results,
[08:16]
providing as much context as the model
[08:19]
might need. You should break down your
[08:21]
prompts into smaller chunks. If there
[08:23]
are multiple tasks to be completed and
[08:26]
iterate from there, you should be
[08:28]
specific about your requirements and
[08:30]
needs so that the model understands the
[08:32]
constraints of what it should provide
[08:34]
for you. Thanks so much for joining us
[08:36]
today and if you want to learn more,
[08:38]
we've created a blog post that
[08:40]
accompanies this episode. Click the link
[08:42]
in the description to be taken there.
[08:44]
Remember to sign up for GitHub Copilot
[08:46]
if you haven't already done so and get
[08:48]
started for free. Don't forget to
[08:50]
subscribe to our channel so you don't
[08:52]
miss any future episodes. Until then,
[08:55]
happy coding.
[08:59]
[Music]