How to write relevant prompts?

Résumer avec :

As advancements in artificial intelligence đź’ˇ continue, mastering prompting has become an essential skill. To support this evolution, Google has published a detailed 68-page guide, written by Lee Boonstra, an engineer at Google. After going through this guide over a weekend (with the help of ChatGPT and Gemini), which has become a reference and offers proven methods for designing effective prompts, whether for Gemini models or other LLMs (Large Language Models), I wanted to share with you the 6 most relevant techniques highlighted.

Mastering Settings for Precise and Controlled Responses

To fully leverage the potential of an artificial intelligence model, it is crucial to understand and adjust three fundamental parameters: max tokens, temperature, top-K, and top-P. These variables influence the length, creativity, rigor, and even reliability of the generated responses.

Concrete usage example:

  • For an article summarization task:
    • max_tokens = 300 (to limit the output)
    • temperature = 0.3 (precise responses)
    • top-P = 0.8
    • top-K = 20
      Result: a concise summary that is faithful to the original text.

Key points to remember:

  • Temperature = 0: for deterministic responses (useful for factual tasks like translation or calculations).
  • Temperature > 1: encourages creativity but increases the risk of errors (ideal for fiction or new ideas).
  • top-K restricts the model to a fixed number of options, top-P acts on a cumulative probability threshold. These two levers allow you to balance precision or diversity.

Guiding AI by Example through Few-Shot Prompting

Few-shot prompting involves providing the model with clear examples of what is expected. It is a powerful alternative to fine-tuning, requiring no additional training.

Application example:
You want the model to convert pizza orders into JSON. Here’s how to structure your prompt:

luaCopierModifierEXAMPLE 1:
Order: I want a medium pizza with ham and mushrooms.
Expected response:
{
  "size": "medium",
  "ingredients": ["ham", "mushrooms"]
}

EXAMPLE 2:
Order: A large pizza, half cheese, half grilled vegetables.
Expected response:
{
  "size": "large",
  "ingredients": [["cheese"], ["grilled vegetables"]]
}

From there, you can request a new interpretation. This format allows the AI to generalize from concrete examples.

Best practices:

  • Vary the formulations (oral, written, implicit questions).
  • Correct any errors in the examples (mistakes heavily influence quality).
  • Prioritize clarity over complexity.

Structuring Thought with the Step-Back Prompting Approach

This method relies on two distinct steps:

  1. First, ask the model what strategy it would adopt to solve a problem.
  2. Then, ask it to solve the same problem using the identified strategy.

Why does it work?
By prompting the AI to take a step back, it activates a broader form of deductive reasoning, mobilizing principles rather than automatism.

Example of a mathematical prompt:

  • Step 1: “What method would you use to solve the following problem: ‘If a train travels at 80 km/h for 3 hours, what distance has it covered?’”
  • Step 2: “Now apply this method to solve the problem.”

This process is particularly useful in complex cases: legal analysis, computer code, or logical argumentation.

Gaining Reliability by Repeating and Comparing Responses (Self-consistency)

Self-consistency prompting involves sending the same prompt multiple times, with a high temperature, to obtain different responses. Then, the most frequent response is considered the most reliable.

Example of a practical case: sentiment analysis of a conversation.

  • Prompt: “Is this discussion positive or negative? Respond only with POSITIVE or NEGATIVE.”
  • Send the prompt 5 times with temperature = 1.5.
  • Results: POSITIVE, NEGATIVE, POSITIVE, POSITIVE, POSITIVE.
  • Final response: POSITIVE (majority)

This type of method is useful for:

  • Sensitive classification tasks (customer feedback, moderation).
  • Resolving ambiguous problems.
  • Reducing hallucinations of an LLM by cross-referencing responses.

Automatically Optimizing Your Prompts with Tested Variations (APE)

Automatic Prompt Engineering (APE) allows for the automatic generation of multiple versions of a prompt, which are then tested to find the most effective one.

Concrete steps:

  1. Provide a base prompt (e.g., “Summarize this article in three sentences.”).
  2. The model generates 10 variations of the prompt.
  3. Each version is tested on the same source text.
  4. The outputs are compared to a human reference.
  5. The best versions (according to BLEU, ROUGE, or human evaluation) are retained.

Example of automatically generated variations:

  • “Give me a brief and clear summary.”
  • “Summarize the content by highlighting the key points.”
  • “What is the main idea of this text?”

This allows for identifying the most robust formulations, especially when developing custom assistants or automated content generation tools.

Documenting Your Experiments in a Spreadsheet to Progress Faster

In the field of prompt engineering, testing, observing, and iterating are the keys to improvement. For this, one of the simplest and most effective tools remains… the good old spreadsheet. Creating a dedicated dashboard for your prompts not only allows you to keep track of your trials but also to analyze their effectiveness with perspective.

Here’s how to structure your spreadsheet to turn it into a true laboratory:

Test NameObjectiveTemperatureTop-KTop-PMax TokensPromptGenerated ResultEvaluation
  • Test Name: Give an evocative title to each attempt (e.g., “Article Summary – Neutral Tone”).
  • Objective: Summarize, generate code, classify, translate, etc.
  • Parameters: Precisely note the generation settings (temperature, top-K, top-P, etc.).
  • Prompt Used: Copy exactly the text sent.
  • Generated Output: Paste the model’s result for comparison.
  • Evaluation: Add a subjective comment or a rating: “OK”, “approximate”, “needs work”, etc.

Over time, you will build a custom database of what works best for your use cases. This accelerates learning, helps you detect biases or repetitions, and most importantly… prevents you from making the same mistakes.

Conclusion

Prompt engineering is not an obscure science reserved for researchers. It is a dialogue: between you, your needs, and a model that tries to understand you. Through techniques like few-shot prompting, two-step reasoning, repetition, or automatic evaluation, you gradually refine your way of “speaking” to AI. And even if some settings or approaches may seem technical, remember: every test is an opportunity to learn. By cultivating a curious, rigorous, yet creative mindset, you transform a simple prompt into a true lever of innovation 🚀.

Résumer avec :

We will be happy to hear your thoughts

      Leave a reply

      mygrowthbox.com
      Logo
      Compare items
      • Total (0)
      Compare
      0
      Shopping cart