Skip to content
[nonimo]
EN
Try it free

Home / Blog

GDPR · RAG

RAG and personal data: what the GDPR expects at each step

· 8 min read

A Dublin letting agent builds an internal assistant over its tenancy files. We follow every copy of tenants' data from ingestion to answer.

The Nonimo teamData protection and AI integration, for engineering teams and DPOs.

In this article
  1. Where does personal data end up in a RAG pipeline?
  2. Should you redact when indexing or when calling the model?
  3. How do you tag chunks so you can delete them later?
  4. Are embeddings personal data under the GDPR?
  5. What does Article 25 expect from a RAG design?
  6. How do you mask the prompt before it reaches the chat model?
  7. What should the DPIA and the record of processing say?
  8. RAG and personal data: checklist

Quick answer

In a RAG system, personal data is copied into chunks, vectors, metadata, caches and logs, and each copy falls under the GDPR. Index only what the assistant needs, tag each chunk with its document and people so you can delete it, and mask names and identifiers in the prompt before it reaches the chat model.

Brackenridge Lettings is a fictional letting agent in Dublin with around 4,000 tenancies on its books. Its property managers spend their mornings answering the same questions: when the rent review is due, who reported the boiler fault, what the lease says about pets.

The IT lead, Ciarán, wants an internal assistant that answers those questions from the firm's own documents. Retrieval-augmented generation (RAG) is the obvious design. The firm's DPO, Gráinne, has one question before anything is built: where will tenants' data end up?

This article follows that project from ingestion to answer. The law is the GDPR together with the Data Protection Act 2018 (Ireland). A UK firm would apply the UK GDPR and the Data Protection Act 2018 (UK), which use the same article numbers for everything discussed here.

Where does personal data end up in a RAG pipeline?

A RAG pipeline takes source documents, splits them into chunks, turns each chunk into an embedding and stores it in a vector database. At question time, a retriever finds the closest chunks and a prompt builder inserts them into the request to a chat model.

Every one of those steps can make a copy. Brackenridge's tenancy agreements contain names, phone numbers, PPS numbers on older forms and IBANs for rent mandates.

After ingestion, those values sit in the source store, the chunk text, the chunk metadata and very often in the vector database itself, because most vector stores keep the chunk text next to the vector.

Copies of personal data in a RAG pipeline, and where the prompt is masked Source documents Chunks Embeddings Vector store leases, emails text + metadata vectors vectors + chunk text Staff question Retriever Prompt builder Chat model [PERSON_1] masked here Answer with real names Also copied: cache, logs, evaluation sets, backups
Each box that stores text is a copy of personal data. The chat model only needs to see labels.

Gráinne asked Ciarán to map every copy before choosing a vector database. Their map is below, and it works as a template for any RAG project.

WhereWhat it holdsRetention at BrackenridgeWhat Brackenridge does
Source storeOriginal leases, emails, ticketsRetention scheduleGives each document a source ID
Chunk textFragments of the sourcesSame as sourceStrips fields the assistant never needs
Chunk metadataSource ID, tenancy ID, datesSame as sourceAdds internal subject IDs to every chunk
VectorsNumbers derived from chunk textSame as chunkDeletes them together with their chunk
Prompt to the chat modelQuestion plus retrieved chunksNot stored by BrackenridgeMasks names and identifiers before it leaves
Cache and logsQuestions, answers, retrieved IDs30 daysKeeps full prompts out of logs
Evaluation setsSample questions and answersReviewed quarterlyBuilds them from invented tenants

Should you redact when indexing or when calling the model?

Both, for different reasons. Indexing decides what you keep; the model call decides what you send out.

Brackenridge applies minimisation at the first moment and masking at the second, and keeps the two jobs apart in its code.

At indexing: minimise

Article 5(1)(c) requires data to be adequate, relevant and limited to what is necessary. Brackenridge's assistant never needs a tenant's PPS number or the IBAN on a rent mandate, so those fields are removed before chunking. If the value is not in the index, it cannot be retrieved, cached or logged.

Names are different. Property managers search by tenant name ("what did Aoife Brennan report last month?"), so names stay in Brackenridge's own index, inside its own systems and access controls.

At the model call: mask

The chat model does not need to know that the tenant is Aoife Brennan to summarise a maintenance ticket. It needs to know that one person reported a leak and another replied.

So the prompt is where masking goes: names and identifiers are swapped for labels, and the real values go back into the answer.

How do you tag chunks so you can delete them later?

Deletion is the part teams forget until a tenant asks for it. If a chunk does not record which document and which people it came from, the only way to erase someone is to re-index everything.

Ciarán's chunker attaches a source ID and a list of subject IDs to every chunk. The subject IDs are Brackenridge's own internal tenant references, never the names.

from dataclasses import dataclass, field

@dataclass
class Chunk:
    text: str
    source_id: str                     # e.g. "lease-EXAMPLE-0001"
    position: int                      # order within the document
    subject_ids: list[str] = field(default_factory=list)  # e.g. ["T-00001"]

    @property
    def chunk_id(self) -> str:
        return f"{self.source_id}:{self.position}"

def chunk_document(text: str, source_id: str, subject_ids: list[str],
                   size: int = 800, overlap: int = 100) -> list[Chunk]:
    chunks, start = [], 0
    while start < len(text):
        piece = text[start:start + size]
        chunks.append(Chunk(piece, source_id, len(chunks), list(subject_ids)))
        start += size - overlap
    return chunks

With that metadata in place, erasing a tenant is a filtered delete in the vector store plus the same delete in the chunk table.

Most vector databases support deletion by a metadata filter; check how yours handles it and whether deleted items linger in snapshots. The full process is in our article on subject access and erasure in LLM apps.

Are embeddings personal data under the GDPR?

Article 4(1) defines personal data as any information relating to an identified or identifiable person. Recital 26 asks whether identification is reasonably likely, taking into account the means someone could use.

An embedding is a list of numbers, but it is stored with a chunk ID that points back to a lease, and often with the chunk text itself.

Whether anyone could work back from the numbers to the text depends on the model and on who holds the vectors, and that is not something you can promise in a DPIA.

The safe design choice is to treat vectors as personal data whenever they can be linked to their source, and to delete them with the chunk they came from.

What does Article 25 expect from a RAG design?

Article 25 requires data protection by design and by default, and it names pseudonymisation as an example of an appropriate technical measure. Article 32(1)(a) names it again among the security measures.

For a RAG system, "by default" has a practical meaning. The pipeline should collect the minimum when it indexes, keep it for the shortest sensible time, and send the chat model only what the answer needs.

Who holds the key

The EDPB's Guidelines 01/2025 on pseudonymisation, adopted for public consultation in January 2025, explain that pseudonymisation only protects people if the additional information is kept separate and protected.

The EDPB's earlier Recommendations 01/2020 on supplementary measures for transfers give a concrete picture of that information: a table that puts each pseudonym next to the value it replaced. In a RAG system, that table maps [PERSON_1] back to the tenant's name.

The Court of Justice of the European Union took a similar line in Case C-413/23 P (EDPS v SRB, 4 September 2025). That case was decided under Regulation (EU) 2018/1725, which covers the EU institutions, with the same concept of personal data as the GDPR, and it does not bind UK courts.

PartyHolds the label table?Masked prompt is personal data?
BrackenridgeYesYes
Model provider, with no reasonable means to re-identifyNoNot necessarily (C-413/23 P)

In a RAG design, the party holding the table should be you, not the model provider.

How do you mask the prompt before it reaches the chat model?

You can build the masking layer yourself, or put a gateway between your application and the provider. Brackenridge chose the second option so that the RAG code stayed as it was.

The Nonimo Gateway sits between the company's applications and the AI provider. Before each chat request leaves, it replaces personal data with labels such as [PERSON_1] and [IBAN_1], masking the retrieved chunks along with the question, and puts each real value back in the answer.

Two settings in the client

It works with the OpenAI API (chat completions and responses) and the Anthropic API (messages). Ciarán changed the base URL and the key, and kept the official SDK, the model and the prompt builder.

import os
from openai import OpenAI

# Same SDK, same model: only the base URL and key change.
client = OpenAI(
    base_url=os.environ["GATEWAY_BASE_URL"],
    api_key=os.environ["GATEWAY_API_KEY"],
)

def answer(question: str, chunks: list[str]) -> str:
    context = "\n\n".join(chunks)
    reply = client.chat.completions.create(
        model=os.environ["CHAT_MODEL"],
        messages=[
            {"role": "system", "content": "Answer only from the context."},
            {"role": "user", "content": f"{context}\n\nQuestion: {question}"},
        ],
    )
    return reply.choices[0].message.content

For each type of data, Brackenridge chose what the Gateway does: mask it, stop the request, or only warn and count. Its building names went into the dashboard as custom terms and are masked the same way.

Embeddings and the vector store stay in Brackenridge's own design. If it computed embeddings through a provider's API, that call would be a second exit to plan for in the DPIA.

For the EU, each customer's Gateway runs on its own confidential machine in Microsoft Azure in Ireland. It only starts published versions of the Gateway, and what it processes is not read by Nonimo staff or Microsoft staff.

What should the DPIA and the record of processing say?

An assistant that reads 4,000 tenancy files is a good candidate for a DPIA under Article 35, and the processing belongs in the Article 30 record. Gráinne's draft lists each copy from the map above, its retention period and who can reach it.

The provider relationship needs its own line. With masking at the model call, the provider receives labels rather than tenants' names, and Brackenridge keeps the link between the two.

Gráinne attached the Gateway's monthly report, with figures by data type and no text, and the hosting and roles from the security page.

Before go-live, the team tested the masking with invented tenants and known identifiers. Our guide to testing PII redaction before go-live walks through that test set.

RAG and personal data: checklist

  • Every place that stores chunk text, vectors, prompts or answers is on the data map.
  • Fields the assistant never needs are removed before chunking.
  • Each chunk carries a source ID and internal subject IDs.
  • You can delete one person's chunks and vectors with a single filtered call.
  • Prompts to the chat model carry labels instead of names and identifiers.
  • Logs record IDs and counts, not full prompts.
  • Evaluation sets are built from invented people.
  • The DPIA and the Article 30 record describe each copy and its retention.

If you want to try the masking on your own RAG prompts, the trial and the plans are on the pricing page.

Common questions

Do I need to delete the vectors as well as the chunk text?

Yes, in practice. Treat vectors as personal data whenever they can be linked back to their source, and delete them in the same operation as the chunk they came from, so that no stray vector still points to an erased tenant.

Should I strip names before indexing?

Only if the assistant never needs them. Staff often search by name, so names can stay in your own index under your access controls and be masked in the prompt sent to the chat model. Identifiers nobody searches for can go before chunking.

Are embeddings personal data under the GDPR?

Plan as if they are whenever they can be linked to a person. Embeddings usually sit next to a chunk ID or the chunk text, and Recital 26 asks whether identification is reasonably likely with the means someone could use.

How do I erase one person from a RAG index?

Tag every chunk at indexing with a source ID and the internal IDs of the people it mentions. Erasure then becomes a filtered delete in the vector store and the chunk table, rather than a full re-index. Check how your snapshots treat deleted items.

Is a RAG assistant over customer files a case for a DPIA?

Often, yes. Large volumes of customer records read by a new technology are a strong reason to run a DPIA under Article 35 before go-live. The processing also belongs in your Article 30 record, with each copy and its retention period.

What should a RAG system keep in its logs?

Chunk IDs, timings and counts are usually enough to debug retrieval. Keeping full prompts and answers out of the logs means one fewer copy of customers' data to search, and a short retention period is easier to justify under Article 5(1)(e).

Does the GDPR require pseudonymisation in a RAG system?

Articles 25 and 32(1)(a) give pseudonymisation as an example of an appropriate measure rather than a fixed requirement. The EDPB's Guidelines 01/2025 add that it only protects people when the additional information, such as a label table, is kept separate.

Does the Nonimo Gateway change my vector database?

No. Your embeddings and vector store stay as you designed them. The Gateway masks the request to the chat model, retrieved chunks included, and puts the real values back in the answer. The security page explains where it runs.

Sources

  1. Regulation (EU) 2016/679 (General Data Protection Regulation)
  2. Data Protection Act 2018 (Ireland)
  3. EDPB Guidelines 01/2025 on Pseudonymisation (version for public consultation)
  4. EDPB Recommendations 01/2020 on measures that supplement transfer tools, version 2.0
  5. Court of Justice of the EU, Case C-413/23 P, EDPS v SRB (4 September 2025)
  6. ICO, Guidance on AI and data protection

More articles

Nonimo Gateway redacts personal data before your request reaches the AI provider and puts it back in the reply.

See how it works
€0 today10 days free · cancel any time

Try Nonimo Gateway

Try it free on real requests from your own applications.

Then €290/month inc. VAT, only if you carry on.

We’ll use your email to send you the trial and remind you before it ends. Privacy.

Questions? Email [email protected]

Already have a Gateway? Go to Your Gateway