How to design your GPT-3 prompt in advanced level

Fredric Cliver
2 min readFeb 7, 2023

Your GPT-3 response is always just text, right?

When you use GPT-3 for grammar correction. Your prompt would be like this.

let PROMPT = "Make it correct in grammar. If it doesn't have grammatical issues, do not give a correction. and Do not give the reason for this change.\n\n"

Following a basic instructional prompt like the above, you append the sentence you want to get grammar correction.

But, how you can decide whether you have to provide the result or not? Will you compare the result text?

Even further, you want to classify the grammar error type in vary. Will you call the GPT several times? to get the classification and grammar correction results.

No the thing you have to do is just generate JSON, not simple text, with a few shot examples.

let PROMPT =
"Make it correct in grammar. If it doesn't have grammatical issues, do not give a correction. and Do not give the reason for this change.\n\n"

// Appending few shot as json type.

PROMPT += `
input: example is here. \n
return: {"original":"example is here", "flag":false, "correction":""} \n\n
input: My name are John \n
return: {"original":"My name are John", "flag":true, "correction":"My name is John"} \n\n
`

the Result is like this.

Examples of JSON result

You don't need separate calls to get the classification and grammar correction results. With the one-shot, you got all types of info in JSON format.

You can make decisions when you have to display the grammar correction result.

--

--

Fredric Cliver

Majored in Physics, self-taught and worked in the IT industry as a Dev/Design/Planning for 11 years. And I had run my Startup for 3 years. I fancy a ☔️ 🇬🇧