Implementing RAG for Enhanced Customer Care at Scale

doctolib · Healthcare · 2024 · source Agentic: no · 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: RAG-enhanced customer care for healthcare platform support

Doctolib wanted to improve customer care beyond rules-based bots and public-knowledge LLM answers. Customer-care users needed answers grounded in Doctolib's frequently updated private FAQ content, with enough precision, latency, and UX quality to reduce cases for human agents while avoiding complex unsupported interactions that basic RAG could not handle.

Constraints:

Architecture

Doctolib built a production RAG pipeline for customer care. FAQ articles are updated daily, embedded into OpenSearch as vector chunks, and retrieved for user questions. The system uses GPT-4o hosted on Azure OpenAI for security and confidentiality, OpenSearch as the vector database, and a reranking component because vector search alone was not precise enough. A Ragas-based evaluation tool measures context precision, context recall, faithfulness, and answer relevancy, supported by annotated groundtruth records. UX work added an ML classifier that predicts whether the RAG system can answer a query, trading reach for precision by routing unanswerable questions away from automation. Latency was reduced from roughly 1 minute to under 5 seconds through code optimization, Azure OpenAI PTUs, smaller-model tests, and streaming.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  Customer_care_user["Customer-care user"] --> Assistant_UI["Assistant UI"]
  Assistant_UI --> Answerability_classifier["Answerability classifier"]
  Answerability_classifier --> Human_customer_care_agents["Human customer-care agents"]
  Answerability_classifier --> Query_embedding_step["Query embedding step"]
  FAQ_articles["FAQ articles"] --> Daily_FAQ_refresh_pipeline["Daily FAQ refresh pipeline"]
  Daily_FAQ_refresh_pipeline --> Embedding_step["Embedding step"]
  Embedding_step --> OpenSearch_vector_database["OpenSearch vector database"]
  Query_embedding_step --> Embedding_step
  Query_embedding_step --> OpenSearch_vector_database
  OpenSearch_vector_database --> Reranking_brick["Reranking brick"]
  Reranking_brick --> Answer_generator["Answer generator"]
  Answer_generator --> Azure_OpenAI_GPT_4o["Azure OpenAI GPT-4o"]
  Azure_OpenAI_GPT_4o --> Provisioned_Throughput_Units["Provisioned Throughput Units"]
  Answer_generator --> Streaming_delivery["Streaming delivery"]
  Streaming_delivery --> Assistant_UI
  Ragas_evaluation_tool["Ragas evaluation tool"] --> Groundtruth_records["Groundtruth records"]
  Groundtruth_records --> Experiment_loop["Experiment loop"]
  Ragas_evaluation_tool --> Experiment_loop
  Experiment_loop --> Reranking_brick
  Experiment_loop --> Answer_generator
  Experiment_loop --> Daily_FAQ_refresh_pipeline
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Customer-care user User seeking help through Doctolib customer care. Assistant UI
Assistant UI User-facing interface for the RAG customer-care answer flow. Customer-care user, Answerability classifier, Answer generator
Answerability classifier Machine-learning classifier that predicts whether the RAG system can answer the user query. Assistant UI, Query embedding step, Human customer-care agents
Human customer-care agents Agents who handle cases the RAG system should not answer and more complex customer-care issues. Answerability classifier, Assistant UI
FAQ articles Private, up-to-date Doctolib FAQ knowledge base used to ground answers. Daily FAQ refresh pipeline
Daily FAQ refresh pipeline Retrieves up-to-date FAQ content and embeds it into the vector database every day. FAQ articles, Embedding step, OpenSearch vector database
Embedding step Embeds FAQ chunks and runtime user queries for retrieval. Daily FAQ refresh pipeline, Query embedding step, OpenSearch vector database
Query embedding step Embeds the user query before FAQ retrieval. Answerability classifier, Embedding step, OpenSearch vector database
OpenSearch vector database Vector database storing embeddings of FAQ article chunks. Embedding step, Query embedding step, Reranking brick
Reranking brick Filters and prioritizes initially retrieved documents because vector search alone was not good enough. OpenSearch vector database, Answer generator
Answer generator GPT-4o on Azure OpenAI generating answers grounded in retrieved FAQ context. Assistant UI, Reranking brick, Azure OpenAI GPT-4o, Streaming delivery
Azure OpenAI GPT-4o Hosted LLM used for answer generation under security and confidentiality constraints. Answer generator, Provisioned Throughput Units
Provisioned Throughput Units Azure OpenAI throughput control used to guarantee consistent throughput and reduce latency. Azure OpenAI GPT-4o, Answer generator
Streaming delivery Generation-phase optimization that starts delivering text progressively to improve perceived latency. Answer generator, Assistant UI
Ragas evaluation tool Evaluation framework measuring RAG component and end-to-end performance. Groundtruth records, Experiment loop
Groundtruth records Annotated perfect answers used as benchmark data for evaluation and optimization. Ragas evaluation tool, Experiment loop
Experiment loop Systematic testing of hybrid search, prompts, LLM parameters, chunking, embeddings, fine-tuning, and reranking. Ragas evaluation tool, Daily FAQ refresh pipeline, Reranking brick, Answer generator

Data flow

A daily data pipeline retrieves updated FAQ content, chunks and embeds it, and writes embeddings into OpenSearch. At runtime, a user asks a customer-care question through the assistant UI. An ML classifier predicts whether the query is answerable by the RAG system. If active, the query is embedded, FAQ chunks are retrieved from OpenSearch, reranked, and passed with the question to GPT-4o on Azure OpenAI to generate an answer grounded in context. Evaluation experiments use Ragas metrics and groundtruth records to tune retrieval, prompts, chunking, embedding models, LLM parameters, and reranking.

3 supporting quotes
“the RAG is based on the FAQ articles updated daily. We currently use GPT-4o as a LLM, hosted on the Azure OpenAI service”article, stated
“OpenSearch as the Vector Database containing the embeddings of the chunks of the FAQ articles.”article, stated
“To achieve this, we developed a Machine Learning classifier model to predict if our system could answer the user query.”article, stated

Why this architecture

RAG gave GPT-4o access to recent private FAQ knowledge that the base model lacked, while Azure OpenAI addressed healthcare security and confidentiality concerns. Reranking improved retrieval precision beyond vector search, Ragas and groundtruth records made optimization systematic, and an answerability classifier improved UX by reducing cases where the system attempted questions it could not answer.

“This lack of access to recent and private data can limit the accuracy and depth of their answers.”article, stated
“We currently use GPT-4o as a LLM, hosted on the Azure OpenAI service by Microsoft for security and confidentiality issues”article, stated

As we embarked on the journey of implementing a RAG"

— article, stated

Models used: GPT-4o · Azure OpenAI · Machine Learning classifier model · embedding models · Ragas evaluation framework

Scale

Alternatives considered (roads not taken)

Rules-based bots

Rejected because: They could not adapt to users or context and required constant updates for new tasks.

“While simplistic rules-based bots are common, they are highly limited. They can’t adapt to users or their context.”article, stated
“They should also be more reliable and scalable than rules-based systems, which need constant updates for new tasks.”article, stated

Base LLM answers without retrieval

Rejected because: LLMs lacked recent private Doctolib knowledge, limiting accuracy for company-specific customer-care questions.

“However, they are trained and thus have knowledge solely on a large corpus of public data. This lack of access to recent and private data”article, stated
“This lack of access to recent and private data can limit the accuracy and depth of their answers.”article, stated

Vector search without reranking

Rejected because: The initial retrieval step alone did not produce good enough results.

“As this step alone does not provide good enough results, we improved it by implementing a re-ranking brick.”article, stated

Answer every query through RAG

Rejected because: The team added an ML classifier to avoid frustrating users when the system could not answer.

“A key to improving user experience is to reduce the number of times our system can’t answer the user. To achieve this, we developed a Machine Learning classifier”article, stated
“To achieve this, we developed a Machine Learning classifier model to predict if our system could answer the user query.”article, stated

Stay with basic RAG for complex and action-oriented support

Rejected because: RAG could not handle complex queries, back-office actions, or seamless multi-turn conversation, motivating exploration of agents.

“It struggles with complex user queries and resolving issues beyond FAQs. It only gives descriptive answers.”article, stated
“To tackle those challenges, we explored agentic frameworks as a potential solution.”article, stated

Patterns

rag-retrieval (knowledge-architecture)

Doctolib grounds GPT-4o answers in daily refreshed FAQ articles retrieved from OpenSearch.

“RAG pulls in up-to-date knowledge to provide more accurate and relevant answers.”article, stated
“In our case, the RAG is based on the FAQ articles updated daily. We currently use GPT-4o as a LLM”article, stated

retrieval-ranking (retrieval)

A reranking component improves initial vector retrieval before answer generation.

“As this step alone does not provide good enough results, we improved it by implementing a re-ranking brick.”article, stated
“We tested the performance of different methods: hybrid search, prompt engineering, LLM parameters, chunking methods, embedding models and fine-tuning, reranking methods…”article, stated

eval-driven-development (quality)

Doctolib built a Ragas-based evaluation tool and groundtruth records to guide systematic experiments.

“We built and deployed an evaluation tool based on a framework called Ragas. It gives us metrics to evaluate our RAG system, both component-wise and end-to-end”article, stated
“We needed a dataset of “Groundtruth records”, which are perfect answers for our system. This evaluation brick lets us optimize our system’s parameters.”article, stated

confidence-thresholding (quality)

An ML classifier decides whether the system is likely to answer successfully before activating the RAG flow.

“To achieve this, we developed a Machine Learning classifier model to predict if our system could answer the user query.”article, stated

As we embarked on the journey of implementing a RAG"

— article, stated

latency-optimization (operations)

Doctolib reduced response latency from about 1 minute to under 5 seconds through code optimization, PTUs, smaller models, and streaming.

“We had a long journey to go from a latency of 1 min to less than 5s. To do so, we tested several strategies”article, stated
“we tested several strategies: optimizing the code, using Provisioned Throughput Units (PTUs) to guarantee consistent throughput”article, stated

data-quality-loop (quality)

The FAQ embedding index is refreshed daily so the RAG system remains synchronized with current support knowledge.

“It is essential to keep the Vector Database embeddings up to date. To do so, we implemented and deployed a data pipeline”article, stated
“we implemented and deployed a data pipeline that retrieves the up-to-date FAQ and embeds it in the vector database everyday.”article, stated

privacy-preserving-processing (governance)

The team chose Azure OpenAI hosting for security and confidentiality in a healthcare context.

“We currently use GPT-4o as a LLM, hosted on the Azure OpenAI service by Microsoft for security and confidentiality issues”article, stated

Tradeoffs

RAG before agentic architecture

Chose production RAG for FAQ-based customer care over jumping directly to multi-agent action-taking systems.

Rationale: RAG already transformed simple FAQ support, while agents were reserved for complex queries and action-oriented limitations.

“But first, let’s start by exploring how a RAG system can already transform your customer care services and understand what are its limitations.”article, stated
“After reaching the ceiling using RAG we started looking at agentic architecture.”article, stated

Managed model hosting

Chose GPT-4o hosted on Azure OpenAI over unmanaged or less controlled model deployment.

Rationale: Healthcare support required security and confidentiality controls.

“We currently use GPT-4o as a LLM, hosted on the Azure OpenAI service by Microsoft for security and confidentiality issues”article, stated

Classifier gate

Chose reduce reach to increase precision and impact over letting RAG attempt every user query.

Rationale: Routing unanswerable questions away from automation improved user experience even though fewer questions entered the automated flow.

"It diminished the reach of our tool but made it more precise and impactful.

As we embarked on the journey of implementing a RAG"

“A key to improving user experience is to reduce the number of times our system can’t answer the user. To achieve this, we developed a Machine Learning classifier”article, stated

Latency engineering

Chose PTUs, code optimization, smaller-model tests, and streaming over accepting one-minute response times.

Rationale: Customer-care UX required a much faster response loop than the first working RAG prototype delivered.

“We had a long journey to go from a latency of 1 min to less than 5s. To do so, we tested several strategies”article, stated
“optimizing the code, using Provisioned Throughput Units (PTUs) to guarantee consistent throughput, using smaller models and implementing streaming”article, stated

Evaluation investment

Chose Ragas metrics plus annotated groundtruth over classic NLP metrics alone.

Rationale: RAG quality depends on retrieval relevance and answer grounding, which BLEU, ROUGE, and BERTScore do not fully capture.

“Those are RAG specific metrics. They differ from the classical Natural Language Processing (NLP) metrics such BLEU or ROUGE scores”article, stated
“This evaluation brick lets us optimize our system’s parameters.”article, stated

Gotchas (what bit them)

Base LLMs could not answer private, current Doctolib questions accurately.

Root cause: They were trained on public data and lacked access to recent private company knowledge.

Resolution: Use RAG over daily updated FAQ articles.

“However, they are trained and thus have knowledge solely on a large corpus of public data. This lack of access to recent and private data”article, stated
“It enables addressing this by providing LLMs context specific content. It leads to far better answers.”article, stated

Vector retrieval alone was not good enough.

Root cause: The initial retrieval step did not provide sufficient answer quality.

Resolution: Add a reranking brick and evaluate retrieval quality with Ragas metrics.

“As this step alone does not provide good enough results, we improved it by implementing a re-ranking brick. It is essential to keep the Vector Database embeddings up to date.”article, stated

— article, stated

RAG evaluation needed purpose-built metrics and groundtruth records.

Root cause: Classic NLP metrics did not verify semantic similarity or factual consistency with source documents.

Resolution: Deploy Ragas metrics and annotate perfect-answer groundtruth records.

3 supporting quotes
“Those are RAG specific metrics. They differ from the classical Natural Language Processing (NLP) metrics such BLEU or ROUGE scores”article, stated
“Also, transformer-based metrics such as BERTScore do not check if answers are factually consistent with source documents.”article, stated
“We needed a dataset of “Groundtruth records”, which are perfect answers for our system. This evaluation brick lets us optimize our system’s parameters.”article, stated

Production latency was unacceptable at first.

Root cause: LLM-based RAG generation initially took about 1 minute per answer.

Resolution: Optimize code, use PTUs, test smaller models, and stream generation to reach under 5 seconds.

“we faced a major challenge: the latency. It is the delay between a request being initiated and a response being received”article, stated
“We had a long journey to go from a latency of 1 min to less than 5s. To do so, we tested several strategies”article, stated

Trying to answer unanswerable queries hurt UX.

Root cause: The RAG system could not answer all customer-care questions, especially complex ones.

Resolution: Add an ML classifier to activate the system only when it predicts answerability.

“A key to improving user experience is to reduce the number of times our system can’t answer the user. To achieve this, we developed a Machine Learning classifier”article, stated
“To achieve this, we developed a Machine Learning classifier model to predict if our system could answer the user query.”article, stated

RAG could not solve action-oriented or conversational support tasks.

Root cause: The system only produced descriptive answers and lacked seamless multi-turn conversation or back-office actions.

Resolution: Explore agentic frameworks as a second-stage architecture beyond the RAG ceiling.

“It struggles with complex user queries and resolving issues beyond FAQs. It only gives descriptive answers.”article, stated
“They enable back office actions, enriching queries with more context or allow user interaction.”article, stated

Evaluation

Doctolib built a Ragas-based evaluation tool for component-wise and end-to-end RAG evaluation. The evaluation tracks context precision, context recall, faithfulness, and answer relevancy, and uses annotated groundtruth records as perfect-answer benchmarks. The team then ran experiments across hybrid search, prompt engineering, LLM parameters, chunking, embedding models, fine-tuning, and reranking.

Metrics: context precision · context recall · faithfulness · answer relevancy · 20% customer care case deflection reduction · latency reduced from 1 minute to under 5 seconds · answerability classifier precision/reach tradeoff

3 supporting quotes
“It gives us metrics to evaluate our RAG system, both component-wise and end-to-end”article, stated
“Faithfulness which measures the factual accuracy of the generated answer”article, stated
“We tested the performance of different methods: hybrid search, prompt engineering, LLM parameters, chunking methods, embedding models and fine-tuning”article, stated

Outcomes

This case should count as a strong production RAG system, not a completed agentic system. Its value for the pattern library is the disciplined path from vanilla RAG to production: retrieval freshness, reranking, RAG-specific evals, classifier gating, and latency work before escalating to agents.

3 supporting quotes
“This improved our vanilla RAG. It has had a significant impact on customer care cases deflection with a 20% reduction.”article, stated
“Customer care agents can now focus on more complex cases.”article, stated
“To tackle those challenges, we explored agentic frameworks as a potential solution.”article, stated