Application Development on Databricks Generative AI
This domain tests your ability to design, build, and deploy production-grade generative AI applications on Databricks—including RAG pipelines, LangChain integrations, agent systems, and model serving patterns. It covers the full stack from vector indexing through prompt engineering to MLflow packaging. At 30% of the exam, this is the highest-weighted domain and the primary differentiator between passing and failing candidates.
Mosaic AI Vector Search: Creating and Querying Indexes
Mosaic AI Vector Search is Databricks' managed vector database service, tightly integrated with Unity Catalog and Delta Lake. It stores and queries high-dimensional embeddings for similarity search.
Index Types
| Index Type | Source | Sync Mode | When to Use |
|---|---|---|---|
| Delta Sync Index | Delta table (Unity Catalog) | Automatic (triggered or continuous) | Production RAG; source data changes regularly |
| Direct Vector Access Index | API write only | Manual via API | Custom pipelines; non-Delta sources |
- Delta Sync Index – Triggered: syncs on demand (via API call or schedule). Lower cost.
- Delta Sync Index – Continuous: streams changes in near-real-time. Higher cost but fresher data.
- Direct Vector Access Index: embeddings are written and updated entirely through the Vector Search API; no Delta table backing.
Creating an Index (Key Parameters)
client.create_delta_sync_index(
endpoint_name="vs_endpoint",
index_name="catalog.schema.my_index",
source_table_name="catalog.schema.source_table",
pipeline_type="TRIGGERED", # or CONTINUOUS
primary_key="id",
embedding_dimension=1536,
embedding_vector_column="embedding",
embedding_model_endpoint_name=None # optional: auto-embed via endpoint
)
- The primary key must be a column in the source Delta table.
- embedding_dimension must match the output dimension of the model used to create embeddings.
- If
embedding_model_endpoint_nameis provided, Vector Search calls that endpoint to compute embeddings automatically (Managed Embeddings mode).
Querying
results = index.similarity_search(
query_text="explain transformers", # or query_vector=[...]
columns=["id", "content"],
num_results=5,
filters={"category": "NLP"} # metadata filtering
)
query_textrequires a managed-embeddings index (endpoint auto-embeds at query time).query_vectorrequires a pre-computed vector of the correct dimension.- Metadata filtering uses exact-match predicates on non-vector columns.
Common Traps
- Assuming you can use
query_texton a Direct Vector Access Index—you cannot unless an embedding endpoint is attached. - Confusing endpoint (the compute cluster serving Vector Search) with index (the data structure). An endpoint hosts one or more indexes.
- Forgetting that Delta Sync indexes require the source table to be in Unity Catalog.
- Believing "continuous" sync means zero latency—there is still a short propagation delay.
LangChain Integration Patterns on Databricks
Databricks provides first-class LangChain integration through the databricks-langchain package (formerly langchain-community Databricks classes).
Key Integration Classes
| Class | Purpose |
|---|---|
ChatDatabricks | Chat-style LLM calls against Model Serving endpoints |
DatabricksEmbeddings | Generate embeddings via a Model Serving endpoint |
DatabricksVectorSearch | Use Mosaic AI Vector Search as a LangChain retriever |
DatabricksChatMessageHistory | Persist conversation history (MLflow-backed) |
Standard RAG Chain Pattern
RAG chain data flow: query to answer
from databricks_langchain import ChatDatabricks, DatabricksVectorSearch, DatabricksEmbeddings
from langchain.chains import RetrievalQA
from langchain_core.prompts import ChatPromptTemplate
embeddings = DatabricksEmbeddings(endpoint="databricks-bge-large-en")
retriever = DatabricksVectorSearch(
index_name="catalog.schema.my_index",
embedding=embeddings,
columns=["content"]
).as_retriever(search_kwargs={"k": 5})
llm = ChatDatabricks(endpoint="databricks-meta-llama-3-1-70b-instruct", temperature=0)
chain = RetrievalQA.from_chain_type(llm=llm, retriever=retriever)
LCEL (LangChain Expression Language)
Modern chains use the | pipe operator:
chain = prompt | llm | output_parser
- LCEL chains are natively compatible with MLflow
langchainflavor logging. - Use
mlflow.langchain.log_model()to log LCEL chains with automatic dependency inference.
Common Traps
- Using
ChatOpenAIinstead ofChatDatabricks—OpenAI classes do not route to Databricks Model Serving. - Logging a chain with
mlflow.pyfuncwhen themlflow.langchainflavor provides richer metadata and schema inference. - Forgetting that
DatabricksVectorSearchneeds either aquery_textpath (managed embeddings) or anembeddingobject passed explicitly. - Assuming LangChain
ConversationBufferMemoryis always the right memory class—for long contexts,ConversationSummaryMemoryis more appropriate.
Unlock with a paid plan
9 more sections (about 2,179 words) continue below. Every paid plan unlocks all Generative AI Engineer Associate study guides, the full question bank and mock exams, from $4.97/month.