SaveMyCert
Log in
5 of 5 free questions left today·for 10 a day
Techniques to improve gen AI model output

Grounding Techniques: RAG, Google Search, and Sampling Settings

14 min readGenAI Leader · Techniques to improve gen AI model outputUpdated

Grounding is the practice of connecting a large language model's responses to verifiable sources of data, so the model answers from facts rather than from memory alone. It is Google Cloud's primary technique for reducing hallucinations and making gen AI trustworthy enough for business use. On the exam, you need to distinguish three sources of grounding data — first-party enterprise data, third-party data, and world data — and explain how retrieval-augmented generation (RAG) changes what a model produces. You also need to recognize Google Cloud's three grounding offerings: pre-built RAG with Agent Search, RAG APIs for custom pipelines, and grounding with Google Search for fresh public information. Finally, this objective covers the sampling parameters and settings that control model behavior: token count, temperature, top-p (nucleus sampling), safety settings, and output length. This lesson covers each concept, the business case for choosing one approach over another, and the trade-offs a leader should weigh.

What you’ll learn
  • Define grounding and explain why it reduces hallucinations in LLM output
  • Differentiate grounding with first-party enterprise data, third-party data, and world data by the data's origin
  • Describe how retrieval-augmented generation (RAG) affects generated output, including its limits and token cost
  • Match Google Cloud's grounding offerings — pre-built RAG with Agent Search, RAG APIs, and grounding with Google Search — to business scenarios by reachability and build effort
  • Explain how token count, temperature, top-p, safety settings, and output length control model behavior
  • Choose appropriate grounding and sampling settings for a given business use case

What grounding means in large language models

Grounding means connecting a model's output to a verifiable source of information, so the response is based on retrieved facts rather than only on what the model absorbed during training. A foundation model on its own generates answers from patterns learned before its knowledge cutoff. It has no built-in awareness of your company's documents, yesterday's news, or a product catalog that changed this morning. When it is asked about something outside its training data, it may produce a fluent but fabricated answer — a hallucination.

Grounding addresses this by giving the model reference material at the moment it answers. Instead of asking the model to recall, you ask it to read and then respond. The model's role shifts from being the source of truth to being a reasoning and language layer over a source of truth you control. This is why grounding is one of the Google Cloud-recommended practices for overcoming foundation model limitations, alongside prompt engineering, fine-tuning, and human-in-the-loop review.

For a business leader, the value is straightforward: grounded answers can cite where they came from, they stay current as the underlying data changes, and they reflect your organization's own information rather than a generic view of the world. That combination — accuracy, freshness, and traceability — is what makes gen AI dependable enough for customer-facing and decision-supporting work.

Three sources of grounding data: first-party, third-party, and world data

Grounding data comes from three distinct sources, and the exam expects you to tell them apart. First-party data is data your organization owns and generates: internal documents, product manuals, support tickets, HR policies, and customer records. Third-party data comes from external providers or partners: licensed industry reports, market data feeds, or partner catalogs — external information your organization acquires but does not create. World data is broad public knowledge, such as the information available through Google Search: news, public websites, and general facts about the world.

Data sourceWhat it isExampleTypical use case
First-party enterprise dataData your organization creates and ownsInternal policy documents, product manuals, CRM recordsEmployee knowledge assistants, customer support grounded in your own documentation
Third-party dataExternal data acquired from providers or partnersLicensed industry research, partner product catalogs, market data feedsEnriching answers with specialist or partner information you do not produce yourself
World dataBroad, public, constantly updated knowledgeGoogle Search results, public news and websitesQuestions about current events, public facts, or anything past the model's knowledge cutoff

The distinction matters because each source answers a different business question. If a customer asks about your refund policy, only first-party data holds the answer. If an analyst asks about industry benchmarks, third-party data is the right source. If a user asks about something that happened last week, world data — fresh public information — is the only source that can be current enough.

Two rules keep the classification straight. First, the category follows the data's origin, not the app's audience or where a copy happens to be stored. Terms and conditions your company wrote are first-party data even when a public-facing chatbot answers from them; a licensed dataset stays third-party data after you download it into your own storage. Second, the category does not by itself pick the Google Cloud offering. Licensed third-party files can be indexed by Agent Search exactly like your own documents. What decides the offering is reachability — is the information on the public web, or held privately? — and how much build effort the team can invest.

How retrieval-augmented generation (RAG) changes model output

Retrieval-augmented generation (RAG) is the technique that makes grounding work at scale: when a user asks a question, the system first retrieves the most relevant passages from a knowledge source, then passes those passages to the model along with the question, and the model generates its answer from the retrieved material. Retrieval happens at query time, every time — the knowledge base can change daily and the answers change with it, without retraining or fine-tuning the model.

RAG changes the generated output in several concrete ways. Answers become more accurate and specific, because the model is working from actual source text instead of a statistical impression of it. Answers become current, because the retrieved documents reflect today's state of the knowledge base, not the model's training cutoff. Answers become attributable, because the system knows which documents were retrieved and can cite them, letting users verify claims. And hallucinations drop sharply, because the model is instructed to answer from the provided context — and can say it does not know when the context contains no answer.

RAG and fine-tuning solve different problems. Fine-tuning changes how the model behaves: trained on many examples, it learns a tone, an output structure, or a task style, and that learning is baked into the model until it is tuned again. Grounding with RAG changes what the model knows at request time: it supplies current, citable facts with each prompt and leaves the model itself unchanged. Fine-tuning is therefore the wrong tool for facts that change or must be cited, and RAG is the wrong tool for making every answer follow a house style. The two can be combined when a use case needs both — for example, a model tuned to write in a company's support format that is also grounded in the current policy documents. For most enterprise question-answering use cases, RAG is the faster, cheaper, and more governable path, which is why Google Cloud offers it both pre-built and as APIs.

RAG has limits a leader should know. A cited answer is only as current and correct as the corpus it retrieves from: if a superseded policy version is still indexed next to its replacement, the system can retrieve the old version and cite it with full confidence. The fix is corpus curation — removing or de-indexing outdated documents and keeping the source of truth maintained — not a sampling change (lower temperature only makes the model follow the stale text more faithfully) and not fine-tuning. The same applies to new content: retrieval searches an index, and the index is only as current as its last ingestion or re-index. A document added to the source system after that point does not exist as far as the RAG system is concerned until the data store is refreshed, so data-store refresh schedules are part of keeping a grounded assistant accurate. RAG also has a cost profile: the retrieved passages are sent to the model as part of the prompt, so they count as input tokens. Adding several passages to every request raises per-request input token usage and cost even when the answers stay the same length, and the retrieval step adds some latency rather than removing generation work.

Google Cloud's grounding offerings

Google Cloud provides three grounding offerings, each aimed at a different balance of speed, control, and data source. Pre-built RAG with Agent Search is the out-of-the-box option: you point it at your enterprise content — documents, sites, structured data — and it handles the entire retrieval pipeline for you, from ingesting and indexing content to retrieving relevant passages and grounding responses with citations. It works over the content you supply to it — your own first-party documents and licensed third-party files alike — and it is the fastest route to a grounded enterprise assistant because there is no retrieval infrastructure to design.

Agent Search does offer some configuration — for example, settings for how documents are parsed and chunked, and controls to boost or bury certain results — but it runs Google's managed pipeline, not your team's own chunking or ranking code. Bringing your own logic to a stage is the job of the RAG APIs.

RAG APIs serve teams that need to build a custom retrieval pipeline. Instead of one managed black box, developers get component APIs for the stages of RAG — processing documents, generating embeddings, ranking retrieved results, and grounding generation on them. This suits organizations with specific requirements the pre-built path cannot express: a specialized corpus, custom chunking or ranking logic, or integration into an existing application architecture. The trade-off is classic build-versus-buy: more control and flexibility in exchange for more engineering effort.

Grounding with Google Search connects the model to world data. When enabled, the model can ground its response in fresh Google Search results, which addresses the knowledge cutoff directly: questions about recent events, current prices, or newly published public information get answers based on what the web says now, with source links. A grounded response comes back with grounding metadata that lists the web sources the answer drew on, which applications display as links so readers can check each claim. Google Search reaches only public web content. Internal, unpublished information — a draft report, an unreleased product roadmap, a confidential price list — is invisible to it, so that information needs RAG over first-party data (Agent Search or the RAG APIs) even when freshness is the main concern. Grounding with Google Search is the right choice when the facts you need are public and time-sensitive rather than proprietary.

Freshness also separates the two ways of reaching public web content. Agent Search can index a public website into a data store, but that copy is only as current as its last crawl or re-index, so anything published since then is missed. Grounding with Google Search queries the live web on each request. If a use case depends on public information that changes faster than a data store can be refreshed — breaking news, today's announcements — Google Search grounding is the fit; a scheduled index of a public site suits stable reference content you want to scope tightly.

OfferingData it reachesBuild effort and control
Pre-built RAG with Agent SearchContent you supply: first-party documents, sites and structured data, plus licensed third-party filesLowest effort; managed pipeline with limited configuration
RAG APIsContent you supply, processed by a pipeline you designHighest effort; component APIs for parsing, embeddings, ranking and grounded generation
Grounding with Google SearchPublic web content onlySwitched on for the model request; returns source links in grounding metadata

These offerings combine naturally. A customer-service agent might ground product and policy answers in first-party data through Agent Search while using grounding with Google Search for public, fast-moving questions. The exam signal to watch for: enterprise documents, minimal build effort points to pre-built RAG with Agent Search; custom pipeline control points to RAG APIs; fresh public information points to grounding with Google Search.

A business example: grounding a customer-support assistant

Consider a retail bank that wants a gen AI assistant to answer customer questions about its accounts, fees, and services. An ungrounded model would be unusable here: it might state a fee schedule from its training data that is years out of date, or invent a policy that never existed — an unacceptable compliance and trust risk in a regulated industry.

The bank grounds the assistant in its first-party data — current product terms, fee schedules, and policy documents — using pre-built RAG with Agent Search, because the content is standard enterprise documentation and speed to deployment matters. Every answer now reflects the current published documents and carries citations a support agent or auditor can check. When a document is updated, the next answer reflects the change automatically, with no model retraining.

Later, the bank adds licensed third-party market data so the assistant can answer comparative questions about industry-standard rates, and enables grounding with Google Search for public, time-sensitive questions such as current regulatory announcements. Each data source maps to a category of question the business needs answered — which is exactly how the exam frames grounding decisions: start from what the user needs to know, then choose the source that authoritatively holds that knowledge.

Sampling parameters: controlling how the model generates

Grounding controls what a model knows when it answers; sampling parameters and settings control how it generates the answer. A language model produces output one token at a time — a token being a small chunk of text, roughly part of a word — and at each step it chooses from many possible next tokens, each with a probability. The sampling parameters shape that choice, and the settings around them constrain the response as a whole.

Parameter or settingWhat it controls
Token countHow much text is processed and produced, measured in tokens; drives cost and constrains how long prompts and responses can be
TemperatureThe randomness of token selection; low values make output focused and consistent, high values make it more varied and creative
Top-p (nucleus sampling)The size of the candidate pool: the model samples only from the smallest set of tokens whose combined probability reaches the threshold p, cutting off unlikely options
Safety settingsA blocking threshold set separately for each harm category (harassment, hate speech, sexually explicit, dangerous content), so content that crosses the configured threshold is blocked
Output lengthThe maximum number of tokens the model may generate in a response (max output tokens), capping response size and cost; a response that hits the cap is cut off

Temperature is the parameter most tested. At low temperature the model strongly favors the most probable tokens, producing predictable, repeatable answers — right for factual Q&A, summarization, and anything grounded, where you want the model to stick to its sources. At high temperature, probability differences flatten and less likely tokens get chosen more often — useful for brainstorming, marketing copy, and creative variation. Lowering temperature reduces run-to-run variation but does not guarantee identical output: even at or near zero, small differences between runs remain possible.

Temperature and top-p change different things. Temperature reshapes the probabilities themselves — how sharply the model favours its likeliest tokens. Top-p leaves that shape alone and cuts the candidate pool: the model keeps the likeliest tokens, in order, until their combined probability reaches p, and samples only from that set. A worked example: suppose the next-token candidates are blue 0.50, clear 0.25, grey 0.15, cloudy 0.06, and a long tail sharing the rest. With p = 0.7 the running total is 0.50 (still short of 0.7), then 0.75 — so blue and clear stay in the pool and everything else is ignored. Raise p to 0.95 and the total must climb through 0.90 to 0.96, so grey and cloudy join the pool too. If instead the model were confident, with one token at 0.85, that single token would already pass 0.7 and the pool would shrink to one.

That adaptive pool size is what separates top-p from top-k, a related setting some models expose. Top-k keeps a fixed number of candidates — say the 40 likeliest — no matter how confident the model is. Top-p keeps however many tokens it takes to reach p: few when one token clearly dominates, many when the model is uncertain. Both trim the long tail of unlikely tokens; only top-p adapts to the model's certainty.

Safety settings and output length in practice

Safety settings let you configure how strictly a Gemini model filters potentially harmful content. The model scores prompts and responses against four configurable harm categories — harassment, hate speech, sexually explicit content and dangerous content — and you set a blocking threshold for each category separately, from blocking even low-probability harm, through blocking only high-probability harm, to not blocking at all. A consumer-facing brand assistant would run strict settings; an internal moderation-review tool might need more permissive ones to examine flagged content at all. The business point is that safety behavior is configurable per application, not fixed — you tune it to the audience and risk profile of each use case.

Know what safety settings do not cover. Personal data, copyrighted text and general profanity are not among the configurable harm categories. Separately from those thresholds, Gemini also applies non-configurable filters that always block certain content, such as child sexual abuse material and some personally identifiable information, and you cannot switch them off. Detecting and redacting personal or sensitive data is handled by services such as Sensitive Data Protection or Model Armor, and Gemini runs its own recitation check, which can stop a response that reproduces long passages of existing text such as copyrighted material. Nor is a system instruction asking the model to avoid certain topics a substitute for filter thresholds: an instruction shapes behaviour but can be ignored or worked around, while a threshold is applied to every response.

Output length caps the number of tokens the model may generate in a single response. When a response reaches that cap, generation simply stops — the visible symptom is an answer that ends mid-sentence or mid-list. Raising the limit (or asking for shorter answers) fixes truncation; lowering it makes truncation more likely. The cap is also a cost control and a product decision: a chat widget that needs two-sentence answers should not permit thousand-token responses. Token count more broadly is the unit in which context and cost are measured. Gemini text usage on Agent Platform with pay-as-you-go pricing is billed per token, for both the input (the prompt, system instructions and any retrieved context) and the output — not per request or per word. Some add-ons carry their own charge on top of tokens: grounding with Google Search, for example, is billed separately for grounded requests. Longer prompts, larger retrieved contexts, and longer answers all consume more tokens, so leaders planning gen AI budgets think in tokens the way they think in compute hours elsewhere.

These settings work together with grounding, not instead of it. A well-designed grounded assistant typically pairs retrieval over trusted data with low temperature, appropriate safety settings, and an output length matched to the surface it serves — each control addressing a different dimension of response quality: factual basis, consistency, safety, and size.

Choosing the right combination for the exam and the business

Choosing correctly starts with two questions: where does the authoritative knowledge live, and what generation behavior does the use case demand? The knowledge question selects the grounding source — first-party enterprise data for your own documents and records, third-party data for licensed external information, world data via Google Search for fresh public facts. The behavior question sets the sampling parameters — low temperature and constrained output for factual, consistent answers; higher temperature and looser limits for creative work.

The offering follows from effort and control. Pre-built RAG with Agent Search is the default for grounding on enterprise content quickly; RAG APIs are for teams building a custom retrieval pipeline with specific requirements; grounding with Google Search is for currency beyond the knowledge cutoff. None of these requires retraining a model, which is precisely their business appeal: grounding decouples the model from the knowledge, so the knowledge can change daily while the model stays the same.

Exam questions in this objective are scenario-driven. Expect a described business need — reduce hallucinations in a support bot, answer questions about last week's announcement, make a legal-drafting assistant less creative — and four plausible responses. Anchor on the vocabulary: hallucination and verifiable sources point to grounding; current public events point to grounding with Google Search; proprietary documents point to first-party data and RAG; consistency versus creativity points to temperature and top-p; response size and cost point to token count and output length; harmful-content filtering points to safety settings.

Tip. The exam presents business scenarios and asks you to pick the right grounding source (first-party, third-party, or world data, classified by the data's origin) or the right Google Cloud offering (pre-built RAG with Agent Search, RAG APIs, or grounding with Google Search, chosen by whether the data is public or private and how much build effort the team can invest). Expect questions on how RAG changes model output — accuracy, freshness, citations, fewer hallucinations — without retraining, and on its limits: stale documents in the corpus and added input tokens. Sampling questions describe a desired behavior or symptom — inconsistent answers, truncated responses, harmful content for a given audience, cost — and ask which parameter or setting to adjust: temperature, top-p, token count, output length, or the per-category safety thresholds.

Key takeaways
  • Grounding connects LLM responses to verifiable data sources, reducing hallucinations and keeping answers current without retraining the model.
  • First-party data is what your organization creates and owns, third-party data is acquired from external providers, and world data is broad public knowledge such as Google Search results — the category follows the data's origin, not the app's audience.
  • RAG retrieves relevant content at query time and sends it with the prompt, making output more accurate, current, and attributable — but only as current as the indexed corpus (stale documents and un-refreshed indexes both leak through), and the retrieved passages add input tokens.
  • Pre-built RAG with Agent Search is the fastest path to grounding on content you supply (first-party or licensed third-party); RAG APIs give developers component-level control over a custom retrieval pipeline.
  • Grounding with Google Search grounds responses in fresh public web data and returns source links, but it cannot reach internal, unpublished information — that needs RAG.
  • Temperature reshapes how sharply the model favours likely tokens (lower = more consistent, but not guaranteed identical); top-p keeps the smallest set of tokens whose probabilities reach p, so the pool adapts to the model's certainty, unlike top-k's fixed count.
  • Safety settings set a blocking threshold per harm category (harassment, hate speech, sexually explicit, dangerous content), tuned per application; a response that hits the max output token limit is cut off mid-sentence.
  • Gemini pay-as-you-go text usage is billed per token for both input and output, so token count and output length are how leaders control spend and response size.
  • Fine-tuning changes how a model behaves (tone, structure, task style); RAG supplies current, citable facts at request time — and the two can be combined.

Frequently asked questions

What is grounding in generative AI?

Grounding is the practice of connecting a large language model's responses to verifiable sources of information, such as enterprise documents or Google Search results, so the model answers from retrieved facts rather than only from its training data. It is Google Cloud's primary recommended technique for reducing hallucinations and keeping answers current and attributable.

What is the difference between first-party, third-party, and world data for grounding?

First-party data is data your organization creates and owns, such as internal documents and customer records. Third-party data is external data acquired from providers or partners, such as licensed industry research. World data is broad public knowledge, such as the fresh information available through Google Search. Each source answers a different class of question: your own policies, specialist external facts, and current public information respectively.

How does retrieval-augmented generation (RAG) improve model output?

RAG retrieves the most relevant passages from a knowledge source at query time and passes them to the model along with the user's question, so the model generates its answer from that retrieved material. This makes output more accurate, keeps it current as the knowledge base changes, enables citations users can verify, and sharply reduces hallucinations — all without retraining or fine-tuning the model.

When should a business use RAG APIs instead of pre-built RAG with Agent Search?

Use pre-built RAG with Agent Search when standard enterprise content needs grounding quickly with minimal engineering, since it manages the whole pipeline from ingestion to cited answers. Choose RAG APIs when the team needs custom control over retrieval stages — such as specialized document processing, embeddings, or ranking logic — and is willing to invest engineering effort to build its own pipeline.

What does temperature do in a gen AI model?

Temperature controls the randomness of token selection during generation. A low temperature makes the model strongly favor the most probable tokens, producing focused, consistent, repeatable output suited to factual and grounded tasks. A high temperature flattens the probability differences so less likely tokens are chosen more often, producing more varied and creative output suited to brainstorming and content generation. Lowering temperature reduces run-to-run variation, but it does not guarantee identical output on every run.

What is top-p or nucleus sampling?

Top-p, also called nucleus sampling, limits the pool of tokens the model can choose from at each step to the smallest set of likeliest tokens whose combined probability reaches the threshold p. With p = 0.7, for example, tokens are added in order of probability until their total reaches 0.7, and the rest are ignored. Because the pool grows when the model is uncertain and shrinks when one token dominates, top-p differs from top-k, which always keeps a fixed number of candidates, and from temperature, which reshapes the probabilities rather than cutting the pool.

Can grounding with Google Search answer questions from internal company documents?

No. Grounding with Google Search reaches only public web content, so internal or unpublished information such as private policies, draft reports or unreleased product roadmaps is invisible to it, however recent that information is. To ground answers in internal data, use retrieval-augmented generation over that data — pre-built RAG with Agent Search for a managed pipeline, or the RAG APIs for a custom one — and keep grounding with Google Search for fresh public information.

Which harm categories do Gemini safety settings cover?

Gemini safety settings let you set a blocking threshold separately for four harm categories: harassment, hate speech, sexually explicit content and dangerous content. Thresholds can be stricter for a consumer or children's app and more permissive for an internal content-moderation tool. Personal data and copyrighted text are not safety-setting categories: sensitive data is handled with services such as Sensitive Data Protection or Model Armor, and Gemini's recitation check addresses reproduced text.

Source

This lesson covers the "Techniques to improve gen AI model output" domain of the official GenAI Leader 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.

Spotted a mistake in this lesson?