[Mini-Guide] Giving ChatGPT Examples (Few-Shot Learning)

MAF Publishing

Regular Member
Joined
Jun 26, 2023
Messages
480
Reaction score
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.


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
 
Do you use this in GPTChat or OpenAI playground and GPT3?

This is a type of fune tunning on a low number of examples and mostly works great. I used it only in the raw model GPT-3.
 
Do you use this in GPTChat or OpenAI playground and GPT3?

This is a type of fune tunning on a low number of examples and mostly works great. I used it only in the raw model GPT-3.
I use it in both ChatGPT and the API if I think the prompt needs it. GPT-4 is smart enough to do most things well without, but I still use it a lot especially when I want consistency of voice in longer writing sections.

I think it helps gpt-3.5-turbo a good amount still.
 
Only problem with GPT-3 and 4 is because they become more and more censored. So the accuracy drops.
Agreed. It's a real problem. Using GPT can be like debating a bad Ethics 101 student.

It's also a pain in the ass when I use it to outline fiction I write as a hobby. Because of course I want characters that can talk about violence and sex and drugs. Thank goodness for open source models.

Edit: Are you cleverspinner dev? I trialed your product this week. Very cool.
 
Agreed. It's a real problem. Using GPT can be like debating a bad Ethics 101 student.

It's also a pain in the ass when I use it to outline fiction I write as a hobby. Because of course I want characters that can talk about violence and sex and drugs. Thank goodness for open source models.

I sometimes have to ask him to tell me what I should not say/write. I used mpt-30b chat it is also censored but a little bit less (https://huggingface.co/spaces/mosaicml/mpt-30b-chat), if somebody makes uncensored one that would be awesome. One of top models I saw.


Edit: Are you cleverspinner dev? I trialed your product this week. Very cool.

thanks.
 
Back
Top