CertSafari
    Databricks Certified Generative AI Engineer Associate· Lessons

    Domain 2 · Lesson 11/56

    Choosing source documents for a RAG corpus

    Identify needed source documents that provide necessary knowledge and quality for a given RAG application

    14 min read
    1.75% of exam
    3 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Explain why the document corpus sets the upper limit on what a RAG application can answer
    • Work backward from expected user questions to the documents the corpus must contain
    • Diagnose a topic-specific retrieval failure as a coverage gap rather than a configuration problem
    • Use domain experts to decide which sources are authoritative and what complete coverage means
    • Test a candidate source against four criteria: relevant, current, unique, and clean

    Key concept

    The corpus as the ceiling on answer quality — A RAG application can only answer from what its corpus contains. Chunking, embeddings, re-ranking and prompting decide how well existing content is found and used, but none of them can supply knowledge that was never ingested.

    1.The corpus sets the ceiling on answer quality

    Choosing what goes into the corpus is the first decision in any RAG data pipeline, and it limits everything after it. The pipeline starts with corpus composition and ingestion: picking the data sources and content that fit the specific use case. Parsing, deduplication, filtering, chunking, embedding and indexing all come later, and they can only work on documents that were selected.

    Retrieval quality has two ways to fail. The context passed to the LLM can be missing the information the user needs, or it can contain superfluous information that distracts the model. A missing document is the first kind of failure in its purest form. No retriever setting can return a passage that doesn't exist, and a generator with nothing relevant in its context will either refuse or hallucinate. Weak retrieval also drags down generation, so a gap in the corpus shows up later as a bad answer.

    The goal is the right content, not the most content. Three tempting rules are all wrong. Bigger is better fails because duplicate and irrelevant documents actively hurt the index. One format only fails because a normal unstructured corpus mixes PDFs, Google and Office documents, and wikis, and the pipeline handles this by choosing a parser per type (for example, unstructured or PyPDF2 for PDFs and Word files, and BeautifulSoup for HTML). Exclude long documents fails because chunking exists to split large documents into smaller pieces that fit the LLM's context. Choosing the parser for each format is covered in extracting document content by format, and chunking in chunking strategy.

    Checkpoint 1 of 7· Check yourself

    A support assistant answers most product questions well. Its corpus was built from product manuals and FAQs, but the warranty policy document was never ingested. When users ask about warranty terms, the assistant refuses or makes up an answer. Which change will fix this?

    Checkpoint 2 of 7· Exam question

    Which statement best describes the foundational consideration when selecting source documents for a RAG application's corpus?

    Sources12

    2.Working backward from the questions users will ask

    The right corpus comes from the application's requirements, not from whatever data happens to be easy to reach. To find the needed sources, start from the questions users will ask and work back to the documents that answer them. For a customer support bot, that leads to four kinds of source, each covering a different kind of question.

    Customer support bot: the question users ask and the source that has to be in the corpus to answer it
    What users ask aboutSource document that must be in the corpus
    General how-to and policy questionsKnowledge base documents
    Common, repeated questionsFrequently Asked Questions (FAQs)
    What a product does and its exact specificationsProduct manuals and specifications
    Something is broken and needs fixingTroubleshooting guides

    Sometimes the answer to a question isn't in a document at all. RAG can retrieve from structured data as well as unstructured data. Unstructured sources include PDFs, Office documents, wikis, images and videos. Structured sources include customer records in a warehouse, transaction data in a SQL database, and data from application APIs such as SAP or Salesforce. If users will ask "what is the status of my order?", the source you need is the transaction table, and no number of manuals will cover it.

    How a failure is spread tells you where it comes from. Pipeline settings such as the parsing and chunking strategy, the embedding model, the number of chunks retrieved, and re-ranking all affect retrieval quality, but they apply the same way to every topic. If they were badly set, many topics would suffer. When one category of question returns nothing while the rest work, the likely cause is that the corpus has no document on that subject. Tuning settings won't help. The fix is to find the missing document and ingest it. To find gaps like this systematically, see evaluating retrieval performance.

    Checkpoint 3 of 7· Match them up

    Match each question users of a customer support assistant will ask to the source that has to be in the corpus to answer it.

    Tap a term, then the definition that fits it.

    Checkpoint 4 of 7· Exam question

    During evaluation of an HR-assistant RAG application, reviewers notice that a recurring category of employee questions about benefits enrollment consistently returns no relevant retrieved content, even though retrieval and chunking configurations are otherwise working well for other topics. What is the most likely root cause and appropriate fix?

    Sources132

    3.Domain experts decide what complete coverage means

    An engineer can list the document stores but usually can't say which version of a policy is the real one, or which questions come in every week. Subject-matter experts and stakeholders can. Bring them in at the start of the project, not after evaluation has already found gaps.

    Experts contribute in three ways:

    • Identifying and curating sources. They say which content is authoritative and which is outdated, a draft, or unofficial.
    • Predicting queries. They know the kinds of questions users are likely to ask, which gives you the list of questions to work backward from.
    • Prioritising. They rank the most critical information, so the first version of the corpus covers what matters most instead of whatever was easiest to ingest.

    These decisions belong to experts because coverage and authority are questions about the domain, not about engineering. A support lead knows that the troubleshooting wiki is more current than the PDF manual. A benefits administrator knows that the intranet FAQ replaced last year's handbook. Neither fact shows up in file metadata. Feedback from experts after launch is covered in incorporating SME feedback.

    Checkpoint 5 of 7· Check yourself

    Your team is planning an HR benefits assistant and has not ingested anything yet. The benefits administrator has agreed to help. How should the team use their time to get the best corpus?

    Sources1

    4.Four tests for a candidate source: relevant, current, unique, clean

    A document that covers a needed topic isn't automatically fit for the corpus. Some ingested documents won't help the agent, because they are irrelevant to its purpose, too old or unreliable, or contain problematic content. Others contain sensitive information that must never be exposed through the agent. Together with duplication, these give four tests that each candidate source has to pass.

    The four source quality criteria, what happens when a source fails one, and how to enforce it
    CriterionFailure if ignoredHow to enforce it
    RelevantOff-purpose documents add superfluous context that crowds out useful chunksFilter out documents irrelevant to the agent's purpose
    CurrentOld or unreliable documents give stale answers, which defeats RAG's up-to-date advantageDrop outdated versions; when copies conflict, keep the most recently updated
    UniqueDuplicates and near-duplicates fill the index with redundant chunksDeduplicate by metadata or content; keep the most authoritative copy
    CleanPersonal information or harmful language can reach users through answersApply a toxicity classifier and PII detection, and filter before ingestion

    Current matters because freshness is one of the reasons to use RAG in the first place: the application can give the LLM information from an updated knowledge base. A corpus full of superseded manuals throws that advantage away.

    Unique is mostly a problem of shared drives. The same document often sits in several folders with small edits, alongside draft blog posts and copies of product docs. Deduplicating by picking any copy at random is only a baseline. It is better to keep the best version: the most recently updated, the published one, or the one from the most authoritative source. Choosing the authoritative copy is the same judgement domain experts make when they curate sources.

    Clean is about whether a source is safe to include, and that has to be checked before the document is added. Suppose a team supplements an internal wiki with scraped public posts that include email addresses and abusive replies. The fix is to run the documents through a toxicity classifier and a PII detection algorithm, then use the predictions as a filter before ingestion. Filtering comes before chunking in the pipeline, so smaller chunks only spread the sensitive text across more pieces. Moving the posts to a separate table leaves them retrievable. Relying on guardrails at inference time leaves the content in the corpus and hopes the model never repeats it. Sources are also a route for data poisoning attacks, which is another reason to detect and filter at this stage.

    These four tests decide whether a whole document goes into the corpus. Removing boilerplate from inside documents you keep is covered in filtering extraneous content. Masking or rewriting problematic passages is covered in mitigating problematic text, and checking whether you're allowed to use a source at all is covered in legal and licensing requirements.

    Checkpoint 6 of 7· Match them up

    An IT helpdesk team reviews candidate sources before ingestion. Match each problem they find to the source quality test it fails.

    Tap a term, then the definition that fits it.

    Checkpoint 7 of 7· Exam question

    A team is preparing a source corpus by scraping publicly available community forum posts to supplement an internal knowledge base for a RAG assistant. Some forum posts contain personal contact details and occasional offensive language. Before these documents are added as knowledge sources, what should the team do to protect application quality and safety?

    Sources13

    Sources

    (3)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Corpus composition and ingestion: Select the right data sources and content based on the specific use case.”
      ↩︎ The corpus sets the ceiling on answer quality
      “Segmenting large documents into smaller, semantically concentrated chunks ensures that retrieved data fits in the LLM's context”
      ↩︎ The corpus sets the ceiling on answer quality
      “The correct data depends entirely on your application's specific requirements and goals”
      ↩︎ Working backward from the questions users will ask
      “Engage domain experts and stakeholders from the beginning of any project to help identify and curate relevant content”
      ↩︎ Domain experts decide what complete coverage means
      “insights into the types of queries that users are likely to submit and help prioritize the most critical information to include.”
      ↩︎ Domain experts decide what complete coverage means
      “either because they are irrelevant to its purpose, too old or unreliable, or because they contain problematic content such as harmful language.”
      ↩︎ Four tests for a candidate source: relevant, current, unique, clean
      “select the “best” version of the duplicate using other logic (such as most recently updated, publication status, or most authoritative source)”
      ↩︎ Four tests for a candidate source: relevant, current, unique, clean
      “applying a personally identifiable information (PII) detection algorithm to the documents to filter documents.”
      ↩︎ Four tests for a candidate source: relevant, current, unique, clean
      “any document sources you feed into your agent are potential attack vectors for bad actors to launch data poisoning attacks.”
      ↩︎ Four tests for a candidate source: relevant, current, unique, clean
      “removing duplicates, and filtering out unwanted information, the next step is to break it down into smaller, manageable units called chunks.”
      ↩︎ Four tests for a candidate source: relevant, current, unique, clean
      “Your RAG application can't retrieve the information required to answer a user query without the right data corpus.”
      ↩︎ Key concept
      “you can end up with highly redundant chunks in your final index that can decrease the performance of your application.”
      ↩︎ Exam trap 1
      “Your RAG application can't retrieve the information required to answer a user query without the right data corpus.”
      ↩︎ Exam trap 2
      “applying a toxicity classifier to the document to produce a prediction you can use as a filter.”
      ↩︎ Exam trap 3
      “Engage domain experts and stakeholders from the beginning of any project to help identify and curate relevant content”
      ↩︎ Exam trap 4
      “you can end up with highly redundant chunks in your final index that can decrease the performance of your application.”
      ↩︎ Prediction
      “Your RAG application can't retrieve the information required to answer a user query without the right data corpus.”
      ↩︎ Checkpoint
      “Your RAG application can't retrieve the information required to answer a user query without the right data corpus.”
      ↩︎ Prediction
      “either because they are irrelevant to its purpose, too old or unreliable, or because they contain problematic content such as harmful language”
      ↩︎ Checkpoint
    2. 2.
      “It's difficult to generate high-quality RAG output if the context provided to the LLM is missing important information or contains superfluous information.”
      ↩︎ The corpus sets the ceiling on answer quality
      “generation quality will invariably be impacted by poor retrieval”
      ↩︎ The corpus sets the ceiling on answer quality
      “Retrieval quality can be influenced by both the data pipeline (for example, parsing/chunking strategy, metadata strategy, embedding model)”
      ↩︎ Working backward from the questions users will ask
    3. 3.
      “RAG architecture can work with either unstructured or structured supporting data. The data you use with RAG depends on your use case.”
      ↩︎ Working backward from the questions users will ask
      “Up-to-date information: A RAG application can supply the LLM with information from an updated knowledge base.”
      ↩︎ Four tests for a candidate source: relevant, current, unique, clean

    Spotted a mistake, or was something unclear? Tell us.