Thursday, July 30, 2020

Tips for designing prompts for use with GPT-3

If what you are looking for is specific and short, give as many examples of what you are looking for as will fit in the prompt and leave you ample room to generate an answer. If you have trouble thinking of examples, just give one example, and start a second one in the same format. Once GPT-3 has completed the second example, evaluate it. If it is reasonable, leave it in and generate another one. Try to make sure you cover the breadth of variety you want in the inputs and outputs of the examples.
Example:
civic space: street, sidewalk, court, courtyard, public park, parkway, square, plaza, wall, bench, fountain, lawn, gardens, playground, alley, boulevard college 
building: library, laboratory, lecture room,  basement, storage room, storage closet, study lab, office, meeting room, conference room, attic 
fort: guard tower, palisade, rampart, bastion, parapet, fortification, fort gate 
village church: chapel, baptistery, sacristy, choir loft, choir stalls, parsonage, pews, altar 
industrial town: factory, ship, mill, factory shed, milling shed, workshop, armory, tool shed, smithy, forge, smelter, mill building 
cathedral: transept, vestry, pulpit, cell, choir, choir loft, choir stalls, loft, nave,  chancel, sacristy, sanctuary, vault, apse, chapel, presbytery, sanctum, crypt, vestibule, turret, belfry, spire  
castle: The great hall, bedchamber, solar, garderobe, kitchen, pantries, larders, gatehouse, guardroom, chapel, boudoir, storeroom, undercroft, cellar, ice house, dovecote, tower, dungeon, yard, well, baths, keep, battlement, armory, archery range, guard tower, bastion, barbican, wall tower 
monastery: oratory, cloister walk, chapter hall, refectory, dormitory, sacristy, library, transepts, dining hall, chapel, kitchen, vineyard, brewery, barn, laundry, garden, well, graveyard
Give detailed instructions for what you are looking for. Adjectives that describe the results (three paragraphs long, serious, clever, etc...) affect what is produced. Shoot for the moon and you might land in the tree-tops-- I mean, ask for the best ever in the world, and it may encourage it to give a higher quality result.
Example:
Here is an award-winning short-short story about friendship and revenge:
Sometimes you can get the system talk its way through to an answer. For some questions, it doesn't do a good job of answering right off the bat. But if you have it "talk through its process" or create an explicit "internal monologue" then the words it produces as part of that monologue will influence the final answer generated.
Example:
Human: If I had three cookies and gave one away, how many would I have? 
AI: two. 
Human: So if I have two cookies and then get another two, how many would I have? 
AI: four.
If what you are producing has some global structure, such as a plot, you can help enforce that structure by having it produce a short summary first, and generate an expansion of that summary, rather than producing the final product all in one go.

Example:
Here is a plot summary of the new movie "Star Frontiers":Sir Michael King is in charge of the British Empire's Solar Guard. They have discovered how to generate power from atomic energy and have built gigantic, interstellar starships which can travel faster than light. However, instead of peaceful colonization missions, King uses these warships to steal gold, precious metals and jewels from other worlds. 
This is the scene that shows Sir Michael King is in charge of the British Empire's Solar Guard:

If the process you want is too complicated, you might send the text through several different prompts in a row. For example, you could
(1) clean up a question so that it is typo-free.
Then you could (2) rewrite it in a more engaging style.
Then you could (3) give it to a prompt whose only goal is to decide whether GPT-3 can answer it, or else say "I don't know."
A paragraph that has passed through all those stages can then be (4) fed to your question-answerer prompt, for a better chance of success.

Sometimes it helps to pretend the thing you are looking for already exists and describe it, rather than ask the engine to invent it. For example, when I wanted scenes from a non-existent novel, I didn't pose it as a question whose answer is a scene. I instead described the overall plot of the novel as if it were a book review, and then said, "Here is an excerpt from the novel, where the antagonist is on the protagonist's trail:"

Try to imagine a web page where the material you are looking for would exist. Is it a news article? A textbook? A work of fiction? Making your prompt resemble a common web page format helps to get it in the right frame of mind.

Instead of just saying "a list" say "a list of ten items" if you want to encourage it to give you a list of a certain length.

You can name a famous author or pair of famous co-authors if you want to encourage it to have a particular style.

Don't be afraid to edit. If what it has produced is good up to a point and then goes off the rails, delete up to that point, type how you want the next sentence to start, and set it loose again. Or alter what it has already written however you want before continuing. If your final goal is just a good text, it doesn't hurt to work with it as a collaborative tool.

If it is plagiarizing, choose a less likely result instead of the most likely. For example, if you ask it to come up with original names for Disney dwarfs, discard the most probable seven results.

Use titles and headers to encourage it to get in the right frame of mind.

(h/t Matt Brockman) sometimes it is better at third-person. In other words, ask it to describe what someone else would do, rather than try to get it to do it itself.

Even if you use multiple examples, remind the model (with an explanation) what it should be attending to shortly before the generation begins. For some reason it seems to pay more attention to things closer to the end of the prompt.

No comments:

Post a Comment