Microsoft Certified: Azure AI Engineer AssociateImplement generative AI solutionsMedium

A research institution is using Azure OpenAI Service to analyze historical documents. They need to extract specific entities (e.g., names, dates, locations) from the text and present them in a structured format for database ingestion. Which prompt engineering approach would best ensure the model outputs the extracted information in a consistent, machine-readable format?

  1. AIncluding a few-shot example demonstrating the desired JSON output structure.
  2. BSetting the 'temperature' parameter to a very high value to encourage creativity.
  3. CInstructing the model to 'extract entities' without further examples.
  4. DUsing a 'stop' sequence that includes common entity names.
Show answer & explanation

Correct answer: A. Including a few-shot example demonstrating the desired JSON output structure.

Few-shot prompting with examples demonstrating the desired JSON output structure is highly effective. It explicitly shows the model the required format, guiding it to produce consistent, machine-readable output for entity extraction.

Why the other options are wrong

  • B. High temperature increases randomness and makes it less likely to adhere to a strict structured format.
  • C. Zero-shot instructions might work, but won't guarantee a specific, consistent structured format like JSON.
  • D. Stop sequences are for ending generation, not for enforcing output structure or content.

Structured Output Prompting

A prompt engineering technique that guides a large language model to generate output in a specific, machine-readable format, such as JSON or XML.

  • Often uses few-shot examples to demonstrate the desired structure.
  • Crucial for integrating LLMs with downstream systems and databases.
  • Ensures consistency and parseability of generated data.

Memory trick: Few JSON Examples Structure Success: Give a 'few' JSON examples for 'structured' results.

More Implement generative AI solutions questions