End-to-End RAG Application
Overview
Section titled “Overview”Build a complete RAG (Retrieval-Augmented Generation) application that parses PDF documents, creates semantic embeddings, and serves answers through a chat interface. By the end you will have a working Knowledge Assistant backed by Vector Search and deployed as a Databricks App.
Skills used: databricks-ai-functions, databricks-vector-search, databricks-agent-bricks, databricks-app-python
MCP tools used: execute_sql, upload_to_volume, create_or_update_vs_endpoint, create_or_update_vs_index, manage_ka, create_or_update_app
Prerequisites
Section titled “Prerequisites”- A Databricks workspace with Unity Catalog enabled
- A catalog and schema for storing documents (e.g.
main.rag_demo) - PDF files to index (company docs, policies, technical manuals, etc.)
- A SQL warehouse for running AI Functions
-
Upload documents to a Volume
Start by getting your source documents into Unity Catalog.
Create a volume at /Volumes/main/rag_demo/documents/ and upload my local PDFfiles from ./docs/ into it. -
Parse and chunk the documents
Use AI Functions to extract text from PDFs and split into chunks suitable for embedding.
Build a document parsing pipeline:1. Use ai_parse_document to extract text from PDFs stored in/Volumes/main/rag_demo/documents/2. Chunk the extracted text into 500-token segments3. Store the chunks in a table main.rag_demo.document_chunks ready forVector Search indexing -
Create a Vector Search endpoint and index
Set up the semantic search infrastructure that powers retrieval.
Create a storage-optimized Vector Search endpoint called "rag-demo-endpoint"and then create a Delta Sync index on main.rag_demo.document_chunks thatautomatically embeds the "content" column using databricks-bge-large-en. -
Build a Knowledge Assistant
Create an agent that answers questions using the indexed documents.
Create a Knowledge Assistant that answers questions using the Vector Searchendpoint "rag-demo-endpoint" and index on main.rag_demo.document_chunks.Add instructions to cite specific document names in its answers. -
Deploy as a Streamlit app
Wrap the Knowledge Assistant in a user-friendly chat interface.
Build a Streamlit app on Databricks that provides a chat interface to myKnowledge Assistant. Include a sidebar showing source documents for eachanswer and a "clear conversation" button.
What You Get
Section titled “What You Get”- Document chunks table in
main.rag_demo.document_chunkswith parsed, chunked text - Vector Search index with automatic embedding and sync from the chunks table
- Knowledge Assistant agent that retrieves relevant chunks and generates cited answers
- Streamlit app with a chat UI deployed on Databricks Apps
Next Steps
Section titled “Next Steps”- Add MLflow Evaluation to score answer quality with Correctness and RetrievalGroundedness scorers
- Use Metric Views to track usage metrics
- Package everything as a Databricks Asset Bundle for repeatable deployment
- Scale up with a Supervisor Agent that routes between the KA and a Genie Space