ZTDS FRAMEWORK MAPPINGS v1.0
RAG · VECTOR STORES · PROMPT ASSEMBLY

RAG Pipeline PII Sanitization: Three Places To Intervene

A retrieval-augmented generation pipeline moves personal data through ingestion, embedding, storage, retrieval, and prompt assembly before any model sees it. Each stage is an opportunity to exclude identifiers. This page lists where a deterministic sanitization step reduces exposure and where it does not.

Summary

Source documents often contain identifiers that the retrieval task does not need. If they are embedded as-is, the vector store becomes a second copy of sensitive data, and retrieved chunks carry those identifiers into every prompt.

Tokenizing at ingestion keeps the vector store free of raw identifiers. Tokenizing at prompt assembly protects the case where the store already holds raw text. Both use the same reversible surrogate contract.

Scope notice. This page maps a technical control to a published framework as a Statutory Risk Minimization and Defense-in-Depth measure. It is not legal advice, not a certification by the framework owner, and not a statement that any regulation is fully satisfied. Consult qualified counsel for jurisdiction-specific determinations.

Pipeline Stage Mapping

StageExposureSanitization option
IngestionRaw documents loaded for chunking and embedding.Tokenize before chunking so stored chunks and embeddings derive from surrogates.
Vector storeEmbeddings and chunk text persist in a database with its own access controls.Store only surrogate text; keep the mapping outside the store.
RetrievalTop results are returned to the application.Results already carry surrogates when ingestion was sanitized.
Prompt assemblyRetrieved context and the user question are joined and sent to a provider.Tokenize the assembled prompt as a final gate before egress.
Response handlingThe model answer references surrogates.Restore surrogates locally for the authorized reader.

How ZTDS Applies

Recommended order of adoption:

  • Add the prompt-assembly gate first because it protects every existing pipeline immediately.
  • Then sanitize at ingestion for new collections to keep raw identifiers out of the vector store.
  • Keep one mapping scope per user session or per tenant and never share it across tenants.
  • Test with a scanner run that confirms no cleartext identifiers appear in outbound requests.

What This Control Does Not Cover

  • Tokenizing before embedding can change retrieval quality for queries that rely on the removed values; measure it on your corpus.
  • It does not enforce document-level access control. That remains the job of the retrieval layer.
  • It does not address poisoning of the vector store or injection through retrieved text.
  • Embeddings of text that still contains free-text context can carry indirect information.

Frequently Asked Questions

Should PII be removed before or after embedding?

Before, when possible. Tokenizing at ingestion keeps raw identifiers out of both the stored chunks and the embeddings. A gate at prompt assembly is still useful as a final check.

Does sanitizing before embedding hurt retrieval?

It can for queries that depend on the removed values, for example searching by a specific name. Measure retrieval quality on your own corpus and decide per collection.

Can the token map be shared across users?

It should not be. Scope the mapping to a session or tenant and keep it in volatile memory so one user can never restore another user values.