Prompt Engineering

Gemini Prompt Engineering: Seven Techniques for Prompts That Work

Gemini follows a prompt best when the prompt has a particular shape. Here is that shape, the seven techniques a good Gemini prompt uses, and what to type into a prompt generator when you want one to write it.

Robert Youssef4 min
Gemini Prompt Engineering: Seven Techniques for Prompts That Work
On this page

Gemini prompt engineering is mostly a matter of shape. Gemini follows a prompt best when the instruction sits at the top, the material sits below it behind a clear separator, the output is described as a schema rather than an example, and the question is repeated at the end when the material is long. This guide covers that shape, the seven techniques a good Gemini prompt uses, and what to type into a prompt generator when you would rather have one write the prompt for you.

What a Gemini prompt looks like

Instruction: [the task, stated as a result, with the audience and the rules].

=== Material ===
[the document, data or draft]
=== End material ===

Output: [a schema or a template: the fields, their types, the order]. [The question again, in one line.]

Gemini follows a system instruction over the user turn strictly, so in a product the instruction goes in the system field and the material in the user turn. In the chat interface, the structure above does the same job. Thinking levels replace the long "think step by step" paragraphs older prompts carried; set the level and keep the prompt short.

What to type into a prompt generator

The generator can only structure what you give it. Three things make the difference between a generated prompt you use and one you delete.

  • The result, not the topic. "A comparison table of three laptops for a student, with price, weight, battery and a one-line verdict each" rather than "help with laptops."
  • The audience and the constraints. Who reads the output, how long it can be, what it must not include.
  • The material, or a note that there is some. If the prompt will work on a document, say so, and the generator reserves the block for it.

Our Gemini prompt generator takes that description (pick Gemini as the target model) and writes the prompt in the structure above, with the brackets for the details only you know. Read it once before you send it; the generator writes the shape, you own the facts.

Seven techniques a generated Gemini prompt should use

1. Zero-shot by default

For a clear task the prompt carries the instruction alone, with no examples. Gemini handles zero-shot well, and examples add tokens and the risk that the model copies their content. A good generator starts here.

2. Few-shot only when the shape is unusual

When the output format is specific to you, one example in its own labelled block, marked as shape only. Two or three when the format has several variants. The generator should ask for the example rather than invent one.

3. Schema for structured output

Gemini fills a JSON schema exactly. For any output that will be parsed, the prompt gives the schema with field names and types instead of describing the structure in prose. This is the single biggest difference between a Gemini prompt and a ChatGPT one.

4. Thinking level instead of reasoning instructions

Where the model exposes a thinking setting, the prompt is kept short and the setting does the work. For hard problems the prompt can still ask for a plan first, but the paragraph of "reason carefully, consider all angles" is gone.

5. Question at the end for long material

With a long document, the question appears after the material as well as before it. Recall on the final question is better than on one buried at the start of a long context.

6. A rule for gaps

"If the material lacks something needed, say what is missing and stop." Gemini will otherwise answer confidently from general knowledge, which is the failure that costs the most.

7. Iteration on real inputs

The generated prompt is a first version. Run it on five varied inputs, score the outputs, change one thing. The prompt optimization guide covers the loop; the generator gives you a version 1 worth testing instead of a blank page.

Gemini-specific things to know

Gemini reads images, PDFs and video in the same prompt as text, so a prompt can say "in the attached PDF" and point at it. The long context means the whole document can go in rather than a summary, and the question-at-the-end rule matters more as the context grows. For Gems, the saved custom versions of Gemini, the generated prompt becomes the Gem's instruction, and the material comes from each conversation. For the API, the same prompt splits into the system instruction and the user content.

For written Gemini prompts by task, the Gemini prompt library has the tested set, and the guide to writing AI prompts for Gemini covers the model's behaviour in more depth than a generator can. A generator is the fastest way to a structured first draft; the library is where the drafts have already been tested.

Prompts for this topic

Put this article to work with ready-to-use prompts from the God of Prompt library.

Keep reading

The best of the blog, in your inbox

One email when notable prompts, tools, and model updates land. No spam, unsubscribe anytime.

Join 100,000+ subscribers. One email a week, real prompts, tools, and model updates. Unsubscribe anytime.