Snowflake Gen AI Governance · Topic 4 of 15

Data Safety - Sensitive Data with AI_REDACT, Hallucinations and Bias

Protect sensitive data with AI_REDACT redact and detect modes, and reduce hallucinations and bias with grounding, low temperature and evaluation.

  • 4 min
In a nutshell
  • AI_REDACT has modes redact (default) and detect; categories are optional and default to all.
  • It needs SNOWFLAKE.CORTEX_USER and is billed on tokens.
  • Grounding with Cortex Search, citations, low temperature and evaluation are the hallucination methods.

What it is

Two risks sit next to each other in Gen AI governance. Sensitive data such as names, card numbers or ID numbers can leak into prompts, indexes or outputs. Hallucinations and bias are quality risks: the model invents facts or produces skewed answers.

Snowflake gives you a function for the first, AI_REDACT, and a set of design practices and evaluation tools for the second. No single switch removes hallucinations. The exam expects you to pick the right combination.

Raw textwith PIImasked byAI_REDACTredact or detectfeedsCortex Searchor AI_COMPLETEgrounded answerEvaluated withAI Observability

How it works

AI_REDACT

AI_REDACT finds personally identifiable information (PII) in text and either replaces it or reports where it is. Syntax:

AI_REDACT( <input> [, <categories> ] [, <return_error_details> ] [, <mode> ] )
ArgumentMeaning
inputVARCHAR text that may contain PII
categoriesOptional ARRAY of PII types; if omitted, all supported categories are redacted; an unsupported name causes an error
return_error_detailsOptional BOOLEAN; needs the session parameter AI_SQL_ERROR_HANDLING_USE_FAIL_ON_ERROR set to FALSE
moderedact (default) or detect, case-insensitive

Supported categories: NAME, EMAIL, PHONE_NUMBER, DATE_OF_BIRTH, GENDER, AGE, ADDRESS, NATIONAL_ID, PASSPORT, TAX_IDENTIFIER, PAYMENT_CARD_DATA, DRIVERS_LICENSE, IP_ADDRESS.

SELECT AI_REDACT('My name is John Smith and I live at twenty third street, San Francisco.');
-- My name is [NAME] and I live at [ADDRESS]

SELECT AI_REDACT(ticket_text, ['EMAIL','PHONE_NUMBER'], FALSE, 'detect') FROM tickets;
  • In redact mode the result is VARCHAR with placeholders such as [NAME].
  • In detect mode the result is an OBJECT with a spans array; each span has category, start, end and text.
  • A role needs the SNOWFLAKE.CORTEX_USER database role.
  • Billing is by input and output tokens, like other Cortex AI functions.
  • Input plus output is limited to 4,096 tokens and output to 1,024 tokens. Split longer text first, for example with SPLIT_TEXT_RECURSIVE_CHARACTER.
  • It works best on well-formed English and covers US PII, plus some UK and Canadian PII. Detection is best effort, so review the output.
Watch out

AI_REDACT is not a guarantee of compliance. Snowflake states detection is best effort and may miss PII, so keep a human or rule-based check for regulated data.

Where to apply redaction

Redact before the data reaches a place with wider access. Typical points are before building a Cortex Search index from support tickets, before sending text to AI_COMPLETE, and before sharing training or evaluation sets. Snowflake's native controls stay in force too: masking policies, row access policies and RBAC apply to the tables that feed the pipeline.

Reducing hallucinations

A hallucination is a fluent answer that is not supported by facts. Snowflake documents no setting that removes them, so the methods are design choices.

MethodHow it helps
Ground the answerRetrieve passages with Cortex Search and put them in the prompt (retrieval augmented generation)
Cite sourcesCortex Agents return citations to the search results used, so a reader can check
Keep temperature lowIn AI_COMPLETE, temperature defaults to 0, which keeps output stable
Constrain the formatStructured outputs make AI_COMPLETE follow a JSON schema; this controls shape, not truth
Give clear instructionsTell the model to answer only from the context and to say when it does not know
Measure itAI Observability scores groundedness, context relevance and answer relevance
Keep a human in the loopReview high risk answers

For structured data, Cortex Analyst reduces invention by generating SQL from a semantic view and running it against real tables, so numbers come from the data.

Reducing bias

Bias comes from training data and from your prompts and sources. Practical steps: test with representative datasets, compare runs of different prompts or models side by side, avoid prompts that ask the model to judge people, restrict the use case to tasks with human review, and write evaluation datasets with ground truth answers. Cortex Guard filters hateful output but does not remove subtle bias.

Exam tip

When two answers look right, prefer the one that grounds the model in your own governed data and measures the result, over one that only changes the wording of the prompt.

Common mistakes

Believing AI_REDACT is complete. It is best effort and limited to its supported categories and languages.

Passing very long text to AI_REDACT. Input and output together are capped at 4,096 tokens; chunk first.

Using detect mode and expecting masked text. Detect returns spans, not redacted text.

Treating Cortex Guard as a hallucination fix. It is a safety filter.

Relying on structured outputs for accuracy. They guarantee shape, not truth.

What to remember for the exam

  • AI_REDACT has modes redact (default) and detect; categories are optional and default to all.
  • It needs SNOWFLAKE.CORTEX_USER and is billed on tokens.
  • Grounding with Cortex Search, citations, low temperature and evaluation are the hallucination methods.
  • Groundedness, context relevance and answer relevance are the AI Observability metrics that target hallucination.
  • Bias is handled by testing, human review and evaluation, not by one parameter.

Check yourself

  • Which AI_REDACT mode returns the positions of PII without changing the text?

    The detect mode, which returns an OBJECT with a spans array.

  • Name a Snowflake-native way to ground an answer in company data.

    Retrieve passages with Cortex Search and pass them to the model, so the answer is based on governed content.

  • Does Cortex Guard reduce hallucinations?

    No. It filters unsafe or harmful responses, not factual errors.

Topic 4 of 15 in Snowflake Gen AI Governance

Test yourself on Snowflake Gen AI Governance

The full Snowflake GES-C02 question bank has 585 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Snowflake. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.