Databricks Generative AI Engineer Associate Question 9
Single answerYou are designing a prompt for a generative AI model to provide a JSON response containing a user's name, age, and a list of their favorite hobbies. Which of the following prompts is most likely to elicit a correctly formatted JSON response?
- A
Generate a response about the user's details, including their name, age, and hobbies.
- B
Provide a structured JSON object with the following keys: 'name' (string), 'age' (integer), and 'hobbies' (list of strings). Ensure the response is valid JSON.
- C
Tell me about the user's name, age, and hobbies in a complete sentence.
- D
Write a list of key details about the user, including their name, age, and hobbies, separated by commas.
Show answer and explanation
Correct answer: B
Explanation
To ensure a generative AI model produces a specifically formatted response, the prompt should clearly define the desired structure, including the format (e.g., JSON), required keys, and data types. Option 2 accomplishes this effectively by explicitly describing the structure and format, making it the correct choice.
- A. Incorrect.
This prompt is too generic and does not specify the desired output format, making it unlikely to elicit a well-formatted JSON response.
- B. Correct.
This prompt explicitly requests a structured JSON object with specific keys and data types, ensuring the model understands the required format and generates a valid JSON response.
- C. Incorrect.
This prompt asks for a response in sentence format rather than JSON, so it is unlikely to result in the desired output structure.
- D. Incorrect.
This prompt does not specify JSON as the required format, so the response is likely to be a plain text list rather than a valid JSON object.