AIForum.

How to Build a RAG Pipeline with WordPress Content and a Local Model

On this page

THE SHORT ANSWER

A WordPress RAG pipeline turns your published posts into a searchable index that a local language model reads before answering. Two documented reference implementations exist: a script-per-step demo that defaults to open-source models and can run on CPU, and a fully local Docker stack chaining WordPress export, a vector document database, Ollama, and a chat interface. This guide covers the four pipeline stages, the hardware involved, verification checks, and the limits of the available evidence.
Quick facts

A WordPress RAG pipeline turns your published posts and pages into a searchable index that a local language model reads before it answers. The pipeline has four stages — export, chunk and embed, retrieve, generate — and two documented reference implementations show how to build it: a small script-per-step demo that defaults to open-source models and can run on CPU, and a fully local Docker stack that chains WordPress export, a vector-capable document database, Ollama, and a chat interface. This guide walks through both, states the hardware involved, and flags where the evidence stops.

It is written for technically curious beginners and intermediate practitioners who already run a WordPress site and want answers grounded in their own content without sending that content to a hosted API.

What “RAG with WordPress content” actually means

Retrieval-augmented generation combines two components: a retrieval system and a generative language model. The retrieval system queries documents relevant to a user’s question from a data store — for example, a collection of blog posts — and the retrieved documents are then fed into the language model, which produces an informed response. The main benefit is that the AI system can extend beyond its training data without fine-tuning or retraining, because data can be added to and updated in the store dynamically. Query results can include not just the model’s text but also the relevant source documents. [1]

The WordPress-specific part is the ingest. WordPress keeps content in a database as HTML mixed with blocks, shortcodes, and metadata. A language model cannot retrieve from that directly. You need plain-text chunks, an embedding vector per chunk, and metadata — post ID, URL, title, publication date — so the retriever can return something a reader can verify.

Two terms are easy to confuse. Embedding is the numeric representation of a chunk used for similarity search; generation is the model writing the answer. A RAG pipeline needs both, and they can be different models running on the same local server.

Choose an architecture before you install anything

There are two documented routes, and they answer different questions.

Route A — the script-based demo. The project iamcam/ai-wordpress-rag-demo is a small demonstration of how to integrate WordPress blog entries into queries for a RAG-based language model. Its premise is that a series of scripts perform specific actions from the command line, and each script is self-contained so that each action can be demonstrated in its own context. By default the scripts use free and open-source libraries and models, with an option to use OpenAI’s LLMs if you have access. The README states the example should run on CPU if you do not have a compatible GPU, though results may vary. [1]

Route B — a full local stack. The MDDB “Build a WordPress AI Agent” guide describes a five-component stack that runs entirely on one machine with no cloud and no API fees: WordPress holds the content; wpexportjson exports content to Markdown via the WordPress REST API; mddbd is a Markdown document database that stores content plus vector embeddings; Ollama runs the LLM and embedding models locally; and Open WebUI provides the chat interface. [2]

Route A is better for understanding each stage. Route B is better if you want a working chatbot with a user interface at the end.

Prerequisites and hardware

The MDDB guide publishes the following requirements for its stack. Treat them as the guide’s recommendation for that specific architecture, not a universal minimum. [2]

ResourceMinimumRecommended
RAM16 GB32 GB
CPU4 cores8+ cores
GPUNone (CPU mode)NVIDIA 8 GB+ VRAM (RTX 3060 or above)
Disk20 GB free50 GB SSD
OSLinux / macOS / WSL2Linux (Ubuntu 22.04 or later)

Ollama works on CPU, but the guide states it is roughly 10× slower there; with an NVIDIA GPU using CUDA it reports response generation in 1–3 seconds instead of 10–30 seconds. Those figures come from the vendor’s documentation rather than an independent benchmark. For CPU-only operation the guide suggests smaller models such as llama3.2:3b instead of llama3.2:8b, and notes that the embedding model nomic-embed-text is lightweight and runs well on CPU. [2]

On the WordPress side you need REST API access to your site. Public posts are readable without authentication; drafts, private posts, and pages with restricted visibility require credentials. Application passwords are the standard WordPress mechanism for authenticating a script against the REST API without exposing your main account password — a general WordPress practice rather than something either source documents.

Step-by-step: build the pipeline

Step 1 — Export WordPress content

On Route A, clone the demo repository and work through its scripts in order; the README describes the setup as creating a virtual environment and activating it before running the scripts. [1]

git clone https://github.com/iamcam/ai-wordpress-rag-demo
cd ai-wordpress-rag-demo

On Route B, the export stage is handled by wpexportjson, which pulls content through the WordPress REST API and writes Markdown. [2]

If you are writing your own exporter, the endpoints are the standard WordPress ones: /wp-json/wp/v2/posts and /wp-json/wp/v2/pages. Paginate with per_page and page, and use the _fields parameter to request only the fields you need — id, link, title, date, content — so the payload stays small. This is general WordPress REST API knowledge, not a claim from either source.

Check: you should end up with one file per post or page, and the count should match the number of published items on the site. A shortfall usually means pagination stopped early or authentication failed silently.

Step 2 — Chunk and embed

Split each document into chunks of a few hundred words, preferably along headings and paragraph boundaries so a chunk stays semantically coherent. Attach metadata to every chunk: post ID, permalink, title, and date. The permalink is what makes a retrieved answer verifiable.

Generate embeddings with nomic-embed-text through Ollama, or with whichever embedding model your chosen stack defaults to. The critical rule is consistency: the model that embeds your documents must be the same model that embeds incoming queries, and the vector dimension must match what the store expects.

On Route B, mddbd stores the content and the vectors. Its documented Docker Compose service exposes port 11023 for the HTTP API and 11024 for gRPC. [2]

services:
  mddb:
    image: ghcr.io/tradik/mddbd:latest
    ports:
      - "11023:11023"  # HTTP API
      - "11024:11024"  # gRPC

Pull the models you plan to use before the first ingest so the download does not interrupt the run:

ollama pull nomic-embed-text
ollama pull llama3.2:3b

Step 3 — Retrieve

At query time the pipeline embeds the user’s question with the same embedding model, performs a nearest-neighbour search over the stored vectors, and returns the top k chunks. Typical starting values are k = 4 to 8; larger values give the model more context but consume more of the context window and slow generation. Return the source URLs alongside the text so the answer can cite where it came from — a capability the demo README explicitly lists as a benefit of the RAG approach. [1]

Step 4 — Generate

Assemble a prompt containing the retrieved chunks and the user’s question, and send it to the local model through Ollama. The retrieved documents are what let the model answer about content it was never trained on. [1] On Route B, Open WebUI is the chat front end that talks to Ollama and displays the answer. [2]

Step 5 — Verify the pipeline works

Run three checks. First, ask a question whose answer appears in exactly one recent post and confirm the answer matches the post and cites it. Second, ask a question about a topic you have never published and see whether the pipeline returns “not in the sources” rather than a confident invention — treat this as a design goal to test, not a guarantee. Third, edit a post, re-run the ingest, and confirm the old chunk no longer appears in results.

Keeping the index current

RAG’s practical advantage over fine-tuning is that the knowledge store can be updated without retraining the model. [1] The simplest reliable pattern is to re-export and re-embed on publish or update, keyed by post ID, deleting any chunks whose post ID no longer exists. A nightly full re-index is easier to reason about and is usually fine for a blog-sized corpus; incremental updates matter more once the site has thousands of posts.

Common failure modes

  • HTTP 401 or 403 from the REST API. The exporter is hitting drafts or private content without credentials. Check the endpoint with a browser or curl first, then add an application password.
  • Empty or truncated export. Pagination stopped early, or a page-builder plugin stores content in shortcodes and custom fields that the content field does not fully render.
  • Retrieval returns irrelevant chunks. Usually a chunking problem — chunks too large, or split mid-sentence. Reduce chunk size and split on headings.
  • Embedding dimension mismatch. Documents were embedded with one model and queries with another, or the store was created with a different vector size. Re-index from scratch.
  • Very slow responses. Expected on CPU-only hardware; the MDDB guide reports roughly 10× slower generation without a GPU. Switch to a smaller model such as llama3.2:3b. [2]
  • Answers ignore the retrieved context. Too many chunks can push the actual question out of the effective context window. Lower k and test again.

Limitations and what the sources do not cover

Neither supplied source publishes benchmark results. The 1–3 second and 10–30 second generation figures are MDDB’s stated expectations for its own stack, not independently measured numbers, and they will vary with model size, quantization, context length, and hardware. [2]

The demo repository is small: 11 stars, 0 forks, and a license listed as “Other” as of the retrieved page. [1] That is enough to learn from, but it is not a widely validated production component, and the license should be checked before commercial use. The MDDB guide is vendor documentation for the mddbd database, so its capability descriptions are provider claims. [2]

Finally, neither route in the supplied material covers ingesting media, PDFs, or content behind membership plugins. If your site’s value lives in those places, you will need additional extraction steps that these guides do not describe.

Where to start

If you want to understand the mechanics, start with Route A and run the scripts one at a time, inspecting the intermediate output at each stage. If you want a working local chatbot over your own posts, start with Route B and use the smallest model your hardware comfortably runs, then scale up once the pipeline is verified end to end. Either way, test retrieval quality before you tune generation — most disappointing RAG answers are retrieval failures, not model failures.

If you build either pipeline, sharing your hardware, model choice, chunk size, and the questions that failed is more useful to the community than a success screenshot.

FAQ

Do I need a GPU to run a local RAG pipeline over WordPress content?

No. The MDDB guide documents a CPU-only mode and notes that the embedding model nomic-embed-text runs well on CPU, while recommending smaller generation models such as llama3.2:3b. The same guide states CPU generation is roughly 10× slower than GPU generation, so expect longer waits rather than failure.

Do I have to fine-tune a model on my blog posts?

No. RAG's stated advantage is that it extends an AI system beyond its training data without fine-tuning or retraining, because documents can be added to and updated in the data store dynamically.

Does the demo project require a paid API?

No. The iamcam/ai-wordpress-rag-demo README states that its scripts use free and open-source libraries and models by default, with an option to use OpenAI's LLMs if you have access.

How do I keep the index in sync when I publish or edit a post?

Re-export and re-embed the changed content, keyed by post ID, and delete chunks whose post ID no longer exists. A nightly full re-index is simpler to reason about for a blog-sized corpus; incremental updates matter more at thousands of posts.

Why does my pipeline return answers that ignore my posts?

Most often retrieval is failing rather than generation. Check chunk size and boundaries, confirm the same embedding model is used for documents and queries, and reduce the number of retrieved chunks if the question is being pushed out of the effective context window.

References

  1. https://github.com/iamcam/ai-wordpress-rag-demo
  2. https://mddb.tradik.com/docs/wordpress-agent/

Related terms

Retrieval-augmented generation (RAG)
An architecture that pairs a retrieval system with a generative language model, feeding relevant documents into the model so answers can draw on data outside its training set.
Embedding
A numeric vector representing the meaning of a text chunk, used to measure similarity between a user query and stored documents.
Chunk
A short passage of a document created during ingest; retrieval operates on chunks rather than whole posts.
Vector store
A database that holds embeddings and supports nearest-neighbour search; mddbd is one example used in the local WordPress stack.
Ollama
A local AI server that runs both large language models and embedding models on your own machine.
WordPress REST API
The HTTP interface that exposes posts, pages, and other content, used by exporters such as wpexportjson.

Leave a Reply

Your email address will not be published. Required fields are marked *