LLMs are incredibly useful tools, especially for programmers. I literally use LLMs each day, and may’t imagine a world without them. Nonetheless, there are a number of particular techniques you may utilize to realize even greater results with LLMs.
I’ve covered a number of different techniques in previous articles, comparable to:
- Using Slash commands
- Utilizing plan mode
- Constantly updating agents.md
In this text, I’ll cover how you may leverage few-shot prompting to have your LLMs perform even higher.
Why use few-shot prompting
Firstly, I need to cover why you must utilize few-shot prompting. Few-shot prompting is incredibly useful since it means that you can show the LLM your intent without having to explicitly write the intent out in your prompt.
For instance, let’s say you would like a web site done in a specific way, much like a previous website you made. And without few-shot prompting, you possibly can try to explain the previous website you would like replicated and have the LLM create that latest website. Nonetheless, this may likely result in numerous ambiguity in your prompt, where the LLM has to make some assumptions. Thus, you’ll likely not achieve the result you might be in search of.
If as a substitute you provide the LLM with the actual codebase, or a minimum of some screenshots of your previous website, and easily ask it to copy the web site, you’ll achieve significantly better results. This essentially removes all ambiguity out of your prompt and helps the LLM achieve much greater results.
I’m arguing for the proven fact that you must use this few-shot prompting technique in the whole lot you do. So long as it’s not the primary time you’re working on a task, all the time discuss with a few of your previous work for the way the LLM should do something. For instance:
- Making marketing material? -> show the LLM your previous work
- Adding a brand new feature to your app? -> show the LLM your previous features
- Creating latest slash commands? -> show the LLM the way you structured your previous slash commands
I almost guarantee you that by referring to your previous work and showing the LLM do something not only within the prompt, but in actual implementation, you’ll achieve much greater results.
Learn how to implement few-shot prompting
Now I need to debate implement few-shot prompting. Few-shot prompting shouldn’t be something you may all the time implement. Some tasks are simply latest, and it’s very hard to make the most of or leverage previous work that you simply’ve done because the brand new work simply isn’t similar enough.
This is totally tremendous and something you must accept. Nonetheless, you must all the time search for opportunities to leverage few-shot prompting. Firstly, I’ll discuss how you must organize your work to extend the surface area for few-shot prompting opportunities, and I’ll then show you do few-shot prompting in practice, using examples.
Also, take a look at my article Learn how to Get the Most out of Claude Code!
Organizing your work
Firstly, it’s essential that you simply organize all of your work in accessible folders in your computer. Personally, I store almost the whole lot I do inside a programming fundamental folder. I then have a folder structure of the code repositories I’m typically working in. One other folder consisting of some personal projects I’m accessing sometimes. One other folder with the marketing material I’m working on, comparable to LinkedIn posts and short-form videos, and one other folder for the entire presentations I’m holding on AI.
Now, at any time when I start a brand new task, my first job is all the time to work out which folder this work belongs to. On the whole, organizing work like that is just general computer organizing hygiene. Nonetheless, being organized like this makes it a lot simpler to make the most of few-shot prompting in the long run. I just all the time recommend spending a while determining where your work belongs at first so which you could make the most of it on a later occasion.
Moreover, you must all the time be committing your work to GitHub. The explanation for that is that it means that you can store all of your progress and provides you with a version history. So if something happens to your computer, otherwise you make changes you need to revert, you may easily revert them using Git.
Moreover, when you don’t have knowledge of using Git, it’s probably not a problem, as you may simply use an LLM to interact with Git for you. You don’t really need to interact with Git in any respect yourself.
Few-shot prompting in motion
Now, assuming you’ve organized your work properly, it’s time to begin benefiting from few-shot prompting. The concept of few-shot prompting is pretty easy. Each time you begin latest work, you just discuss with a folder or file of previous work that you simply want the pc to either replicate or follow the identical styling or similar.
I believe it’s easiest if I show you, if I describe some specific examples of how I exploit few-shot prompting in practice.
Writing code
Probably probably the most common use case for me when few-shot prompting is writing code. Let’s say I need to implement a GitHub Actions validation script in a brand new repository. I essentially never ask Claude Code to provide you with this script from scratch. As a substitute, I simply tell Claude Code, “This script exists in folder X, replicate or duplicate the script exactly within the repository I’m currently working on. Nonetheless, just make this one change where you don’t run the a part of the validation script”.
This has two fundamental advantages. For one, I’m almost certain I’ll get the GitHub Actions validation script I’m expecting, because I understand it’s working in the opposite repository. Moreover that is great because regardless that I’m copying over the script from one other repository, I’m still in a position to make changes. And in this instance, the change was that I don’t need to run the total validation script. I need to skip one a part of it on this latest repository.
Claude Code is great at coping with these sorts of tasks, where you tell it to copy another piece of code after which make a number of customized changes. Which is why this works so well.
Creating marketing material
One other quite common use case I even have for few-shot prompting is creating marketing material. Creating fresh marketing material generally is a time-consuming task. You’ve got to, for instance, create brand latest presentations or carousel views for use on LinkedIn.
Moreover, it is usually hard to explain your exact preferences relating to presentations. You would possibly want a specific sort of font style or a specific sort of alignment of text and pictures in your presentations. This is solely hard to explain in natural language, however it’s very clear to the model when you show it an example of how this text font is or how text and pictures are aligned out of your previous work.
Thus, once I’m making a brand new presentation nowadays, I all the time show Claude Code my previous presentations and tell it the things I need to vary from those previous presentations. The things I need to vary are typically the actual content of the presentation, after all, where I describe each page in my presentation to as much detail as possible. That is, after all, essential to maintain the content yours and never AI-generated.
Moreover, I simply iterate rather a lot with Claude Code. I told it to make me an initial draft of the presentation. I then review the draft, transcribe the entire changes I need modified through MacWhisper while reviewing the presentation, and have the AI make a second draft. I’ll then proceed like this until I’m completely happy with the presentation.
Slash commands
Creating slash commands can also be something I do on a fairly regular basis. Slash commands are essentially stored prompts which you could have with the code that means that you can access prompts rapidly. I typically have slash commands for commands like making a pull request to dev, making a pull request to fundamental, simplifying code, or running a PR review.
Nonetheless, I typically want my slash commands to follow a specific sort of structure. The structure is a markdown structure with a number of points that I generally share across my different slash commands. Thus, showing Claude Code my previous slash commands makes the generation of recent slash commands rather a lot simpler, faster, and more more likely to follow the preferences I even have.
Conclusion
In this text, I’ve discussed leverage few-shot prompting to realize the perfect results along with your LLMs. Lively usage of few-shot prompting by showing the LLM examples of your previous work could make your LLM much more efficient on your use cases. I like to recommend all the time striving to make use of few-shot prompting at any time when you’re employed with LLMs to realize the perfect results. The very best a part of few-shot prompting is that it gets higher the more work you do. The more work you do, the more previous examples you will have to indicate the LLM, and the higher it’s going to perform in response to your preferences, which is what makes it such a terrific technique.
👉 My free eBook and Webinar:
🚀 10x Your Engineering with LLMs (Free 3-Day Email Course)
📚 Get my free Vision Language Models ebook
💻 My webinar on Vision Language Models
👉 Find me on socials:
💌 Substack
Also, take a look at my article Learn how to Get the Most out of Claude Code.
