Design Applications · Topic 1 of 2
Prompts, Model Tasks and Chain Components
Databricks GenAI Engineer: turn a use case into inputs and outputs, write prompts that return a fixed format, pick the model task and the chain parts.
- 5 min
- Start every design from the input, the output and the consumer of the output.
- Fixed format comes from explicit instructions, allowed values, delimiters and few shot examples.
- Structured outputs with a JSON schema is the strongest way to force a format.
What it is
Designing a generative AI application starts with a plain statement of what goes in and what must come out. Once the input and output are clear, you can pick the model task that connects them and the chain components that feed the model and shape its answer.
The prompt is the contract with the model. A well designed prompt states the role, the task, the allowed output format and an example, so the response can be parsed by code instead of read by a person.
How it works
From business goal to inputs and outputs
A business goal such as "reduce time spent triaging support tickets" is not yet a design. Rewrite it as a description of the pipeline.
| Question to answer | Example answer |
|---|---|
| What is the input? | The ticket subject and body as text |
| What extra context is needed? | The product list and routing rules |
| What is the output? | One of five queue names plus a priority |
| What constraints apply? | Under two seconds, runs on every ticket, low cost per call |
| How is success measured? | Share of tickets routed to the right queue |
The consumer decides the format. A person can read free text, but a downstream system needs a fixed label or JSON with known keys.
Prompts that return a fixed format
To get the same structure every time, a prompt combines several techniques:
- Clear instruction: state the task and the exact output, such as "Return only JSON with the keys product, issue and priority".
- Allowed values: list the labels the model may use, so it cannot invent a new category.
- Delimiters: wrap the input in clear markers so the model separates instructions from data.
- Few shot examples: show one or two input and output pairs in the exact target format.
- System prompt: put the role and format rules in the system message so they apply to every turn.
Where the serving endpoint supports structured outputs, you can also pass a JSON schema with the request, and the model is constrained to return output that matches it. This is stronger than prompt wording alone.
Choosing the model task
| Requirement | Model task |
|---|---|
| Put each review into one of fixed categories | Classification |
| Pull invoice number, date and total from text | Information extraction |
| Shorten a long report for executives | Summarization |
| Answer questions from company documents | Retrieval augmented generation (question answering) |
| Find similar documents or power a retriever | Embedding |
| Judge positive or negative tone | Sentiment analysis |
On Databricks, several of these are available as AI Functions in SQL, such as ai_classify, ai_extract, ai_summarize and ai_translate. For a custom prompt against any serving endpoint, use ai_query.
SELECT ticket_id,
ai_classify(body, ARRAY('billing', 'login', 'shipping')) AS queue
FROM main.support.tickets;
These suit batch work over a table; an interactive chatbot needs a chain or agent.
Choosing chain components
A chain is a fixed sequence of steps around a model call. Add each component only when the input or output needs it.
| Component | Needed when |
|---|---|
| Prompt template | Always; it inserts the input into fixed instructions |
| Retriever | The answer depends on private or recent documents |
| Chat history (memory) | Follow up questions refer to earlier turns |
| LLM | Always; the chat or completion model |
| Output parser | The result must be a string, JSON or a typed object |
In LangChain style code, the pieces are joined with the pipe operator.
from databricks_langchain import ChatDatabricks
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
prompt = ChatPromptTemplate.from_template("Summarize in three bullets: {text}")
llm = ChatDatabricks(endpoint="my_chat_endpoint")
chain = prompt | llm | StrOutputParser()
How the exam asks about this
- "The output feeds an order system and must always contain the same three fields." Ask for JSON with named keys, give an example, and use structured outputs if the endpoint supports it.
- "Route each email to one of four teams." This is classification with a fixed label list, not summarization or generation.
- "The chatbot must answer from the latest internal policy documents." Add a retriever to the chain; the model alone does not know private documents.
What to remember for the exam
- Start every design from the input, the output and the consumer of the output.
- Fixed format comes from explicit instructions, allowed values, delimiters and few shot examples.
- Structured outputs with a JSON schema is the strongest way to force a format.
- Classification picks from fixed labels; extraction pulls fields; summarization shortens.
- A retriever is needed only when the answer depends on documents the model has not seen.
- Chat history is needed only when later turns depend on earlier ones.
Do not choose a bigger or fine tuned model to fix a formatting problem. A clearer prompt, examples and structured outputs fix format at far lower cost.
Common mistakes
Designing from the model instead of the goal. Write the input and output first, then choose components.
Asking for "JSON" without showing it. The model may add prose or change key names. Show the exact keys and an example, and tell it to return nothing else.
Using generation for a labeling task. Open-ended generation can return labels outside the allowed set. Classification with a fixed list gives consistent, countable results.
Check yourself
Which technique most reliably forces a response to match a JSON schema?
Passing the schema as a structured outputs request where the endpoint supports it; prompt instructions and examples help but do not guarantee the format.
A team wants a short summary of each call transcript stored in a table every night. Which approach fits?
A summarization task run in batch, for example with ai_summarize or ai_query in SQL over the transcripts table.
When does a chain need chat history?
When users ask follow up questions that refer to earlier turns, so the model must see the previous messages.
Topic 1 of 2 in Design Applications
Test yourself on Design Applications
The full Databricks Generative AI Engineer Associate question bank has 600 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Databricks. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.