Tuning RAG Search for Customer Support Chatbot

elastic · Tech · 2024 · source Agentic: no · promotional bias: med · 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: Customer support RAG search relevance

Elastic's Support AI Assistant had a working RAG chatbot, but search relevance failed for CVEs, product-version queries, semantic matching, and duplicate content, weakening the context available to GPT-4.

Constraints:

Architecture

Elastic tuned the RAG retrieval layer with hybrid BM25 plus ELSER semantic search, conditional boosting for CVE/title and version fields, GPT-4-generated field enrichment, collapse-based deduplication, and Precision@K evaluation against curated support queries. Search results fed a GPT-4 generation pipeline through Azure OpenAI.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  support_content_corpus["Support content corpus"] --> elasticsearch_index["Elasticsearch index"]
  support_content_corpus --> gpt_4_enrichment_pipeline["GPT-4 enrichment pipeline"]
  gpt_4_enrichment_pipeline --> elasticsearch_index
  elasticsearch_index --> hybrid_search_query["Hybrid search query"]
  hybrid_search_query --> gpt_4_answer_generator["GPT-4 answer generator"]
  gpt_4_answer_generator --> support_chat_interface["Support chat interface"]
  support_chat_interface --> feedback_analytics["Feedback analytics"]
  feedback_analytics --> evaluation_test_cases["Evaluation test cases"]
  evaluation_test_cases --> hybrid_search_query
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Support content corpus Contains support knowledge articles, product documentation, and blog content. Elasticsearch index, GPT-4 enrichment pipeline
GPT-4 enrichment pipeline Generates improved field summaries for search and future applications. Support content corpus, Elasticsearch index
Elasticsearch index Stores documents and supports hybrid keyword/semantic search. Hybrid search query, GPT-4 enrichment pipeline
Hybrid search query Combines BM25, ELSER semantic search, boosts, and collapse deduplication. Elasticsearch index, GPT-4 answer generator
GPT-4 answer generator Generates the support answer from the top 3 retrieved documents. Hybrid search query, Support chat interface
Support chat interface Collects user questions and feedback events. GPT-4 answer generator, Feedback analytics
Feedback analytics Stores feedback and query patterns for relevance tuning. Support chat interface, Evaluation test cases
Evaluation test cases Curated cases used to measure Precision@K relevance. Feedback analytics, Hybrid search query

Data flow

Elastic crawls support articles, documentation, and blogs into Elasticsearch, enriches fields such as summaries, builds hybrid BM25/ELSER search queries, boosts title or version fields conditionally, collapses duplicate-like content, passes the top 3 results into a system prompt, and sends context plus conversation to GPT-4.

3 supporting quotes
“For querying, the team implemented a hybrid search strategy combining BM25 (keyword-based search) with ELSER (Elastic Learned Sparse EncodeR) for semantic search.”summary, stated
“after search, the system built a system prompt with instructions and the top 3 search results as context, then fed the conversation alongside the context into GPT-4”summary, stated
“feedback collection, the team used a third-party tool to capture client-side events, storing data in BigQuery for analysis.”summary, stated

Why this architecture

Elastic treated RAG quality as a search-tuning problem: semantic retrieval alone was not enough for CVE codes, product versions, stale summaries, and duplicate content.

“Their approach emphasizes that RAG tuning is fundamentally a search problem requiring both high-quality data and accurate retrieval”summary, stated
“while semantic search is powerful, understanding and leveraging user intent patterns can provide simple but highly effective optimizations”summary, stated

Models used: ELSER · GPT-4 · Azure OpenAI

Scale

Alternatives considered (roads not taken)

Semantic search alone

Rejected because: CVE and version queries needed targeted lexical and field boosts.

“users often include near-exact CVE codes in their queries, and these codes typically appear in the article titles.”summary, stated

Use crawled first-body-text summaries as embeddings

Rejected because: They poorly represented product documentation content.

“the summary field for Product Documentation articles was simply the first few characters of the document body, generated during the crawling process.”summary, stated

Patterns

hybrid-search (retrieval)

Elastic combined BM25 keyword search with ELSER semantic retrieval.

“For querying, the team implemented a hybrid search strategy combining BM25 (keyword-based search) with ELSER (Elastic Learned Sparse EncodeR) for semantic search.”summary, stated

retrieval-ranking (search tuning)

Conditional boosts and collapse deduplication shaped which documents appeared in the top 3.

“conditional boosting of title and version fields, AI-generated field enrichment using GPT-4, and Elasticsearch's collapse parameter”summary, stated

eval-driven-development (search relevance)

Precision@K against curated test cases guided relevance improvements.

“By implementing a systematic evaluation framework using Precision@K metrics against curated test cases, they achieved a ~75% improvement in top-3 search relevance while also generating over 300,000 AI-generated summaries for future applications.”summary, stated

data-quality-loop (field enrichment)

GPT-4 generated better summaries to improve semantic retrieval quality.

“To solve this, the team developed a custom AI Enrichment Service using GPT-4 to generate four new fields: a proper summary, category classification, tags, and topics.”summary, stated

Tradeoffs

Use hybrid retrieval.

Chose BM25 plus ELSER over Pure keyword or pure semantic retrieval.

Rationale: Support queries mix exact identifiers, versions, and semantic intent.

“The semantic component used text_expansion queries against both title and summary embeddings, while the keyword component employed cross_fields matching”summary, stated

Limit generation context to top 3 results.

Chose Small high-precision context over Passing more retrieved documents.

Rationale: Token constraints and user scale made precision in the top 3 essential.

“The limitation to only 3 results was driven by token constraints in their dedicated deployment combined with a large user base.”summary, stated

Gotchas (what bit them)

Semantic embeddings can fail on exact identifiers.

Root cause: CVE codes and product versions carry lexical structure that semantic matching may underweight.

Resolution: Detect identifier patterns and boost title/version fields conditionally.

“Customers frequently encounter security alerts about CVEs and naturally asked questions like "Does CVE-2016-1837 or CVE-2019-11756 affect Elastic products?"”summary, stated

Bad summary fields poison semantic retrieval.

Root cause: Crawler-generated summaries duplicated first body text rather than representing content.

Resolution: Use AI enrichment to generate better summaries.

“This redundancy created vector embeddings that poorly represented the actual document content. To solve this, the team developed a custom AI Enrichment Service using GPT-4 to generate four new fields: a proper summary, category classification, tags, and topics.”summary, stated

Small top-k context makes search mistakes expensive.

Root cause: Only three results could fit into the prompt under token constraints.

Resolution: Evaluate and tune top-3 precision directly.

“The limitation to only 3 results was driven by token constraints in their dedicated deployment combined with a large user base.”summary, stated

Evaluation

Elastic evaluated search tuning with Precision@K against curated test cases and feedback-derived query patterns.

Metrics: ~75% improvement in top-3 relevance. · Over 300,000 indexed documents. · Over 300,000 AI-generated summaries. · Top 3 search results used as LLM context.

“By implementing a systematic evaluation framework using Precision@K metrics against curated test cases, they achieved a ~75% improvement in top-3 search relevance”summary, stated

Outcomes

The system operated over a corpus of more than 300,000 support, documentation, and blog documents.

“achieved a ~75% improvement in top-3 search relevance while also generating over 300,000 AI-generated summaries”summary, stated