stefandango.dev

AI

Your embedding model sees more than your LLM

The model that writes your answers sees five passages. A hosted embedding model sees every document you have.

Say you want an AI assistant that answers questions from your company's internal documents: contracts, case files, HR notes. The documents are sensitive, so you keep them on your own servers. The search runs there too. Only the last step goes out: the few passages that match a question are sent to a hosted language model, which writes the answer. You picked a provider under EU law, and you can filter or redact those passages before they leave.

That's a sensible setup, and a lot of these systems are built this way. Security reviews focus on that one outgoing call: where the model is hosted, under whose law, and what goes into the prompt.

But there's usually a second outgoing call that nobody draws. Before a document can be searched, an embedding model has to turn it into numbers. If that model is a hosted API -- and in many of the best-known tutorials it is -- every document you own is sent to that provider. Not five passages per question. All of it.

In short:

  • The problem: a hosted embedding API gets every document when you build the search index, and every question when someone searches. It sees far more than the model that writes the answers.
  • Why "it's only numbers" doesn't help: researchers have shown that embeddings give away much of what the text said, including names.
  • What to do: run the embedding model yourself, or use an EU provider and say clearly that your documents leave your servers.

Diagram: every document and every question go to the embedding provider; only the question and five chunks go to the language model.

This post sits beside a series I've written on EU AI jurisdiction: why "EU region" is about geography, not law, the options between US cloud and fully on-premises, and the answer-writing step as running code. You don't need to have read them.

How the search part works

An assistant that answers from your own documents (usually called RAG, retrieval-augmented generation) works in three steps:

  1. Prepare the documents. Each document is cut into small pieces, called chunks. An embedding model turns each chunk into a list of a few hundred numbers, and chunks with similar meaning get similar numbers. The numbers are saved in a search index.
  2. Search. A question is turned into numbers the same way, and the index finds the chunks whose numbers are closest.
  3. Answer. A language model reads the question and those few chunks, and writes the answer.

"Keep the documents on our own servers" sounds like one promise, but it's really three: where the documents are stored, where the search runs, and where the embedding model runs. The first two are easy. Storage is a database you run, and search is a query against it. The embedding model is the one that slips, because it's a model, and teams are used to renting models. A hosted embedding API is cheap, well documented and one line of configuration away. As of November 2026, LlamaIndex's starter example falls back to OpenAI's embedding model if you don't choose one, and the RAG tutorials from LangChain and Microsoft's .NET docs both start from a hosted one -- a sensible default for a tutorial, though tutorial code tends to end up in production. (Haystack's first RAG tutorial is the exception: it runs a small model locally -- the same one I use.) And nothing on the architecture diagram changes when you use one. The index is still inside, and the search still never touches the internet.

What changes is where your documents go. If the embedding model is hosted in the US, it doesn't help that the answering model is under EU law. Every document has already been through a US provider.

What gets sent, and how often

Put the calls side by side and look at what each one sends.

Call When it happens What it sends How much of your documents
Embedding, building the index Every time a document is added, changed or re-indexed Every chunk, word for word All of them, again on every re-index
Embedding, a question Every question The question No documents, just the question
Search Every question Numbers in, the closest chunks back Stays on your servers
Answer Every question The question, plus the few chunks the search found A small slice per question

The answer call is the one people worry about, and it sends the least. Each question sends a handful of passages -- five, ten, whatever your search returns -- and nothing else. Over months that adds up to a lot of text, but it's text that was picked: relevant to a question someone actually asked, and small enough to check.

The embedding call has no such filter. A document can only be found if it has been embedded, so in a typical setup, every document you choose to index goes through the embedding model: the contract nobody will ever ask about, the HR note saved in the wrong folder, the draft that should have been deleted. Whether a document is relevant never comes into it.

It's also the call nobody watches. The answer call happens on every question, in every demo. Building the index is a background job that runs once at setup and then on a schedule, and it costs so little that nobody reads that line of the invoice.

And it doesn't happen just once. Every time you change how documents are cut up or embedded, the whole collection has to be embedded again, and those changes are routine: a better chunk size, a new model, a dependency update. My own index was rebuilt from scratch twice in eleven days this October. The first time, on the 2nd, came from a small deploy that only changed which notes get indexed. Its deploy steps included forcing a full re-index, which it turned out not to need. The second, on the 13th, was on purpose, for a change to how chunks are cut. My embedding model runs on my own hardware, so nothing left either time. With a hosted one, both rebuilds would have sent every document out again -- and the first would have done it as a routine deploy step that nobody thought of as sending anything.

Questions matter too, for a different reason. A question is often the most sensitive text in the whole exchange, because it shows what someone is looking for. "Has this client been flagged before?" says more than any single document it finds. The answer call sends the question as well, so a hosted embedding model doesn't create this risk -- it doubles it, by sending every question to a second provider.

The last difference matters most in practice. The tools that make the answer call safe enough -- choosing which chunks may leave, removing names before they go -- don't work for embeddings. You can remove names from a passage before it goes into a prompt and still get a good answer. You can't remove names from a document before embedding it, because then nobody can search for those names, and searching is the whole point. You can trim what goes into a prompt. You can't trim what goes to the embedding model: if it's hosted, it gets every chunk you index.

"It's only numbers"

A common reply is that embeddings aren't the text. The provider gets a chunk, sends back a list of numbers, and keeps nothing. Your index holds only numbers, and nobody can read those.

There are two problems with that.

First, the provider doesn't get numbers. It gets the text. Every chunk goes out word for word, and the numbers come back after. Whatever happens to the numbers later, the provider has already seen everything. That's the main problem with a hosted embedding model, and nothing below changes it.

A zero-retention agreement doesn't change it either. It's worth having: the provider promises to process the text and keep nothing. But the provider still handles every document, under whatever law applies to it. The promise covers what happens afterwards. The law decides who can force access while it's happening. The first post in the series explains why a contract can't settle that when the provider is under US law.

Second, the numbers aren't as anonymous as they look. Most search indexes store each chunk's text right next to its numbers anyway -- that's how search results come back as readable text. Mine does too. But some setups keep only the numbers, and some vendors offer to hold "just the vectors". For those, the question is how much the numbers give away.

More than you'd hope. In 2023, researchers at Cornell showed that embeddings of short passages -- a sentence or two -- can usually be turned back into the original text, word for word (Text Embeddings Reveal (Almost) As Much As Text, EMNLP 2023). On short clinical notes containing names, they recovered 89% of the full names. Longer text is harder: in a separate test at 128 tokens, only 8% came back exactly, though most of the words still did. Nobody has shown the same for chunks the size most systems use.

The attacks are getting cheaper, though not yet more exact. The 2023 method had to train a separate model for each embedding model and query it many times. A 2024 attack needs no queries to the target model, and a 2025 preprint from the Cornell group needs no per-model training.

So embeddings leak a lot of what the text said: nearly all of it for short text, the gist and many of the words for longer text. For data protection, that's enough. A leak doesn't have to be word for word to expose a name or a diagnosis. Under EU data protection law, what counts is whether whoever holds the data could reasonably identify the people in it. The research shows that someone with the embeddings and the right tools can often recover names and other details. The rule: if the text was personal data, treat its embedding as personal data too. In practice:

  • Protect your search index like your documents: same access controls, same backups, same rules about where it's hosted.
  • "We only store vectors" is not a privacy argument -- not for your index, and not for a vendor's.

Where the index itself is hosted is its own question, for another post. It's the same argument, one step further along.

You can't keep half of it local

Questions have to be embedded by the same model that embedded the documents. Two different embedding models generally produce numbers that can't be compared, so matching a question from one model against documents from another gives you noise. That rules out the compromise most people think of first: keep the sensitive documents on a local model and send the rest to a hosted one -- at least within one index. You can run two indexes with two models, but then every question has to be embedded twice, and one copy goes to the hosted provider. Whichever embedding model you choose, you've chosen it for all your documents and every question anyone asks.

In my own system this is a design rule, not luck: questions are embedded by the same service that built the index, so both sets of numbers come from exactly the same model by design, not by checking afterwards.

The same fact makes the choice hard to undo. Numbers from one model mean nothing to another, so switching models means embedding everything again. If the model is hosted and the provider retires it, that happens on the provider's schedule, not yours. And if you switch providers, every document has to be sent again, this time to the new one. How hard it is to leave a provider is a sovereignty question of its own, separate from which law applies, and I've written about it before.

What to use instead

For sensitive documents, there are three ways to keep the embedding model on your own servers, or at least under a law you chose. None of them is free.

A small model on hardware you already have. Small embedding models run fine on an ordinary CPU. Mine turns each chunk into 384 numbers and rebuilds my whole index -- about 3,900 chunks -- on a Raspberry Pi in a little over seven minutes. The cost is quality, and the next section shows exactly how much.

A larger open model on your own GPU. Two of the three EU-hosted embedding models below are open weights, so you can run the same model on a workstation in your own building. Both come from BAAI, a research lab in Beijing. bge-m3 is MIT-licensed. bge-multilingual-gemma2 is built on Google's Gemma 2 and comes with Google's Gemma terms, which add use restrictions. Running either locally sends nothing to anyone, but where a model comes from is a question of its own -- the second post in the series covers it. You get a model that reads longer chunks and matches meaning better. You pay for the hardware, and for running one more service. The cost moves from a monthly invoice to a hardware purchase, which is usually where a regulated organisation would rather have it.

An EU-hosted embedding service. As of October 2026, Mistral offers mistral-embed, Scaleway offers bge-multilingual-gemma2, and OVHcloud offers bge-m3. The last reads chunks of up to 8,192 tokens -- 32 times what mine can. This is a legitimate choice, and for many organisations the sensible one. But be honest about what it means: every document leaves your servers, to a provider under EU law. Check where the processing actually happens, too -- an EU company doesn't always process everything inside the EU. That's a different promise from "embeddings stay on our servers", and whoever describes the system -- to a security review, a customer or a regulator -- should know which one they're making. Provider catalogues change, so check the one you depend on.

Or a hosted embedding model, on purpose. For public material -- documentation, product manuals, published policies, anything you'd happily put on your own website -- none of this matters, and a hosted model is the cheapest good option. The risk is only worth managing when the documents are something you'd mind someone else reading. The catch is that a collection of documents is only as public as its most sensitive document, and collections grow. The index built for the product manuals is the one someone adds the support tickets to a year later.

What this costs in my own system

My own system is a small version of this setup: a service that answers questions about my notes. The documents, the index and the search run on a Raspberry Pi that's only reachable over a private network. The embedding model runs there too -- all-MiniLM-L6-v2, a small open model -- and questions are embedded by the same service. The only call that leaves is the one that writes the answer, to a hosted model under EU law.

It isn't free. I know what it costs because every change to chunking or embedding goes through a retrieval test before it ships.

The model only reads the start of each chunk. It reads 256 tokens (a token is roughly a word, or part of one) and ignores the rest. My code used to cut documents by character count, so a fifth of the chunks were losing their endings -- often the part with the answer, like the reasoning at the end of a decision record. This October I rebuilt it to cut by tokens instead, and long table rows are now embedded in overlapping pieces. That's real engineering work, spent only to fit a small model.

It matches meaning weakly. It's small and English-only, and it shows. In November I asked five questions twice: once in the note's own words, once in different words. Worded like the note, the right note came first every time, with a similarity score around 0.8 (1.0 would be a perfect match). Reworded, the score fell to around 0.45, and the right note came first only twice. It was always in the top five, but a system that only trusted the top result would have missed it three times out of five. It's a small, informal test on my own notes, not a benchmark. Some answers still get missed even when they have a chunk of their own, which points at the model, not the chunking. A better model is a decision I haven't made yet. It would mean embedding everything again, rebuilding the index for a model that produces a different number of values per chunk, and re-pinning every version on the embedding path.

None of that is a reason to send my documents out. It's the price of not doing so, and I'd rather write it down than pretend the local option is just as good. For a larger organisation the sums shift towards the second option above: the same idea, on hardware that removes most of these costs.

Local isn't the same as offline

One more lesson from my own system. This one isn't a data leak -- no text left my network. It's about a dependency I didn't know I had.

The embedding library downloaded the model's files from Hugging Face, a site run by a US company for sharing models, and checked for a newer version every time the service started. Between 27 and 30 September, the people who maintain the model changed its tokenizer settings. The model itself stayed byte-for-byte the same, but the amount of text it reads went from 128 tokens to 256. On 2 October a routine container rebuild picked up the new settings, the index was rebuilt, and the numbers for every chunk longer than 128 tokens changed. One 197-token chunk ended up at a cosine similarity of 0.908 to its old self (1.0 would mean identical): the same text, noticeably different numbers.

The change happened to be an improvement. Until then the index had only read the first 128 tokens of each chunk, and 56% of chunks had been cut short. But nobody decided it, and nothing announced it. My retrieval test caught it because scores moved on notes nobody had edited. The next silent change might not be an improvement.

The fix was pinning: a fixed version of every package, the base image by its digest, and the model at a specific version stored in a local cache, with the library told never to download anything. If the cache goes missing, the service now fails at startup instead of quietly fetching whatever is newest. The pipeline doesn't contact Hugging Face at all any more.

The general lesson: a model you host yourself is still someone else's work, downloaded from somewhere. "Local" only means something if the model is pinned and works offline. Otherwise it means whatever the upstream project published this morning.

What actually matters

Your documents are only as safe as the least safe place you send them -- not as safe as the model that writes the answers. To check your own system:

  • List every call that sends document text, not just the one that runs when someone asks a question. Import jobs, re-index scripts and backfills all count.
  • For each call, write down where it runs and which country's law applies. That list is your real setup, whatever the diagram shows.
  • Protect the search index like the documents themselves: same access controls, backups and hosting rules.
  • Pin local models, and stop them downloading anything while they run.
  • Be clear about which setup you have: "embeddings stay on our servers", or "embeddings go to a named provider under EU law". Both can be defended. Only the first matches the diagram most people draw.

If you've checked your own systems and found the arrow somewhere unexpected, I'd like to hear where. My email's in the footer.