An LLM knows nothing about your site. RAG fixes that by finding the relevant content first and sending it to the model together with the question.

What it is

Retrieval augmented generation has three steps:

  1. Retrieve: find the pieces of content that match the question.
  2. Augment: put them into the prompt as context.
  3. Generate: the model answers using that context.
flowchart LR
    Q["Question"] --> R["Retrieve<br/>search site content"]
    R --> A["Augment<br/>add found content to prompt"]
    A --> G["Generate<br/>LLM answer"]

How it works

Retrieval is the part that decides quality. There are two common approaches:

  • Keyword search: match words in titles and text. Simple, runs in plain PHP, misses synonyms.
  • Vector search: turn text into embeddings and find content by meaning. Needs an embedding model and a vector store.

Our 4WP AI Assistant uses the first one: it indexes public post types and scores matches by title, word frequency and exact phrase. A full vector-based model is a separate project, 4wp-rag, currently at the concept stage.

Where it is used

  • Q&A over documentation, courses or a knowledge base.
  • Support answers based on existing FAQ.
  • Internal search for editors.
  • Product questions in stores.

Related