What is RAG, and why is it hard on CPUs?

· 5 min read

Documents flowing into a processor chip under the title What is RAG

A language model only knows what it saw in training. It has never read your documents, your product manuals or last week’s meeting notes. RAG (retrieval-augmented generation) fixes that without retraining anything: before the model answers, the app finds the most relevant passages in your documents and hands them to the model together with the question.

It is the most practical way to make a private model useful at work. It also asks a lot from a CPU. Here is why.

How RAG works, step by step

RAG has two phases: preparing your documents once, and then using them for every question.

Preparing the documents (once per file)

  1. Extract the text. PDFs, Word files and web pages are turned into plain text.
  2. Split it into chunks. Each document is cut into short passages, a few hundred characters each, with a small overlap so that an idea split across a boundary stays whole somewhere.
  3. Embed each chunk. An embedding model turns every chunk into a vector, a list of numbers that captures its meaning. Passages about similar topics get similar vectors, even when they use different words.
  4. Store the vectors in an index, ready to search.

Answering a question (every time)

  1. Embed the question with the same embedding model.
  2. Retrieve. Find the chunks whose vectors are closest to the question’s vector, usually the top 3 to 5.
  3. Augment the prompt. Put those chunks into the prompt: “Using these passages, answer the question…”
  4. Generate. The language model reads everything and writes the answer, ideally quoting where it came from.

The model does not memorize your documents. It reads the few passages it needs, right when it needs them, so new or changed files count at once.

Reranking: a second, closer look

Vector search is fast, but rough. It compares two lists of numbers that were made separately, one for the question and one for each passage, so it finds passages about the same topic, not always the ones that answer the question. Ask “How long is the warranty on the X200?” and a passage about the X100’s warranty may score just as high as the right one.

A reranker fixes that with one extra step between retrieving and augmenting:

  1. Shortlist. Vector search picks a wider set, say the top 20 passages instead of 4.
  2. Rerank. A reranker model reads the question together with each passage and gives it a relevance score from 0 to 1. Reading both at once lets it notice details, like the model number, that vector search can miss.
  3. Keep the best. Only the top few, by the new score, go into the prompt.

The result is better answers without a longer prompt. A reranker is a small model that scores instead of writing, but it still reads every shortlisted passage, so it adds a short wait before the answer starts. On a CPU that is usually worth it: a few seconds spent picking the right 4 passages beats a minute spent reading 10 mediocre ones.

Why RAG is hard on a CPU

When a model runs, there are two kinds of work. Writing the reply is limited by memory speed, and a modern CPU handles it well. Reading the prompt is pure arithmetic, and that is where a CPU is far behind a GPU. RAG makes the reading part much bigger.

What helps on a CPU

How pAIring and Matricxon handle it

pAIring has a built-in knowledge base. Each user can add private documents, which are split, embedded in the background and searched on every question. By default it retrieves 4 short passages, and each person can change that number in Settings > Knowledge. With Matricxon as the engine, an admin can add a reranker in one click (Settings > Models > Reranker models, Qwen3 Reranker 0.6B): pAIring then shortlists 20 passages and the reranker keeps the best ones. Matricxon checks its reranker scores against llama.cpp’s own. It also keeps a cache for each conversation (and can save it to disk), so a follow-up question reads only what is new, not the whole chat again.

RAG is the simplest way to give a private model real knowledge of your work. On a CPU it works well too, as long as you keep the retrieved context lean.

← All posts