Eight lessons in, you’ve built every stage of a real retrieval-augmented generation pipeline, not a toy demo, working code for embedding, chunking, storing, searching, and grounding an answer, plus the sync logic that keeps it honest as content changes. This lesson pulls all of it into one picture.
The pipeline, one more time, as a single picture
Embed (Lesson 2): AiClient::input( $text )->generateEmbedding()->getValues()
turns a piece of content into a numeric vector, and generateEmbeddings() does it in
batch for many pieces at once.
Chunk (Lesson 3): long content is split into paragraph or heading-aware pieces before embedding, since one embedding per whole post produces retrieval too vague to be useful.
Store (Lessons 4 and 5): a custom ai_chunk_embeddings table, one row per chunk,
holding the chunk text and its JSON-encoded vector, created and upgraded with
dbDelta(). No official WordPress vector store exists, this table is the honest,
real answer for most sites.
Retrieve (Lesson 6): the user’s question is embedded the same way, compared against every stored row with cosine similarity computed in plain PHP, and the top-N closest chunks are kept.
Ground and generate (Lesson 7): those retrieved chunks, plus a system instruction
that explicitly permits “I don’t have information on that,” plus the question, are
assembled into one prompt and handed to wp_ai_client_prompt()->generate_text().
Stay in sync (Lesson 8): save_post re-indexes changed content, before_delete_post
removes what’s gone, and a WP-CLI command bulk-indexes everything that predates the
pipeline.
An assistant that can call an LLM and an assistant that can answer accurately about your site are not the same thing. The gap between them is everything this course built: retrieval. Skip it, and every assistant you build elsewhere in this track is only ever as trustworthy as the model’s guesswork.
Where this pipeline plugs into the rest of the track
| Course | How it uses this pipeline |
|---|---|
| Connect AI Assistants & Agents to WordPress (Course 3) | The conversational admin assistant built there is only as accurate as the retrieval grounding it, this course’s Lessons 6 and 7 directly. |
| AI Content & SEO Automation for WordPress (Course 6) | Editorial tools answering questions about existing content, or checking new drafts against it, need exactly this indexing and retrieval pipeline underneath them. |
| Autonomous agent courses later in the track (Course 11) | Any agent expected to reason about specific site content rather than general knowledge needs a retrieval step, this pipeline is that step. |
What to build next on your own
Before moving to another course, it’s worth hardening what you’ve built here on your own content: run the WP-CLI reindex command from Lesson 8 against your real site, ask it several questions you know the answer to and several you know it doesn’t cover, and confirm the “I don’t have information on that” path actually triggers instead of silently guessing. That test matters more than any single lesson’s code sample, it’s the real measure of whether this pipeline is trustworthy on your content specifically.
Recap
This course took embeddings from Course 5’s brief introduction to a complete, production pipeline: generating them correctly with the current SDK, chunking content so retrieval is precise rather than vague, storing vectors honestly given that WordPress has no official answer for it, searching them with real cosine similarity math, grounding a generated answer in what was actually retrieved, and keeping the whole thing in sync as content changes. Every chatbot, assistant, or agent elsewhere in this track that needs to be right about your specific site, rather than merely fluent, depends on exactly this pipeline.
Ready to put this pipeline behind a real conversational interface? Continue to Connect AI Assistants & Agents to WordPress.
Resources & further reading
- PHP AI Client SDK repository, GitHub
- AI Building Blocks for WordPress, make.wordpress.org
- Generating Embeddings, Course 5