Retrieval Augmented Generation
Agentic AI for Oracle AI Database Professional · Lesson 10 of 20 · 1:13:21
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the Agentic AI for Oracle AI Database Professional exam (1Z0-1159-26). In this lesson: the limits of language models, what RAG adds, the RAG flow from documents to answers, and the ways to build RAG with Oracle AI Database (PL/SQL, Select AI, and LangChain). Follows Ambergate Appliances, a fictional appliance maker. Includes three original practice questions.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
A confident wrong answer
Ambergate tried a general chatbot for its repair line, and it confidently described steps that do not exist on Ambergate dryers. It also knew nothing about the models launched last month. This lesson covers the limits of language models, what retrieval augmented generation does, its flow, and the ways to build it with Oracle AI Database.
The limits of language models
A large language model only knows what it learned in training, so its knowledge stops at a point in time. It has never seen your private data, like Ambergate's manuals and service logs. And when it does not know, it can still produce a fluent answer that is simply wrong, which is called a hallucination.
What RAG does
Retrieval augmented generation, or RAG, addresses these limits without retraining the model. At question time, a similarity search retrieves the most relevant facts from your own data. Those facts are added to the prompt along with the question, and the model is asked to answer from them. The answers are grounded in your data, up to date, and they can cite their sources.
The RAG flow
The flow has two phases. First, preparation: documents are converted to text, split into chunks, embedded, and stored in a table with a vector index. Then, for each question, the question is embedded with the same model, and a similarity search finds the top k chunks. The chunks and the question form an augmented prompt, and the language model writes the answer.
RAG with Oracle
Oracle AI Database offers three ways to build RAG. In the database, the DBMS_VECTOR_CHAIN package covers every step in SQL and PL/SQL, and the data stays in the database, except for the call to the language model you choose. Outside the database, frameworks like LangChain have an Oracle integration, which uses the database as the vector store. On Autonomous AI Database, Select AI with RAG automates the whole flow, from documents in Object Storage to answers with their sources. And in every case, the similarity search can be combined with relational, JSON, graph, or spatial data in the same query.
Recap
Let's recap. Language models know only their training data, never your private data, and they can hallucinate. RAG retrieves relevant facts at question time and adds them to the prompt, with no retraining, so answers are grounded and cite sources. Preparation turns documents into text, chunks, and vectors, and each question is embedded with the same model before the top k search. DBMS_VECTOR_CHAIN builds RAG in the database, LangChain builds it outside, and Select AI automates it on Autonomous AI Database. And the search combines with relational, JSON, graph, and spatial data.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
Ambergate published new dryer manuals last week, and the assistant must answer questions about them, without retraining any model. What fits?
- Retrieve manual chunks into the prompt
- Fine-tune the model every week
- Ask the model longer, more detailed questions
- Raise the temperature setting of the model
Show the answer
Retrieve manual chunks into the prompt
Retrieving the relevant chunks and adding them to the prompt gives the model the new facts, with no training at all. “Fine-tune the model every week” is retraining, which is exactly what the team wants to avoid, and it would always lag behind. “Ask the model longer, more detailed questions” cannot help, since the model has never seen the new manuals. And “Raise the temperature setting of the model” makes answers more varied, not more accurate.
A developer embeds the questions with a different model from the one used for the chunks, although both models produce vectors with the same number of dimensions. What happens?
- The search runs faster, but less accurately
- The language model corrects the mismatch
- Nothing, since the dimensions are the same
- Distances lose meaning, and matches are poor
Show the answer
Distances lose meaning, and matches are poor
Two models place meanings differently in their vector spaces, so the distances no longer reflect meaning, and the retrieved chunks are poor. “The search runs faster, but less accurately” is wrong, since the search costs the same, and only its results get worse. “The language model corrects the mismatch” is wrong, because the language model only sees the chunks it is given. And “Nothing, since the dimensions are the same” is the trap: equal dimensions make the query run, but they do not make the vectors comparable.
Ambergate’s legal team wants the manuals to stay in the database, with only the final prompt sent to the chosen language model, and the pipeline written in SQL and PL/SQL. Which approach fits?
- A Python app with an outside vector store
- DBMS_VECTOR_CHAIN in the database
- Fine-tuning a model on all the manuals
- A second vector database, synced nightly
Show the answer
DBMS_VECTOR_CHAIN in the database
DBMS_VECTOR_CHAIN runs every step in the database, in SQL and PL/SQL, and only the prompt goes to the language model. “A Python app with an outside vector store” moves the pipeline into an application outside the database, and stores the vectors elsewhere. “Fine-tuning a model on all the manuals” is retraining, and it puts the manuals inside a model. And “A second vector database, synced nightly” copies the manuals to a second system, which the legal team wants to avoid.