The JSON Whisperer: How to Craft Prompts That Make Google Gemini Sing

Leon Nicholls
8 min readMay 28, 2024

Want to learn a secret language that will make Google Gemini understand precisely what you mean? Well, get ready to unlock the power of JSON! It’s not some complex algorithm or hidden code but a simple yet potent tool that Gemini loves. Think of it as your direct line to Gemini, allowing you to communicate your creative visions.

By the time you finish reading this post, you’ll be fluent in JSON and have an arsenal of advanced prompting techniques. So grab your favorite caffeinated beverage and get comfy—it’s about to get interesting!

Note: This article spotlights techniques for the Google Gemini Advanced chatbot (a paid service). While these concepts also apply to the free version, we’ll focus on the enhanced capabilities offered by the Advanced subscription.

A quick intro to JSON

(If you know JSON, please skip to the next section). Have you ever written a grocery list or filled out a form? That’s a bit like JSON! It’s a way to organize information neatly so that humans and computers can easily understand it. Instead of plain English sentences, JSON uses a unique format with curly braces {}, square brackets [], and colons to create lists and key-value pairs.

Let’s take a look at a simple JSON example:

{
“name”: “Alice”,
“age”: 30,
“city”: “New York”
}

This JSON represents information about a person named Alice. It has three key-value pairs:

  • “name”: “Alice”: The person’s name is Alice.
  • “age”: 30: The person is 30 years old.
  • “city”: “New York”: The person lives in New York City.

As you can see, JSON is relatively easy to read and understand. It’s just a way of organizing data using keys (like labels) and values (the actual information).

Why JSON is Your Secret Weapon

Alright, let’s get down to business! JSON is like that secret decoder ring you always wanted as a kid. It’s your direct line to Gemini, allowing you to communicate with laser precision.

Think of it this way: When you write a prompt in plain English, you’re trying to give directions to a distracted friend who sometimes mishears things. JSON, on the other hand, is like handing them a detailed map with turn-by-turn instructions. There’s no room for misinterpretation here!

What makes JSON so unique?

  • Clarity: With JSON, you’re not just throwing words at Gemini and hoping for the best. You’re giving it a structured blueprint to follow. This means you get more accurate and consistent results.
  • Flexibility: JSON is incredibly versatile. You can customize it to fit any task you can dream up, from writing a sonnet to summarizing a research paper.
  • Efficiency: There is no need to write long, rambling prompts. JSON lets you pack a lot of information into a neat little package.

Imagine you’re asking Gemini to write a product description. A plain text prompt might look like this:

Create a compelling product description for a revolutionary kitchen appliance that simplifies coffee-making. The description should be geared toward individuals who appreciate technology and a good cup of coffee, and the overall tone should be lively and captivating.

That’s alright, but it leaves a lot of room for interpretation. Here’s how you could do better with JSON:

Generate a product description:
{
“product_name”: “CoffeeBot Pro”,
“features”: [“bean grinder”, “brewer”, “self-cleaning”],
“target_audience”: “tech-savvy coffee lovers”,
“tone”: “fun and engaging”
}

See how much cleaner and clearer that is? Gemini will know precisely what you want, and you’ll get a spot-on product description.

So, if you’re serious about getting the most out of Gemini, JSON is your secret weapon. Don’t worry if you’ve never used it before — it’s surprisingly easy to learn and love.

Mastering the JSON Playground

Let’s roll up our sleeves and get into the nitty-gritty of JSON. Don’t worry; it’s not as scary as it might sound. Think of it like learning the controls of a spaceship — once you get the hang of it, you can explore the vast universe of possibilities!

The Anatomy of a JSON Prompt Template

At its core, the JSON prompt is just a bunch of key-value pairs wrapped in curly braces {}. Let’s break down the key components:

  • Instruction: This is where you tell Gemini what to do (e.g., “write a poem,” “summarize this article,” “generate code.”).
  • Parameters: These are the specific details that guide Gemini’s output. Some standard parameters include:
  • Topic: What do you want Gemini to focus on? (e.g., “climate change,” “artificial intelligence”)
  • Format: The type of output you want (e.g., “blog post,” “email,” “code”).
  • Tone: The style or voice you want (e.g., “formal,” “humorous,” “persuasive”).
  • Length (or word count): How long or short you want the output to be (e.g., “short,” “medium,” “long,” “500 words”).
  • Audience: Who you’re writing for (e.g., “tech experts,” “general public”).
  • Keywords: Specific words or phrases to include in the output (e.g., “sustainability,” “renewable energy”).

Example: Article Prompt

Please write an article about:
{
“topic”: “The impact of AI on education”,
“format”: “opinion article”,
“word_count”: 800,
“tone”: “informative”,
“audience”: “general public”,
“keywords”: [“artificial intelligence”, “learning”, “future of education”]
}

With this level of detail and structure, you are setting Gemini up for success!

As you can see, JSON is like a Swiss Army knife for prompt engineering. It’s simple, versatile, and powerful. Once you master it, there’s no limit to what you and Gemini can create together!

Gemini’s Creative Sweet Spot: Project Showcase

Enough chit-chat! Let’s see what this JSON magic can do. Get ready to be amazed as we put these structured prompts to work in some real-world scenarios:

The Futurist Blog

Do you want to share your work predictions in the automation age? Let Gemini help you articulate your vision in a captivating blog post that sparks discussion and debate.

Please write an opinion article that adheres to these specifications:
{
“topic”: “The future of work in the age of automation”,
“format”: “thought-provoking blog post”,
“word_count”: 1200,
“tone”: “visionary and optimistic”,
“audience”: “business leaders and policymakers”,
“keywords”: [“automation”, “future of work”, “job displacement”, “upskilling”, “universal basic income”]
}

The Conversation Starter

Do you need realistic dialogue for a chatbot or training scenario? Gemini can simulate conversations between a therapist and a patient, complete with empathetic responses and insightful questions.

Using the character information below, create a dialogue between Dr. Smith and Alex:
{
“characters”: [
{
“name”: “Dr. Smith”,
“role”: “therapist”,
“traits”: [“empathetic”, “insightful”]
},
{
“name”: “Alex”,
“role”: “patient”,
“traits”: [“anxious”, “introverted”]
}
],
“setting”: “therapy office”,
“goal”: “explore Alex’s anxiety”
}

The Marketing Guru

Are you launching a new smart thermostat? Gemini can help you create a compelling product description that concisely and persuasively highlights its key features and benefits.

Craft a product description incorporating the following details:
{
“product_name”: “Smart Thermostat”,
“features”: [“voice control”, “energy saving”, “learning algorithm”],
“target_audience”: “eco-conscious homeowners”,
“style”: “concise and persuasive”
}

The Coding Whiz (Even If You’re Not)

Are you not a coding ninja? No worries! Gemini can translate your plain English instructions into functional Python code to sort a list of numbers, complete with optimizations for duplicate values and memory usage.

Write code to these specifications:
{
“language”: “Python”,
“task”: “sort a list of numbers”,
“algorithm”: “quicksort”,
“additional_requirements”: [“handle duplicate values”, “optimize for memory usage”]
}

The Data Detective

Do you have a pile of customer survey data? Gemini can perform a sentiment analysis and visualize the results in a handy bar chart, showing how customers feel about each product category.

Analyze the following data and present the results:
{
“dataset”: “customer_survey_results.csv”,
“analysis_type”: “sentiment analysis”,
“visualization”: “bar chart”,
“focus”: “customer satisfaction by product category”
}

The Personal Shopper

Want to recommend books that your audience will love? Gemini can take a reader’s preferences and suggest personalized titles, complete with summaries and explanations.

Recommend books based on the following:
{
“user_preferences”: {
“genre”: [“science fiction”, “fantasy”],
“author”: [“Neil Gaiman”, “Ursula K. Le Guin”],
“format”: [“ebook”]
},
“recommendation_type”: “book”,
“number_of_recommendations”: 3
}

See? JSON is like having a multi-talented assistant who can tackle all sorts of tasks. The best part? You get to be the director, guiding Gemini’s every move with your carefully crafted prompts. So, let your imagination run wild and see what amazing things you can create together!

Troubleshooting and Fine-Tuning

Even with the best-laid JSON plans, sometimes Gemini can throw you a curveball. It could repeat like a broken record, go off on a wild tangent, or not quite hit the mark. But don’t worry — even the most experienced prompt engineers have to deal with these hiccups occasionally.

Here are some common issues and how to troubleshoot them like a pro:

The Broken Record

If Gemini keeps repeating the exact phrases or ideas, try these tips:

  • Add More Variety: Think of this like adding spices to a dish. Instead of repeatedly using the exact words and sentence structures, introduce synonyms, variations in phrasing, and different perspectives to your prompt. This will encourage Gemini to explore various possibilities and avoid getting stuck in a rut.
  • Increase Specificity: Be more precise in your instructions and parameters. Tell Gemini precisely what you want to avoid. For example, if it keeps repeating a specific phrase, explicitly mention that you’d prefer a different wording.

The Wandering Mind

If Gemini starts rambling or going off-topic, here’s what to do:

  • Rein In the Reigns: Add more explicit instructions or constraints to your prompt. Clearly define the scope of the task and specify the desired output format.
  • Break Down the Task: Divide a complex task into smaller steps to keep Gemini focused. Provide clear instructions for each step, guiding Gemini through the process one piece at a time.

The Perfectionist

Even if Gemini’s sound output is sound, it can constantly improve. Here are some ways to fine-tune your prompts:

  • Iterate, Iterate, Iterate: Think of your prompts like a sculptor refining a statue. Start with a rough draft, then gradually refine it through multiple iterations. Change the wording, add or remove details, and experiment with different parameters. Each iteration brings you closer to the perfect prompt that elicits your desired response.
  • Get Feedback from Gemini: Ask Gemini to evaluate its output and suggest improvements. You might be surprised by its insights! This can help you identify areas where your prompt could be more specific or where Gemini might misunderstand your intent.
  • Learn from Others: Check out online communities and forums where prompt engineers share tips and tricks. The collective wisdom of the community always offers something new to learn.

Remember, prompt engineering is an ongoing process of learning and experimentation. The more you practice, the better you understand Gemini’s quirks and guide it to produce the desired results. So, keep going even if your first few attempts could be better. Keep tweaking, keep exploring, and have fun with it!

Conclusion

You’ve officially unlocked the power of JSON and are ready to take your Google Gemini prompts to the next level. With this newfound knowledge, you have the tools to craft laser-focused instructions, spark creative collaborations, and unlock a world of possibilities with Gemini.

Remember, the true beauty of JSON lies in its flexibility and precision. Don’t be afraid to experiment, test new ideas, and push the boundaries of what you can achieve. The more you practice, the more fluent you’ll become in this secret language, and the more impressive your Gemini-powered creations will be.

Check out my reading list of other Google Gemini articles.

This post was created with the help of AI writing tools, carefully reviewed, and polished by the human author.

--

--