John WalpoleAI systems engineering & reliability

architecture

Retrieval-Augmented Generation Architecture

One of the most common failure modes of modern AI systems is presenting confident answers without sufficient grounding in trusted information.

Type
Architecture
Last updated
2026-06-04
ragretrievalai-systemsarchitectureobservabilitygovernance

Overview

One of the most common failure modes of modern AI systems is presenting confident answers without sufficient grounding in trusted information.

Large Language Models are excellent at generating language, but they are not authoritative sources of truth. Without access to relevant context, they may generate incomplete, inaccurate, outdated, or entirely fabricated responses.

Retrieval-Augmented Generation (RAG) addresses this problem by retrieving relevant source material before generating an answer.

This architecture describes the retrieval-first approach used throughout this personal AI and Reliability Engineering Lab.

The core principle is:

Retrieve first. Generate second.

Goals

The primary goals of the architecture are:

  • improve response accuracy
  • reduce hallucinations
  • provide source attribution
  • improve trust in AI responses
  • support explainable workflows
  • enable content-driven recommendations
  • separate knowledge management from model selection

The architecture is intentionally designed so that retrieval quality has a greater impact on answer quality than the specific language model being used.

Components

Content Corpus

The content corpus serves as the canonical source of knowledge.

Content is stored as structured Markdown documents organized into categories:

  • portfolio
  • architecture
  • writing
  • synthetic incidents
  • prompts
  • demos

Each document contains metadata used for retrieval, filtering, routing, and recommendations.

Ingestion Pipeline

The ingestion pipeline transforms source documents into searchable retrieval content.

Responsibilities include:

  • metadata validation
  • document parsing
  • semantic chunking
  • embedding generation
  • vector indexing

Markdown files remain the source of truth.

Embeddings and vector indexes are considered derived artifacts.

Embedding Layer

The embedding layer converts text into vector representations.

The reference implementation uses:

  • Ollama
  • nomic-embed-text

Embedding generation occurs during ingestion and re-ingestion workflows.

Embedding providers can be substituted without changing retrieval behavior.

Vector Database

The vector database stores semantic representations of document chunks.

Reference implementation:

  • Weaviate

Responsibilities:

  • semantic similarity search
  • metadata filtering
  • retrieval ranking
  • hybrid retrieval support

The vector database serves as a retrieval index for semantic search. The authoritative source of knowledge remains the version-controlled Markdown corpus, from which embeddings and retrieval indexes are derived.

Retrieval Layer

The retrieval layer identifies relevant content for a given question.

Responsibilities:

  • semantic search
  • metadata filtering
  • persona-aware weighting
  • retrieval ranking
  • confidence estimation

The retrieval layer should return context, not answers.

Answer generation happens only after relevant context has been selected.

Generation Layer

The generation layer receives:

  • user question
  • retrieved context
  • metadata
  • workflow instructions

Reference implementation:

  • Ollama
  • local inference

Additional providers can include:

  • OpenAI
  • Anthropic

Provider abstraction is used to prevent lock-in.

Citation Layer

The citation layer preserves source attribution.

Responses should include:

  • source references
  • related documents
  • suggested exploration paths

This allows visitors to inspect supporting material rather than relying entirely on generated output.

Data Flow

High-level workflow:

1. User submits question. 2. Retrieval layer searches corpus. 3. Relevant chunks are identified. 4. Chunks are filtered and ranked. 5. Context is assembled. 6. Language model generates response. 7. Citations are attached. 8. Related content is suggested.

The language model never operates without retrieved context when answering corpus-related questions.

Operational Risks

Hallucinations

Language models may generate unsupported claims.

Mitigation:

  • retrieval-first workflows
  • source attribution
  • confidence scoring
  • grounded prompt construction

Poor Retrieval

A strong model cannot compensate for poor retrieval quality.

Mitigation:

  • metadata standards
  • semantic chunking
  • corpus quality review
  • retrieval analytics

Corpus Drift

As content grows, retrieval quality may degrade.

Mitigation:

  • metadata validation
  • controlled tagging
  • ingestion review
  • quality loop analysis

Provider Lock-In

Architectures tightly coupled to a single model provider become difficult to evolve.

Mitigation:

  • provider abstraction
  • retrieval abstraction
  • portable document storage

Scaling Considerations

The architecture intentionally separates:

  • content
  • retrieval
  • generation

This separation allows independent scaling.

Examples:

  • stronger models without changing corpus structure
  • alternative vector databases without rewriting content
  • hosted inference without changing retrieval workflows
  • expanded corpus without changing frontend experiences

The design prioritizes flexibility and portability.

Tradeoffs

Local Inference

Benefits:

  • lower operating costs
  • local control
  • portability

Costs:

  • increased resource requirements
  • slower inference
  • model limitations

Vector Search

Benefits:

  • semantic retrieval
  • contextual discovery
  • recommendation support

Costs:

  • operational complexity
  • embedding management
  • index maintenance

Citation-First Design

Benefits:

  • transparency
  • trust
  • explainability

Costs:

  • additional implementation effort
  • more complex response generation

The additional complexity is considered worthwhile because trust is a core design goal.

Observability

Retrieval quality should be observable.

Examples:

  • retrieval latency
  • selected chunks
  • confidence scores
  • unanswered questions
  • citation usage
  • corpus gaps

These metrics support retrieval improvement and help identify where knowledge quality needs attention.

Security Considerations

Only governed source content should be retrievable.

The retrieval system must not expose:

  • secrets
  • unpublished content
  • credentials
  • private notes
  • internal infrastructure information

Prompt input should be treated as untrusted.

Prompt injection attempts should never override retrieval boundaries.

Extension Points

The architecture leaves room for:

  • hybrid retrieval
  • reranking models
  • knowledge graph relationships
  • semantic exploration maps
  • retrieval quality scoring
  • adaptive recommendation systems
  • workflow visualizations
  • corpus gap analysis

Those additions should be evaluated against the same standard as the core design: they need to improve trust, explainability, retrieval quality, or operational usefulness.

Key Design Principle

The purpose of retrieval is not to make the model smarter.

The purpose of retrieval is to make the system more trustworthy.

A smaller model with strong retrieval and citations is often more useful than a larger model operating without context.

Sources

  • Retrieval-Augmented Generation Architecture

    Public architecture document. Last updated: 2026-06-04.