Databricks GenAI Engineer: Choosing LLMs and Embedding Models
Choosing LLMs and embedding models is the part of building a generative AI application where you match models to the application's requirements: an LLM that meets every hard requirement (capabilities, context window, hosting, licence) at the lowest cost and latency, an embedding model whose input length and languages fit your documents and queries, a shortlist screened from model cards in system.ai, Databricks Marketplace or a model hub, and a final pick based on the right experiment metrics. This lesson covers each decision and the trade-offs behind it.
On this page10 sections
- How to choose an LLM from the application's attributes
- Model size, cost and latency
- Sizing the LLM's context window
- Capabilities: tool calling, structured outputs and languages
- Reasoning models versus standard instruct models
- Open weights, hosting and base versus Instruct variants
- Choosing an embedding model's context length
- Embedding consistency, re-embedding and language fit
- Finding models and reading model cards and licences
- Choosing a model from experiment metrics
- Select an LLM by filtering on hard requirements (capabilities, context window, hosting, licence) and then choosing the smallest, fastest model that clears the quality bar
- Size an LLM's context window for the full prompt plus the reply, and diagnose truncated replies caused by an overflowing window
- Decide between reasoning and standard instruct models, base and Instruct variants, and open-weights versus external model endpoints
- Select an embedding model's context length from the source documents, the expected queries and the retrieval strategy, and keep query and document embeddings consistent
- Shortlist models from system.ai, Databricks Marketplace or a model hub using model-card metadata and licences
- Choose a model from MLflow experiment runs using the right task metric, thresholds first and a fair comparison
How to choose an LLM from the application's attributes
To choose an LLM, turn the application's attributes into requirements, drop every model that fails a hard requirement, then pick the cheapest and fastest model that still clears the quality bar. The best-sounding model on a leaderboard is often the wrong answer because it breaks exactly one stated constraint: it is too slow, too expensive, missing a capability, or hosted somewhere the data may not go.
Work through the attributes in this order:
- Hard requirements (pass/fail): languages, tool calling, structured output, context window, where prompts may be processed, licence, whether you must fine-tune the weights, and release status (some teams allow only generally available features in production).
- Quality bar: the minimum accuracy or task metric the application needs, measured on your own evaluation data.
- Objective: among the models that pass 1 and 2, minimise what the business cares about, usually cost per request or latency.
| Application attribute | What it rules in or out |
|---|---|
| High volume, simple task (labels, short extraction) | Favours a small instruct model; a large or reasoning model adds cost with no measured gain |
| Interactive, latency-sensitive (a user is waiting on screen) | Rules out long thinking phases; favours small or mid-sized standard models that start streaming quickly |
| Multi-step reasoning, latency-tolerant (results consumed later) | A reasoning model can be worth its extra tokens when it measurably raises accuracy |
| Long inputs that cannot be chunked | Needs a context window that holds the whole input plus the reply |
| Agent that calls APIs; output written to a typed table | Needs function calling; needs structured outputs |
| Data must stay in the workspace; future fine-tuning | Needs open weights served on Databricks Model Serving |
Model size, cost and latency
Use the smallest model that meets the measured quality bar. Per-request cost and latency grow with model size, so when candidates score within noise of each other on your task, the smaller instruct model wins. For most workloads the model's per-token price is the dominant cost, which is why the choice of model usually moves the bill far more than adjustments to prompt wording or output limits.
Base the decision on evidence: compare the candidates on a representative evaluation set drawn from real traffic, not on a few hand-picked prompts or a vendor demo.
One-off costs versus per-request costs
Every option for closing a quality gap has a cost profile. One-off costs are paid once: fine-tuning a model, building an evaluation set, curating training data. Per-request costs are paid on every call: the model's token price and the number of input and output tokens each request carries. At high volume, per-request costs dominate the total, so the economical path is usually the one that spends once to let a small model meet the bar rather than one that adds cost to every request for the life of the application.
Fine-tuning fits that pattern when the task is narrow and repetitive and you have plenty of labelled examples: the model learns the task's format and vocabulary instead of being reminded of them in every prompt. For broad, open-ended tasks with little labelled data, fine-tuning has less to learn from, and a stronger general model may be the better buy.
Sizing the LLM's context window
The context window must hold everything in the request plus the longest reply you allow: system prompt, instructions, retrieved chunks, the user's question (and any conversation history you resend), and the maximum output tokens. Input and output share one window, so counting only the input undersizes it.
Work it out as a sum. A summarisation request that carries a 40,000-token call transcript, 1,500 tokens of instructions and up to 3,000 output tokens needs at least 44,500 tokens of window. A model with a 32K window fails even before the reply is counted; a model with a 64K window fits with room to spare.
Then buy no more window than you need. Among candidates that fit, extra window adds no value on its own, and longer-context or larger models usually cost more, so the requirement is a threshold, not a score to maximise.
Recheck the sum whenever the request grows: more retrieved chunks, longer history or a longer system prompt all consume window. When input plus max_tokens exceeds it, requests fail or replies are cut short. Resolve that by asking which quantities are fixed requirements (the amount of context, the reply length) and which can give; if none can give, the model's window has to grow.
Capabilities: tool calling, structured outputs and languages
Capabilities are pass/fail filters: a model that lacks one the application needs is out, however well it scores elsewhere. Check them on the model card or the serving documentation before any quality comparison.
- Function (tool) calling: required when an agent must invoke APIs to read or change data. Without it the agent can only talk, not act.
- Structured outputs: on Databricks Foundation Model APIs you pass a JSON schema through the
response_formatparameter, and decoding is constrained so every reply conforms to that schema. Instructions and examples in the prompt only encourage a format; nothing enforces it. Use structured outputs when code or a typed table consumes the reply directly. - Languages: the model must be trained for every language your users write in. Quality in an unsupported language is poor regardless of speed or size.
- Modality: image or audio input is a requirement only when the application actually has such inputs.
Reasoning models versus standard instruct models
Choose a reasoning model only when the task needs multi-step reasoning, a test shows it raises accuracy, and the application can absorb its extra latency and tokens. Reasoning models spend a thinking phase, billed as tokens, before the visible answer. That improves results on problems with dependent steps (calculations that build on each other, multi-hop analysis) but delays the first visible word and raises the token bill.
| Standard instruct model | Reasoning model | |
|---|---|---|
| Best for | Classification, extraction, rewriting, FAQ answers, chat | Multi-step problems where accuracy is measurably higher |
| Time to first visible word | Short; streams quickly | Delayed by the thinking phase |
| Tokens billed | Input + output tokens | Input + output + thinking tokens |
| Good fit | Interactive, high-volume or simple tasks | Latency-tolerant work with dependent steps and budget headroom |
The thinking phase is part of what the model does, so its latency and token cost come with the choice of model or mode rather than with serving settings. Treat a reasoning model like any other candidate: it has to earn its extra cost with a measured accuracy gain on your own evaluation set.
Open weights, hosting and base versus Instruct variants
Where a model runs and whether you control its weights are requirements in their own right. Data residency is decided by where inference runs: if prompts and responses may be processed only inside your Databricks workspace, or you will fine-tune the model later, choose an open-weights model served on Databricks Model Serving. If a proprietary model is allowed and wins your evaluation, serve it through an external model endpoint.
| Option | Where prompts are processed | Can you fine-tune the weights? | Billing and governance |
|---|---|---|---|
Open-weights model (for example from system.ai) on a provisioned throughput endpoint | Databricks Model Serving | Yes; the tuned model is registered in Unity Catalog and served the same way | Reserved capacity; suits steady, predictable or sensitive workloads and is how fine-tuned models are served |
| Foundation Model APIs pay-per-token endpoint | Databricks-hosted shared endpoint | No | Billed per token; suits variable or modest traffic |
| External model endpoint (proprietary provider) | Forwarded to the provider | No; the provider keeps the weights | Provider API key stored in Databricks secrets; usage, permissions and rate limits managed centrally through the endpoint and AI Gateway |
Base versus Instruct
Open model families usually ship a base version (trained only to continue text) and an Instruct (chat) version tuned to follow instructions and hold a conversation. Databricks recommends Instruct versions for deployment and base versions for fine-tuning. Deploy Instruct for an assistant that must follow instructions out of the box. Start from base for continued pretraining on unlabelled domain text or for your own instruction tuning; training an Instruct model on raw text would also erode the tuning it already has.
A base model has no concept of roles or instructions: it treats the whole prompt as a document and predicts what text would come next. Served as an assistant, it therefore tends to keep writing in the style of its input rather than answer it, which is how a mistakenly deployed base version usually shows itself.
Choosing an embedding model's context length
An embedding model's maximum input length must cover the longest unit you embed: the largest chunk or document, and the longest query users send. Each chunk is embedded in one call, and queries are embedded by the same model, so both sides count. Text beyond the window cannot be represented in the vector.
The generally available Foundation Model APIs embedding endpoints differ mainly in input length:
| Endpoint | Max input | Vector size | Notes |
|---|---|---|---|
databricks-gte-large-en | 8,192 tokens | 1,024 | English; long chunks and whole short documents |
databricks-bge-large-en | 512 tokens | 1,024 | English; paragraph-sized passages |
databricks-qwen3-embedding-0-6b | about 32K tokens | see the model card | Multilingual; in Public Preview at the time of writing, so excluded where policy allows only GA features |
Match the embedded unit to the expected queries
A vector represents the overall meaning of the text it was computed from. The longer and more varied that text, the less any single detail contributes to it. The optimisation strategy follows from what users ask:
- Precise lookups answered by a sentence or a paragraph favour short, focused passages, so the matching passage's vector is about that detail and the result points straight at it. A long window lets you embed bigger units, but bigger units blur details rather than sharpen them.
- Questions about a document as a whole, where each document must stay one index row, need a window that holds the longest document. Anything past the window is silently dropped, so content near the end of a long document would never influence its vector.
- Documents longer than any available window can still be represented whole by embedding a condensed representation of each document, such as a generated summary, and keeping the full text alongside for the LLM.
- Long queries, when users paste large blocks of text, put the query side over the limit too. Because queries and documents must share one model, a longer-input model on the query side means re-embedding the documents with it as well (see the next section).
Chunk sizing for a given embedding model is covered in the data preparation lessons; this topic runs the other way, choosing the model for given units and queries.
Embedding consistency, re-embedding and language fit
Queries and documents must be embedded by the same model, so switching embedding models means re-embedding the whole corpus and changing the query path together. Vectors from different models live in different spaces even when they have the same number of dimensions, so similarity between a query vector from one model and a document vector from another is meaningless. A half-finished switch shows up as retrieved chunks that look unrelated to the questions.
Treat a model replacement on a self-managed index as one migration: re-embed every chunk with the new model, write the new vectors to the index (or build a new index and cut over), and switch the query embedding at the same moment. On a Delta Sync index with Databricks-computed embeddings, changing the embedding endpoint likewise means rebuilding the index so every vector comes from the new model.
Language fit
The embedding model must cover the languages of both the documents and the queries. Check the model card's language list first: an English-focused model maps other languages poorly however long its input. For cross-language retrieval, where a question written in one language must find a passage written in another, choose a multilingual embedding model, which places text with the same meaning near each other whatever the language. Embedding and generation are separate roles, so the multilingual requirement applies to the embedding model itself, not only to the LLM that writes the answer.
When no hosted embedding endpoint meets every requirement (language, input length, release status, licence), an open embedding model that does can be logged, registered in Unity Catalog and served on a custom model serving endpoint.
Finding models and reading model cards and licences
Databricks surfaces models in three places: Databricks-provided models in system.ai, partner and vendor models on Databricks Marketplace, and models you bring from external hubs such as Hugging Face.
| Source | What you get |
|---|---|
system.ai (the ai schema of the system catalog) | Databricks-provided foundation models with permissive licences, already registered in Unity Catalog, available to all account users by default and servable from Catalog Explorer with nothing to download |
| Databricks Marketplace | Datasets and models published by external providers; obtaining a listing shares the model into a read-only catalog in Unity Catalog, governed with Unity Catalog permissions, from which you can then serve it |
| External hubs (for example Hugging Face) | The widest choice; you download the model, log it with MLflow and register it in Unity Catalog yourself before serving |
Model cards
A model card is a screening tool: use it to drop models that fail a hard requirement before spending time on experiments. Read every field against the application:
- Task type and intended use: the model's role must match the job (a generative instruct model for writing and extraction, an embedding model for vectors).
- Languages: the users' and documents' languages must be listed.
- Context length: must hold the input plus the reply (for an LLM) or the longest chunk and query (for an embedding model).
- Licence: must permit the intended use.
A card describes the model in general. Anything that depends on your data, your prompts or your serving setup has to be measured in experiments. Screen on the card; decide on experiments.
Licences
Filter by licence first, then rank by score; a licence is a cheap pass/fail check that saves evaluation effort.
| Licence on the card | Commercial product? |
|---|---|
| Apache 2.0, MIT | Permitted (with their notice terms) |
| CC BY-NC 4.0 and other NC licences | Not permitted. The NC term restricts use to non-commercial purposes; whether a given internal use qualifies depends on its purpose, so check with legal |
| Research-use only | Not permitted |
| "other" or a custom licence file | Unknown until you read it: a custom licence may allow, restrict or attach conditions to commercial use |
For a derivative model (a fine-tune or other model built from another), check the whole licence chain, not just the latest label: the terms of the model it was built from continue to bind what was built on it.
Choosing a model from experiment metrics
Pick the metric that measures the failure the business cares about, compare every candidate on the same evaluation set, filter by the requirements, then rank by the objective. Log each candidate as a run in one MLflow experiment so metrics, parameters and costs sit side by side.
| Task | Common metric | What it measures |
|---|---|---|
| Summarisation with reference summaries | ROUGE | How much of the reference's content the summary recovers (recall-oriented n-gram overlap) |
| Translation with reference translations | BLEU | How much of the output appears in the references (precision-oriented n-gram overlap) |
| Short factual answers | Exact match | Whether the answer equals the reference; suits answers with one correct form |
| Classification | Accuracy, per-class precision, recall, F1 | Accuracy hides rare classes; recall counts missed cases; precision counts false alarms |
| Fit to domain text | Perplexity on held-out text | How well the model predicts your text; lower is better |
With imbalanced classes, overall accuracy is dominated by the common classes, so a model can score well while handling a rare class badly. Look at the per-class metric for the class that matters: recall when missing a case is the costly error, precision when false alarms are. Perplexity is an early, cheap signal of how familiar a model already is with your domain's language; the task metrics still decide.
Thresholds filter, the objective ranks
Treat each requirement (a minimum task score, a maximum p95 latency, a cost ceiling) as a filter: discard every run that fails any of them, then rank the survivors by the objective, such as lowest cost. A run that leads on one metric is still out if it breaks another requirement.
Is the difference real?
- Same evaluation set: scores are comparable only when the candidates were evaluated on the same examples. Runs on different or older versions of a set measure different things.
- Enough examples: on a small set, one or two examples swing the score by several points, so small gaps are within noise. Weigh a gap against the size of the set, and invest in a bigger representative set when the decision is costly or long-lived.
LLM judges and scorers for qualities such as groundedness and safety belong to the evaluation and monitoring material; this topic covers choosing a model from the classic task metrics your experiments produce.
Tip. Expect scenario questions that describe an application and ask which LLM, embedding model or experiment run to choose. Most hinge on one stated constraint: lowest cost or latency once quality ties, a context window that must hold input plus output, in-workspace processing or future fine-tuning, generally available features only, a commercial licence, or one index row per document. Embedding items give chunk, document and query lengths and ask which endpoint fits, or diagnose bad retrieval after a model switch. Model-card items show card fields (languages, context, licence, task) and ask which model goes forward. Metric items show a table of MLflow runs or a class imbalance and ask which metric or run decides. Some items are multiple selection.
- Filter on hard requirements first, then choose the smallest, cheapest model that meets the measured quality bar.
- The LLM's context window must hold the full prompt plus the maximum reply; buy no more window than that.
- Structured outputs via response_format constrain decoding to a JSON schema; prompt instructions and examples only encourage a format.
- Use a reasoning model only when it measurably raises accuracy on multi-step work and latency and cost allow it.
- Deploy Instruct versions; start from base versions for fine-tuning and continued pretraining.
- In-workspace processing or future fine-tuning means open weights on Model Serving; a permitted proprietary winner goes behind an external model endpoint.
- An embedding model's input window must cover the longest chunk and the longest query; gte-large-en takes 8,192 tokens, bge-large-en 512.
- Switching embedding models means re-embedding the corpus and the queries with the new model; equal dimensions do not make vectors comparable.
- Screen on the model card (task, languages, context, licence); decide on experiments run on the same evaluation set.
- Match the metric to the task: ROUGE for summaries, BLEU for translation, per-class recall for rare classes, perplexity for domain fit.
Frequently asked questions
How do I choose the best LLM for a Databricks generative AI application?
List the application's hard requirements (languages, tool calling, structured outputs, context window, where prompts may be processed, licence, fine-tuning plans) and drop every model that fails one. Measure the remaining models on your own evaluation set, keep those that clear the quality bar, and choose the one with the lowest cost or latency. A larger or reasoning model is only worth it when it measurably improves quality on your task.
How large does an LLM's context window need to be?
It must hold the whole request (system prompt, instructions, retrieved context, the question and any resent history) plus the maximum number of output tokens, because input and output share one window. Add the parts up, choose a window at or above the total, and recheck the sum whenever the request grows.
Which embedding model should I use on Databricks Foundation Model APIs: gte-large-en or bge-large-en?
Choose by input length. databricks-gte-large-en accepts up to 8,192 tokens and suits long chunks, whole short documents and long queries; databricks-bge-large-en accepts 512 tokens and suits paragraph-sized passages. Both are English models with 1,024-dimensional vectors. For queries in several languages, choose a multilingual embedding model instead.
What happens if I change the embedding model of a vector index?
You must re-embed every document with the new model and embed queries with it too. Vectors from different embedding models are not comparable even when they have the same number of dimensions, so a half-finished switch returns unrelated results.
Should I deploy the base or the Instruct version of an open model?
Deploy the Instruct version for chat and instruction-following applications, because it has been tuned to follow instructions. Databricks recommends base versions as the starting point for fine-tuning and continued pretraining, since a base model has only been trained to continue text.
Where can I find models on Databricks?
Databricks-provided foundation models with permissive licences are in system.ai in Unity Catalog and can be served from Catalog Explorer. Provider models on Databricks Marketplace are shared into a read-only catalog in Unity Catalog when you obtain the listing. Models from external hubs such as Hugging Face are logged with MLflow and registered in Unity Catalog by you.
Can I use a model with a CC BY-NC licence in a commercial product?
No. The NC (non-commercial) term restricts the model to non-commercial purposes, so a commercial product cannot use it; whether a particular internal use counts as non-commercial is a question for legal. A model derived from a CC BY-NC model, such as a fine-tune, is still bound by that restriction whatever licence its uploader shows.
Which metric should I use to compare models in experiments?
Use the metric that matches the task: ROUGE for summarisation, BLEU for translation, exact match for short factual answers, per-class recall or F1 for classification with a rare important class, and perplexity on held-out text for fit to domain language. Compare all candidates on the same evaluation set, apply every threshold first, then rank the survivors by cost or latency.
Source
This lesson covers the "Application Development" domain of the official Databricks GenAI exam guide. Vendors revise their guides — check the source for the current version.
Sign up free to mark lessons complete, bookmark topics and track your exam readiness.