Private Inference for Sensitive RAG
Engineering

Private Inference for Sensitive RAG

Running the language model on your own servers covers one hop of a RAG pipeline; embeddings, reranking, logs and evaluation decide whether the data really stays inside.

Short answer

Private inference means running the models that read your documents and questions on infrastructure you control instead of a shared external API. For sensitive RAG it helps only if every stage stays inside that boundary: parsing, embeddings, the vector index, reranking, generation, logs and evaluation. Map that data path first, then decide between a self-hosted model and a regional managed deployment.

What does private inference mean for a RAG system?

Private inference means the models that read your documents and questions run on infrastructure you control, such as your own servers, a private cloud or an isolated tenancy, instead of a shared external API. For a sensitive RAG system, the point is that contracts, personnel files or case documents are not sent to a party you have not approved, and not processed in a country you have not approved.

The catch is that a RAG system has several data paths, not one. Documents are parsed and sometimes passed through OCR, cut into passages, turned into embeddings, stored in a vector index, retrieved, optionally reranked, inserted into a prompt together with the question, answered by a language model, and then written to logs, caches and evaluation tools. Running the language model privately covers one of those hops. If the embedding model, the reranker or the tracing tool is an external service, the same passages still leave. So the first task is not choosing a model; it is drawing the data path.

Which parts of a RAG pipeline send data where?

Use this matrix to map each stage. For every row, write down where the data is processed, where it is stored, for how long, and who can read it.

StageData that movesWhat to check
Parsing and OCRWhole documents, including scanned pagesIs a cloud document service used? Are intermediate files kept?
EmbeddingEvery passage at indexing time, every question at query timeWhere does the embedding model run? Are inputs logged?
Vector indexEmbeddings and the passage text stored next to themLocation, encryption, backups, permission filter
RerankingThe question and the top candidate passagesOften a separate API that is easy to overlook
GenerationQuestion, retrieved passages, system prompt, answerProcessing location, retention, abuse monitoring, stored conversations
Logs, caches, tracesPrompts, passages and answers in fullRetention rule, who can read them, external monitoring tools
EvaluationSample questions and answers sent to a judge modelWhether the judge is an external API

Do not treat embeddings as harmless numbers. OWASP's entry on vector and embedding weaknesses warns that attackers can invert embeddings and recover significant amounts of the source information, and recommends permission-aware vector stores. A private generation model with an exposed vector index protects very little.

Is a managed cloud endpoint ever enough?

Sometimes, and it depends on how the endpoint is deployed, not only on who provides it. Microsoft's page on data, privacy and security for models sold by Azure is a useful example of what to read. It states that prompts, completions and embeddings are not available to other customers or to the model provider and are not used to train foundation models without permission. It also states that for standard deployments prompts are processed within the customer-specified geography, while "Global" deployments may process them in any geography where the model is deployed and "DataZone" deployments anywhere within the data zone. Features that keep state, such as stored conversations and stored completions, keep data at rest in the resource; and the abuse-monitoring process may store flagged prompts for human review unless the customer has been approved for modified abuse monitoring.

For a Turkish organisation, the processing location is a legal question as well as a technical one. Article 9 of the personal data protection law (KVKK), amended with effect from 1 June 2024, allows transfers abroad on the basis of an adequacy decision, of appropriate safeguards such as standard contracts or binding corporate rules, or, in limited cases, of incidental transfers, as the authority's page on cross-border transfers summarises. If a managed endpoint processes personal data outside Türkiye, the transfer rules apply. Confirm the specific route with your legal adviser; the technical data-path matrix above is what they will need to see.

When do you actually need a private model?

RequirementTypical answer
A law, contract or classification forbids the data leaving your premises or networkPrivate inference for every stage, including embedding and reranking
Data may be processed by a provider, but only inside a given country or regionA regional managed deployment may fit; check the deployment type and every stage
The system must work offline or with very low latency on siteA local model, sized for the site's load
You need a model adapted to your domainEither route; adaptation does not by itself require self-hosting
"It feels safer"Write down the threat first; self-hosting adds operating risk of its own

How much hardware does a private model need?

Two things fill GPU memory: the model weights and the key-value (KV) cache that holds the attention state of every request being served. The weights are roughly the number of parameters times the bytes per parameter, so an 8-billion-parameter model at 16-bit precision needs about 16 GB before anything else. The KV cache grows with context length and with concurrency, and in RAG the context is long because retrieved passages are part of every prompt.

The PagedAttention paper behind vLLM gives a concrete reference: for the 13-billion-parameter OPT model, the KV cache of a single token takes about 800 KB (2 for key and value × 5,120 hidden size × 40 layers × 2 bytes), so one 2,048-token request can need up to 1.6 GB. Serving that model on a 40 GB A100, the authors report about 65 percent of memory going to weights and close to 30 percent to request state. Newer architectures can store considerably less per token, so compute the figure from your own model's configuration rather than reusing this one.

As a hypothetical sizing exercise, take that 800 KB-per-token reference, a RAG prompt of 6,000 tokens plus a 500-token answer, and 50 users waiting on answers at peak. Each request needs about 5 GB of KV cache, and 50 at once need more than 250 GB, far beyond one GPU. The usual levers are fewer and shorter retrieved passages, a model with a smaller per-token cache, a queue with an agreed waiting time, or more GPUs. Serving software matters too: the same paper reports 2 to 4 times higher throughput for vLLM than earlier systems at the same latency. vLLM's online serving documentation describes an HTTP server compatible with the OpenAI completions and chat APIs, with embedding and reranking endpoints as well, which makes it easier to run the same application against a private model and a managed one and compare them.

How do you compare a private model with a managed one?

Separate retrieval from generation first. Measure retrieval on a fixed question set: if the right passage is not retrieved, no generator can cite it. Then keep the passages, metadata and permission filters identical and change only the generation model. Compare on the same questions:

  • Grounding: share of claims supported by a retrieved passage, and correct citations.
  • Refusals: does the model say "not found" when the documents do not contain the answer?
  • Language: Turkish answers that read naturally and keep legal and technical terms intact.
  • Latency: the 95th-percentile response time at expected peak concurrency, not the average on an idle server.
  • Cost: per 1,000 questions, including GPUs that sit idle outside working hours and the people who operate them.

A smaller private model that meets the grounding and latency targets is a good outcome. One that misses them is not rescued by being private; revisit the architecture under the same data rules instead.

What else has to stay private besides the model?

Everything that stores prompts, passages or answers: application logs, traces, caches, crash reports, analytics and evaluation tools. Give each a retention period and a named group of readers. Test deletion end to end: remove a source document and confirm it disappears from the index, the cache and the stored traces. Keep the permission filter that decides which passages a user may retrieve; running on your own servers does not replace it. Finally, plan operations: who patches the serving stack, how a model update is tested before it replaces the current one, and how you roll back.

How should the inference servers themselves be isolated?

A model server is an HTTP service like any other, and it often holds the most sensitive text in the system. Make it reachable only from the RAG application, not from the wider network, and require authentication on every call. Block outbound internet access from the inference hosts so that telemetry, automatic updates or a misconfigured plugin cannot send prompts out; bring model and software updates in through a controlled path instead. Download model weights only from the publisher's official source, record their checksums, and store which model version produced each answer, so that a later question about an answer can be traced to the exact model that wrote it.

Common mistakes

  • Hosting the language model privately while embeddings, reranking or tracing go to external services.
  • Choosing a "Global" or multi-region deployment without checking where prompts are processed.
  • Sizing GPUs from model weights alone and ignoring the KV cache of long RAG prompts.
  • Comparing models with different retrieval settings, so the test measures retrieval rather than generation.
  • Keeping full prompts in logs with no retention rule or deletion test.

RAG systems that run entirely on your own servers with open-weight models, or in the cloud with the data flow and KVKK transfer rules agreed up front, are covered on our enterprise RAG and semantic search service page. For the wider choice between in-house and cloud AI, see our guide to on-prem and sovereign AI.

Key takeaways

  • Map every RAG stage, from OCR and embeddings to logs and evaluation, before choosing where the model runs.
  • Protect embeddings and the vector index as carefully as the source documents.
  • For managed endpoints, check the deployment type, stored-state features and abuse-monitoring retention, and apply KVKK transfer rules when data leaves Türkiye.
  • Size GPUs for the weights plus the KV cache of long RAG prompts at peak concurrency.
  • Compare models with identical retrieval on grounding, refusals, Turkish quality, 95th-percentile latency and cost per 1,000 questions.
  • Give logs, caches and traces a retention rule and test deletion end to end.

Frequently asked questions

Does running the LLM on-premises make a RAG system private?

Not on its own. Embeddings, reranking, OCR, logs and evaluation tools can each send the same passages elsewhere. Map every stage of the data path and keep each one inside the boundary your rules require.

Are embeddings sensitive data?

Yes. OWASP warns that embeddings can be inverted to recover significant parts of the source information, so the vector index needs the same access control, encryption and retention rules as the documents it was built from.

Can a managed cloud model be used for sensitive documents?

Sometimes. Check the deployment type, because global or multi-region deployments may process prompts outside the chosen geography, and check stored-conversation features and abuse-monitoring retention. If personal data is processed outside Türkiye, KVKK's cross-border transfer rules apply.

How much GPU memory does a private RAG model need?

Enough for the model weights plus the KV cache of every concurrent request. Weights are roughly parameters times bytes per parameter, about 16 GB for an 8-billion-parameter model at 16-bit; the KV cache grows with prompt length and concurrency, and long RAG prompts make it large. Compute it from your model's configuration and expected peak load.

Is a smaller private model good enough for RAG?

It can be, if it meets your grounding, refusal, language and latency targets on the same questions and retrieval settings as the alternative. Measure retrieval first; no model can cite a passage that was never retrieved.

All articles