MAF Publishing
Regular Member
- Jun 26, 2023
- 480
- 353
This is a brief guide to a fundamental prompting technique, few-shot prompting or few-shot learning. All of this knowledge is free, widely available and pretty commonly known, but I do see people asking questions that this will answer.
Few-shot is a fancy term for training a model with your prompt by giving it examples. Most people figure this out naturally, and I've seen it given as advice here in lots of ways: "be sure to give it details" "paste in your product info" etc. This technique alone can get you a decent way toward "human-like" output, or it can be used to give you more consistent output of any kind. All you are doing is teaching ChatGPT what a good answer looks like.
So: you want a quick blog article, but it needs to blend in to your site. Give ChatGPT samples of existing articles you've written, at least 100 words, or if you're not caring about tokens, you can give it whole articles if they fit in the context limits. Include the prompt you would normally use and at least one, preferably two, examples.
That whole thing is your prompt. You'll get an article about Z. From then on in the conversation, simply give the command and the topic, and if there is a clear format and voice to your examples, it will attempt to emulate it. The more examples you give, and the more consistent the writing style and format of the samples you use, the better your results will be.
This is useful for getting formatted outputs too. e.g.:
(use real product examples)
That's all your prompt. You get the idea. Like I said, you're probably already doing this in some form. Now do it more consciously and intentionally, and craft good examples for GPT, and you will get better output. The prompts can be anything, the key is consistency and good examples -- preferably at least two, to help it establish a pattern. That is the absolute lowest hanging fruit of the tree of prompting.
Cheers,
DD
Few-shot is a fancy term for training a model with your prompt by giving it examples. Most people figure this out naturally, and I've seen it given as advice here in lots of ways: "be sure to give it details" "paste in your product info" etc. This technique alone can get you a decent way toward "human-like" output, or it can be used to give you more consistent output of any kind. All you are doing is teaching ChatGPT what a good answer looks like.
So: you want a quick blog article, but it needs to blend in to your site. Give ChatGPT samples of existing articles you've written, at least 100 words, or if you're not caring about tokens, you can give it whole articles if they fit in the context limits. Include the prompt you would normally use and at least one, preferably two, examples.
Code:
User: Write me a 700 word how-to guide on X
Assistant: <Your pre-existing writing sample or article1>
User: Write me a 700 word how-to guide on Y
Assistant: <Your pre-existing writing sample or article2>
Write me a 700 word how-to guide on Z
That whole thing is your prompt. You'll get an article about Z. From then on in the conversation, simply give the command and the topic, and if there is a clear format and voice to your examples, it will attempt to emulate it. The more examples you give, and the more consistent the writing style and format of the samples you use, the better your results will be.
This is useful for getting formatted outputs too. e.g.:
(use real product examples)
Code:
Product Format Example #1
Item: X
Desc: X
Sizes: X, X, X
Price: $X
Product Format Example #2
Item: X
Desc: X
Sizes: X, X, X
Price: $X
Put these products into the format used in the examples above:
<bunch of messy unstructured product info you copied off some website>
That's all your prompt. You get the idea. Like I said, you're probably already doing this in some form. Now do it more consciously and intentionally, and craft good examples for GPT, and you will get better output. The prompts can be anything, the key is consistency and good examples -- preferably at least two, to help it establish a pattern. That is the absolute lowest hanging fruit of the tree of prompting.
Cheers,
DD