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