Databricks Generative AI Engineer Associate Question 11
Single answerYou are designing a prompt for a generative AI model to generate a JSON response that includes a user's name, age, and hobbies. The response must strictly follow the format:
{ "name": "<name_value>", "age": <age_value>, "hobbies": ["<hobby_1>", "<hobby_2>"] }
Which of the following prompts is most appropriate to elicit the desired response format?
- A
Generate a JSON object including a user's name, age, and hobbies.
- B
Provide the user's details in the form of a JSON object with the fields: name (string), age (integer), and hobbies (array of strings). Ensure the JSON is properly formatted.
- C
Write a brief description of a person including their name, age, and hobbies in any format.
- D
Create a JSON schema for a user's name, age, and hobbies.
Show answer and explanation
Correct answer: B
Explanation
To elicit a specifically formatted response from a generative AI model, the prompt must include clear instructions about the required structure and format of the output. Option 2 provides precise guidance for generating a JSON object with the specified fields and types, ensuring the desired output format is met.
- A. Incorrect.
This option is too vague and does not specify the required structure or format of the JSON output.
- B. Correct.
This option is correct because it explicitly states the required JSON structure (field types and format) and ensures the response adheres to proper JSON formatting.
- C. Incorrect.
This option does not specify the need for JSON formatting and allows for any output format, which is not suitable for the desired structured response.
- D. Incorrect.
This option asks for a JSON schema rather than a JSON object with actual values, which is not aligned with the task.