Skip to content

Generative AI Engineer Associate · Domain 1: Design Applications · 14% of the exam

Task 1.1: Design a prompt that elicits a specifically formatted response; Select model tasks to accomplish a given business requirement

Structured outputs with response_format and JSON schemas, few-shot and delimiter patterns, and matching a requirement to a task: chat, embeddings, classification, extraction or summarization.

Study it

  • Prompts that return a fixed format: structured outputs, JSON schemas and examples

    Partly covered by: Fine-Tuning vs Prompting

  • Matching a business requirement to a model task

    Lesson coming

Sample questions

Try each one before opening the answer. Every option is explained, with the Databricks documentation page that proves it.

Question 1 · choose 1

A claims team calls a Databricks-hosted chat model through Foundation Model APIs and loads each reply into a Delta table with fixed columns: claim_id, severity and a list of damaged parts. Some replies wrap the JSON in prose or rename keys. The fields are known in advance. What should the engineer change in the chat request?

  1. ASet response_format to the json_object type and list every field name and type in the system prompt
  2. BSet response_format to the json_schema type with the field definitions and strict set to true
  3. CKeep plain text output and add one complete JSON example to the prompt as a few-shot pattern
  4. DLower max_tokens until the reply has no room left for any prose around the JSON object
Show the answer and why
  • ASet response_format to the json_object type and list every field name and type in the system prompt

    Incorrect

    json_object returns valid JSON but does not bind the reply to a schema; Databricks shows it for cases where the schema is not known beforehand.

  • BSet response_format to the json_schema type with the field definitions and strict set to true

    Correct

    A json_schema response format makes the model generate JSON that follows the supplied schema, which is the documented way to get fixed fields from a chat model.

  • CKeep plain text output and add one complete JSON example to the prompt as a few-shot pattern

    Incorrect

    An example steers the format but enforces nothing, so wrapped prose and renamed keys can still appear.

  • DLower max_tokens until the reply has no room left for any prose around the JSON object

    Incorrect

    A token cap truncates output; it can cut the JSON itself and does nothing to keep the key names stable.

Structured outputs on Databricks use a response_format field that works across supported chat models. json_schema enforces a defined structure, json_object only guarantees well-formed JSON, and text is unconstrained.

Question 2 · choose 1

An extraction JSON schema for structured outputs has 90 keys nested six levels deep, uses anyOf for a field that can be a string or an object, and uses a pattern to check policy numbers. Requests fail or return poor JSON. Which redesign fits what Foundation Model APIs support for structured outputs?

  1. AKeep the nested structure and replace each pattern with maxLength and minLength limits on the policy number field
  2. BKeep all 90 keys and move the repeated nested objects into shared $ref definitions
  3. CSend the same prompt twice with the json_object type and merge the two halves of the keys
  4. DFlatten to 64 keys or fewer, one type per field, and check policy numbers after the response
Show the answer and why
  • AKeep the nested structure and replace each pattern with maxLength and minLength limits on the policy number field

    Incorrect

    Foundation Model APIs do not enforce length or size keywords such as maxLength, so the check would silently not happen.

  • BKeep all 90 keys and move the repeated nested objects into shared $ref definitions

    Incorrect

    $ref is one of the schema composition keywords that structured outputs do not support, and the key count still exceeds the limit.

  • CSend the same prompt twice with the json_object type and merge the two halves of the keys

    Incorrect

    json_object enforces no schema at all, so neither half is guaranteed to carry the expected fields.

  • DFlatten to 64 keys or fewer, one type per field, and check policy numbers after the response

    Correct

    The schema subset excludes pattern and anyOf, allows at most 64 keys, and flatter schemas generate better JSON, so format checks move to post-processing.

Foundation Model APIs support a subset of JSON schema: no pattern, no anyOf, oneOf, allOf, prefixItems or $ref, at most 64 keys, and no enforcement of length or size keywords. Heavily nested schemas lower quality, so flatten and validate formats downstream.

Question 3 · choose 1

An operations team must assign each of two million support tickets in a Unity Catalog table to one of seven fixed categories every night, from SQL, with as little prompt engineering as possible. Following Databricks guidance on AI Functions, which function should the engineer start with?

  1. Aai_query with a hand-written prompt that lists the categories and asks for one
  2. Bai_classify, passing the seven labels with a short description of each
  3. Cai_extract with a schema that has a single free-text field named category
  4. Dai_parse_document on the ticket text, then a CASE expression over its output
Show the answer and why
  • Aai_query with a hand-written prompt that lists the categories and asks for one

    Incorrect

    ai_query is the general-purpose function for when a task-specific one does not meet the need; here it adds prompt work the team wants to avoid.

  • Bai_classify, passing the seven labels with a short description of each

    Correct

    ai_classify assigns text to labels you provide, and descriptions improve accuracy; Databricks recommends a task-specific function when one matches the objective.

  • Cai_extract with a schema that has a single free-text field named category

    Incorrect

    ai_extract pulls schema fields out of text; a free-text field does not restrict the answer to the seven labels.

  • Dai_parse_document on the ticket text, then a CASE expression over its output

    Incorrect

    ai_parse_document parses binary documents such as PDFs into layout elements; it does not label text.

Databricks recommends starting with a task-specific AI Function such as ai_classify, ai_extract or ai_parse_document when one fits, and moving to ai_query only for more control over the model, prompt or output.

Question 4 · choose 1

An analyst extracts title, authors and keywords from paper abstracts in a SQL query that calls ai_query on a chat model. Downstream code needs typed fields. Which ai_query argument enforces the structure?

  1. AreturnType with the name of a Delta table
  2. BmodelParameters with temperature set to 0
  3. CThe name of an embedding endpoint
  4. DresponseFormat with a DDL-style STRUCT string
Show the answer and why
  • AreturnType with the name of a Delta table

    Incorrect

    returnType describes the expected type, mainly for custom model endpoints; it does not take a table name.

  • BmodelParameters with temperature set to 0

    Incorrect

    Model parameters change sampling, not the shape of the output.

  • CThe name of an embedding endpoint

    Incorrect

    Embedding endpoints return vectors, not structured text fields.

  • DresponseFormat with a DDL-style STRUCT string

    Correct

    ai_query accepts responseFormat as a DDL-style STRUCT string or a JSON schema for chat foundation models.

The responseFormat parameter of ai_query enforces an output schema for chat foundation models, either as a DDL-style STRUCT string or as a JSON string of type text, json_object or json_schema.

Question 5 · choose 1

After a team adds response_format to its chat requests on Foundation Model APIs, token counts per request rise slightly. Why?

  1. AStructured outputs always switch to a larger model
  2. BTechniques used to enforce the format add tokens
  3. CJSON keys are billed at a higher rate than text
  4. Dresponse_format turns on streaming by default
Show the answer and why
  • AStructured outputs always switch to a larger model

    Incorrect

    The same model serves the request; the format is enforced in how the request is handled.

  • BTechniques used to enforce the format add tokens

    Correct

    Prompt injection and other techniques that improve structured output quality change the input and output tokens consumed, which affects billing.

  • CJSON keys are billed at a higher rate than text

    Incorrect

    Billing is per token; JSON tokens are not priced differently.

  • Dresponse_format turns on streaming by default

    Incorrect

    Streaming does not change token counts, and structured outputs do not enable it.

Databricks notes that enforcing structured outputs uses prompt injection and other techniques that affect the number of tokens consumed, and therefore cost.

Question 6 · choose 1

A team writes a new ai_classify job that uses label descriptions and instructions. Which interface version does Databricks recommend?

  1. AVersion 1.0
  2. BAny version; they are identical
  3. CVersion 2.1
  4. DNo version; ai_classify is retired
Show the answer and why
  • AVersion 1.0

    Incorrect

    Version 1.0 is a legacy interface that lacks these capabilities and is not recommended for new work.

  • BAny version; they are identical

    Incorrect

    The versions differ in capabilities.

  • CVersion 2.1

    Correct

    Databricks recommends version 2.1 for ai_classify; it supports label descriptions and instructions.

  • DNo version; ai_classify is retired

    Incorrect

    ai_classify is a current task-specific AI Function.

ai_classify classifies text with labels you provide; adding label descriptions and instructions improves accuracy in the recommended version.

Question 7 · choose 1

A team wants ai_query to describe product photos stored in a volume, reading them with read_files in binaryFile format. Which image formats does ai_query accept for this multimodal input?

  1. AJPEG and PNG
  2. BAny format that read_files can open
  3. CTIFF and PDF pages
  4. DOnly base64 text in a STRING column
Show the answer and why
  • AJPEG and PNG

    Correct

    ai_query supports multimodal image inputs in JPEG and PNG, passed with files => content.

  • BAny format that read_files can open

    Incorrect

    read_files can load many file types, but ai_query accepts only the listed image formats.

  • CTIFF and PDF pages

    Incorrect

    Those are document parsing inputs for ai_parse_document, not image inputs for ai_query.

  • DOnly base64 text in a STRING column

    Incorrect

    The files parameter takes the binary content column from read_files.

For multimodal requests, ai_query takes a files => content argument, where content is the binary column from read_files. Only image inputs in JPEG or PNG are supported.

Practice domain 1 →Practice all domains →