Microsoft Certified: Azure AI Engineer AssociateImplement generative AI solutionsMedium

An e-commerce company uses Azure OpenAI Service to generate product descriptions. They need to ensure that the descriptions consistently include specific keywords relevant to SEO and product categorization, even if the model might not naturally generate them. Which prompt engineering technique is most appropriate for this requirement?

  1. AConstraining the output with a JSON schema.
  2. BZero-shot prompting with clear instructions.
  3. CUsing a 'stop' sequence that triggers after keywords are generated.
  4. DFew-shot prompting with example descriptions including keywords.
Show answer & explanation

Correct answer: D. Few-shot prompting with example descriptions including keywords.

Few-shot prompting, by providing examples of product descriptions that successfully incorporate the required keywords, implicitly teaches the model the desired pattern and increases the likelihood of similar keyword inclusion in new generations.

Why the other options are wrong

  • A. JSON schema constrains structure, not specific content or keyword presence within natural language text.
  • B. Zero-shot prompting might work for general keyword inclusion but is less reliable for consistent, specific keyword integration.
  • C. A 'stop' sequence would prematurely end generation and doesn't guarantee keyword inclusion; it's for stopping once certain text is encountered.

Few-shot Prompting

A prompt engineering technique where a few examples of the desired input-output behavior are provided to the model.

  • Demonstrates desired patterns and formats.
  • Improves model performance on specific tasks without fine-tuning.
  • Effective for guiding tone, style, and content inclusion.

Memory trick: Few Examples Lead to Consistent Keywords: Give a 'few' good examples to hit your 'keywords'.

More Implement generative AI solutions questions