Implementing RAG and RagRails for Reliable Conversational AI in Insurance

geico · Insurance · 2023 · source Agentic: yes · promotional bias: low · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Reliable customer-facing conversational AI for insurance workflows

GEICO explored a conversational chat application that could collect user information instead of relying on web forms, but commercial and open-source LLMs varied without constraints, hallucinated plausible but false answers, and overpromised capabilities they did not have. In an insurance setting, the team needed a way to ground answers, guide the model through process state, limit false system-capability assumptions, and evaluate repeatability before using generative technology safely.

Constraints:

Architecture

GEICO built an experimental RAG architecture for a conversational insurance chat application. Business data is split into records, embedded through an API, enriched with LLM-extracted metadata, and indexed in a vector database through an offline asynchronous conversion path. At interaction time, the system dynamically composes a system prompt from the conversation state, quote process stage, task description, constraints, and RAG context. User messages are also translated by an LLM into coherent likely questions, causing retrieval over both original and translated inputs. Retrieved records are ranked and reordered to improve model focus, filtered by an LLM relevance check, inserted into the prompt as answer-only context where possible, and augmented with RagRails instructions when relevant records need to steer the model away from overpromising.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  Customer_user["Customer user"] --> Conversational_chat_application["Conversational chat application"]
  Conversational_chat_application --> Conversation_state_tracker["Conversation state tracker"]
  Conversation_state_tracker --> Dynamic_system_prompt_composer["Dynamic system prompt composer"]
  Business_knowledge_sources["Business knowledge sources"] --> Document_splitting_pipeline["Document splitting pipeline"]
  Document_splitting_pipeline --> Embedding_API["Embedding API"]
  Document_splitting_pipeline --> Metadata_extraction_LLM["Metadata extraction LLM"]
  Embedding_API --> Offline_indexing_builder["Offline indexing builder"]
  Metadata_extraction_LLM --> Offline_indexing_builder
  Offline_indexing_builder --> HNSW_vector_database["HNSW vector database"]
  Conversational_chat_application --> Input_translation_LLM["Input translation LLM"]
  Input_translation_LLM --> RAG_retrieval_runtime["RAG retrieval runtime"]
  HNSW_vector_database --> RAG_retrieval_runtime
  RAG_retrieval_runtime --> Ranking_mechanism["Ranking mechanism"]
  RAG_retrieval_runtime --> Relevance_checker["Relevance checker"]
  RAG_retrieval_runtime --> RagRails_records["RagRails records"]
  Ranking_mechanism --> Dynamic_system_prompt_composer
  Relevance_checker --> Dynamic_system_prompt_composer
  RagRails_records --> Dynamic_system_prompt_composer
  Dynamic_system_prompt_composer --> LLM_response_generator["LLM response generator"]
  LLM_response_generator --> Conversational_chat_application
  LLM_response_generator --> Repeatability_test_harness["Repeatability test harness"]
  RagRails_records --> Repeatability_test_harness
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Customer user Person interacting with the conversational insurance application. Conversational chat application
Conversational chat application Customer-facing interface that collects information through conversation rather than forms. Customer user, Dynamic system prompt composer, RAG retrieval runtime, LLM response generator
Conversation state tracker Tracks underlying data-model state, conversation state, process stage, and progress toward the predetermined task. Dynamic system prompt composer, Conversational chat application
Dynamic system prompt composer Composes task description, constraints, RAG context, conversation state, quote process stage, and user intention into the LLM prompt. Conversation state tracker, RAG retrieval runtime, LLM response generator
Business knowledge sources Dense internal knowledge that must be converted into semantic records for RAG. Document splitting pipeline
Document splitting pipeline Splits dense documents into records before embedding and metadata extraction. Business knowledge sources, Embedding API, Metadata extraction LLM
Embedding API Converts record segments into vector representations. Document splitting pipeline, Offline indexing builder
Metadata extraction LLM Extracts metadata for indexed records. Document splitting pipeline, Offline indexing builder
Offline indexing builder Asynchronous component that builds vector collections and creates database snapshots away from retrieval traffic. Embedding API, Metadata extraction LLM, HNSW vector database
HNSW vector database High-dimensional vector index used for efficient nearest-neighbor search and metadata-aware retrieval. Offline indexing builder, RAG retrieval runtime
Input translation LLM Rewrites fragmented or varied everyday language into a coherent likely question for retrieval. Conversational chat application, RAG retrieval runtime
RAG retrieval runtime Retrieves record sets from raw and translated inputs, combines them, ranks them, and prepares them for prompt insertion. Dynamic system prompt composer, Input translation LLM, HNSW vector database, Ranking mechanism, Relevance checker, RagRails records
Ranking mechanism Reorders retrieved knowledge so highly relevant content is positioned where the LLM is more likely to attend to it. RAG retrieval runtime, Dynamic system prompt composer
Relevance checker Uses an LLM to judge whether retrieved records are relevant before adding excessive context. RAG retrieval runtime, LLM response generator, Dynamic system prompt composer
RagRails records Retrieved records that include guiding instructions to prevent misconceptions and overpromising only when relevant. RAG retrieval runtime, LLM response generator, Dynamic system prompt composer
LLM response generator Generates conversational responses using dynamically composed instructions and retrieved context. Conversational chat application, Dynamic system prompt composer, RagRails records, Relevance checker
Repeatability test harness Runs repeated samples to measure incorrect overpromising responses and judge whether railed responses are suitable. LLM response generator, RagRails records

Data flow

Dense business knowledge is split, embedded, given metadata, and indexed offline into HNSW-backed vector collections. During a chat, GEICO composes state-aware instructions and retrieves records based on both the user's raw input and an LLM-translated version of the input. It combines the retrieved record sets, ranks and positions the most relevant knowledge, optionally checks relevance, and injects focused answer context into the system prompt. When a retrieved record carries a RagRails instruction, that instruction is applied only in relevant contexts to constrain model behavior and reduce overpromising.

3 supporting quotes
“The ingestion process encompasses splitting documents, converting each to embeddings through an API, then extracting metadata using LLMs.”article, stated
“every user message was sent to a LLM to translate the input into a form that could be matched within the knowledge base.”article, stated
“RagRails is only used when the record is retrieved and relevant.”article, stated

Why this architecture

GEICO chose RAG before fine-tuning because it was cheaper, more flexible, more transparent, and easier to update. Offline indexing isolates expensive vector-structure construction from retrieval QPS. Query translation and ranking address messy user language and lost-in-the-middle behavior. RagRails solves a prompt-control problem that permanent system-prompt instructions could not solve cleanly by attaching the behavioral guidance to relevant retrieved records only.

"We considered RAG as a first line of defense due to:

“This approach aims to maximize Queries per Second (QPS) without the load of indexing during retrieval.”article, stated
“attempts to permanently add instructions to the system prompt were unsuccessful and disrupted other goals.”article, stated

Models used: GPT model · commercial LLMs · open-source LLMs · embedding model/API · LLM for metadata extraction · LLM for input translation · LLM for relevance checking

Scale

Alternatives considered (roads not taken)

Fine-tune as the first hallucination mitigation step

Rejected because: GEICO treated fine-tuning as a last resort because RAG was cheaper, flexible, transparent, and efficient for updating knowledge.

“Many practitioners use fine tuning as a last resort to combat hallucinations because models can be adapted to improve their outputs against a specialized task.”article, stated

— article, stated

Use the entire retrieved record in the system prompt

Rejected because: Including full records was ineffective and unreliable; inserting only the answer portion produced more focused outcomes.

“The first RAG implementation utilized the entire record within the system prompt, but this approach was ineffective and unreliable.”article, stated
“a more refined insertion approach that only included the answer, excluding the examples. This resulted in more focused outcomes.”article, stated

Retrieve only from the user's raw message

Rejected because: Everyday language was fragmented and varied, so GEICO also translated the input into a coherent likely question and retrieved both sets.

“Given that everyday language can often be fragmented, grammatically incorrect, and varied, every user message was sent to a LLM to translate the input”article, stated
“eventually resulted in two records sets retrieved. Both sets were then collected and combined for later insertion into the system prompt.”article, stated

Permanently add all behavioral instructions to the system prompt

Rejected because: Those instructions disrupted other goals; RagRails attaches guidance to retrieved relevant records instead.

“attempts to permanently add instructions to the system prompt were unsuccessful and disrupted other goals.”article, stated
“We then included the instructions in the record shown to the model upon retrieval.”article, stated

Use the largest LLM for every subtask

Rejected because: GEICO suggests smaller, more finely tuned models for optimization, extraction, relevance, and validation, with the LLM as backup.

“one choice is to use smaller, more finely tuned models for specific tasks such as optimization, entity extraction, relevance detection, and validation.”article, stated
“The LLM could then serve as a backup solution when these smaller models are insufficient.”article, stated

Patterns

rag-retrieval (knowledge-architecture)

GEICO converts business knowledge into embedded records and retrieves authoritative context into the system prompt instead of relying on model memory.

“RAG can be categorized as a prompt engineering technique that aims to provide LLMs with access to authoritative external knowledge”article, stated
“we need to convert business data into their vectorized representations.”article, stated

batch-offline-processing (operations)

The vector indexing and snapshot-building work happens offline and asynchronously so retrieval can serve traffic without indexing load.

“Creating the multilayer data structure required for the vector indexing can be a resource-intensive mathematical operation, so we designed an offline asynchronous conversion.”article, stated
“we have a component for building collections and creating snapshots for the vector database, minimizing disruption and downtime”article, stated

retrieval-ranking (retrieval)

GEICO ranks and reorders retrieved records so the most relevant material sits at the beginning or end of the context window.

“By reordering retrieved knowledge and prioritizing the most relevant ones at the beginning or end of the sequence, the LLM's focus window improved”article, stated
“This added step ensured that the most semantically relevant knowledge was positioned at the bottom of the RAG context window.”article, stated

query-rewriting (retrieval)

Every user message is rewritten into a coherent likely question for better knowledge-base matching.

“every user message was sent to a LLM to translate the input into a form that could be matched within the knowledge base.”article, stated
“This translated input was a coherent sentence that tried to predict the question the user was likely to ask”article, stated

llm-as-judge (quality)

GEICO uses the same LLM to evaluate retrieved record relevance before injecting too much context.

“we introduced a relevance check. We used the same LLM to evaluate the records' relevance to a part of the conversation.”article, stated
“Developing a concept of relevance proved challenging and remains an area for improvement.”article, stated

guardrails-io-filtering (quality)

RagRails places guidance inside retrieved records to steer the model away from incorrect capability claims.

“RagRails involves adding guiding instructions to a record to aid the LLM.”article, stated
“The additional context helps the model to avoid misconceptions and potential negative effects while reinforcing desired behaviors.”article, stated

cost-aware-routing (operations)

GEICO proposes smaller specialized models for subtasks and using the LLM as backup to reduce inference burden.

“Maintaining our current path may result in higher inference costs due to the additional information provided to the model.”article, stated
“use smaller, more finely tuned models for specific tasks such as optimization, entity extraction, relevance detection, and validation”article, stated

Tradeoffs

RAG before fine-tuning

Chose retrieval-augmented generation as first line of defense over fine-tuning as the initial mitigation.

Rationale: RAG avoided retraining cost, supported independently updated knowledge, improved transparency, and allowed rapid knowledge access.

"We considered RAG as a first line of defense due to:

— article, stated "* Transparency: Enables easy interpretability and attribution.

— article, stated

Offline indexing

Chose asynchronous collection building and snapshots over doing vector-index construction during retrieval.

Rationale: Vector indexing was resource intensive, so separating it from retrieval protected QPS and reduced disruption.

“Creating the multilayer data structure required for the vector indexing can be a resource-intensive mathematical operation”article, stated
“without the load of indexing during retrieval. As a result, we have a component for building collections and creating snapshots”article, stated

Answer-only prompt insertion

Chose insert the answer portion of records over insert entire records including examples.

Rationale: Focused insertion reduced ineffective and unreliable behavior from noisy record context.

“the entire record within the system prompt, but this approach was ineffective and unreliable.”article, stated
“only included the answer, excluding the examples. This resulted in more focused outcomes.”article, stated

Contextual RagRails

Chose instructions embedded in retrieved relevant records over permanent global instructions in the system prompt.

Rationale: Record-level guidance constrained behavior only when relevant without disrupting other objectives.

“attempts to permanently add instructions to the system prompt were unsuccessful and disrupted other goals.”article, stated
“RagRails is only used when the record is retrieved and relevant.”article, stated

Cost versus truthfulness

Chose higher inference context for truthfulness-critical scenarios over minimizing inference cost at the expense of consistency.

Rationale: GEICO argues dependable application should be prioritized in scenarios requiring high truthfulness and precision.

“Maintaining our current path may result in higher inference costs due to the additional information provided to the model.”article, stated
“dependable and consistent application of Language Models should be prioritized for specific scenarios that require a high degree of truthfulness and precision.”article, stated

Gotchas (what bit them)

LLMs overpromise capabilities in customer-facing flows.

Root cause: A helpful persona plus RAG context can make the model assume it can perform actions related to an answer.

Resolution: Attach guiding instructions to relevant retrieved records using RagRails and test repeatability.

3 supporting quotes
“The model may "overpromise", presuming it can perform actions that it is not able to do.”article, stated
“RagRails involves adding guiding instructions to a record to aid the LLM.”article, stated
“The key to this method is the repeatability of the test, as a positive result may mask future undesirable outcomes.”article, stated

Full records in prompts were noisy and unreliable.

Root cause: Examples and record structure inside the prompt confused the model.

Resolution: Delineate record structure and insert only the answer portion.

“The first RAG implementation utilized the entire record within the system prompt, but this approach was ineffective and unreliable.”article, stated
“A clear delineation of the record structure allowed for a swift shift to a more refined insertion approach that only included the answer”article, stated

More retrieved context increased variability and cost.

Root cause: Adding extra context can produce response variability while increasing inference burden.

Resolution: Introduce an LLM relevance check and consider whether contexts are actually applicable before insertion.

“Incorporating more context can lead to increased response variability and more costs.”article, stated
“To address these concerns, we introduced a relevance check.”article, stated

Retrieved passages can be missed in the middle of long prompts.

Root cause: LLMs can struggle to focus on context placed in the middle of the input sequence.

Resolution: Rank and position the most relevant knowledge at prompt locations where the model attends better.

“LLMs can struggle to keep focus on retrieved passages positioned within the middle of the input sequence”article, stated
“reordering retrieved knowledge and prioritizing the most relevant ones at the beginning or end of the sequence”article, stated

User language did not map cleanly to knowledge records.

Root cause: Everyday language was fragmented, grammatically incorrect, and varied.

Resolution: Use an LLM to translate each message into a coherent likely question and combine retrieval from both original and translated inputs.

“everyday language can often be fragmented, grammatically incorrect, and varied”article, stated
“eventually resulted in two records sets retrieved. Both sets were then collected and combined”article, stated

Evaluation

GEICO evaluated the RAG/RagRails implementation through repeated sample tests focused on overpromising, LLM and developer effort, relevance checks, and whether retrieved contexts were applicable. The reported overpromising test improved from 12 incorrect responses out of 20, to 6, and eventually to none after RagRails adjustments.

Metrics: incorrect overpromising responses: 12 out of 20 before correction · incorrect responses reduced to 6 after initial RagRails-style adjustment · incorrect responses eventually reduced to none after further adjustments · LLM performance and developer effort for railed responses · retrieved-record relevance · Queries per Second protected by offline indexing

3 supporting quotes
“In this case, 12 out of 20 responses were incorrect during repeated testing.”article, stated
“This approach reduced the 12 errors to 6, and eventually to none after further adjustments, leading to our RagRails strategy.”article, stated
“We performed sample tests for consistency and evaluated responses based on LLM and developer effort”article, stated

Outcomes

This case is a strong safety and reliability example rather than a mature production launch report. Its most reusable contribution is the RagRails idea: putting behavioral guidance into retrieved records so constraints appear only when relevant, avoiding global prompt bloat while reducing overpromising.

3 supporting quotes
“This blog describes some of the processes for an experimental RAG implementation and the insights gained.”article, stated
“This approach reduced the 12 errors to 6, and eventually to none after further adjustments, leading to our RagRails strategy.”article, stated
“At GEICO Tech, we continue to explore RAG and other techniques as we explore how to use generative technologies safely and effectively”article, stated