Back to guides
3
5 min

Knowledge Retrieval

Finding the Right Answer

Why Retrieval Matters

Classification tells you WHAT the customer needs. Retrieval finds the answer. This is the step that determines whether the AI gives a helpful, specific response or a generic "please check our help center."

A great retrieval system finds "How to Reset Your Password" (KB-001, 342 helpful votes) within milliseconds when someone asks "I can't log in after changing my password." A bad one returns irrelevant results or nothing at all.

Key Concepts

The Two-Path Architecture

Support retrieval uses two paths, and always tries the fast one first:

Path 1: FAQ Fast Path (< 1ms)

80% of support queries are variations of 15-20 common questions. Title and tag matching identifies these instantly without running expensive vector search. "How do I reset my password?" matches "How to Reset Your Password" via direct title overlap.

Path 2: Full Hybrid Search (50-200ms)

For queries that don't match a known FAQ, combine keyword search with semantic search:

Search TypeStrengthExample
KeywordExact terms, IDs, code"Error 429", "POL-001"
SemanticMeaning, synonyms"can't access" ≈ "login issues"
FilteredMetadata constraintstopic=authentication, source=kb

Source Type Boosting

Not all sources are equally authoritative for answering questions:

SourceBoostRationale
Knowledge base+0.2Curated, reviewed, maintained
Product docs+0.15Official, versioned
Escalation rules+0.1Operational, current
Tickets+0.05Historical, may be outdated
CSAT+0.0Survey data, not answers

This means a KB article about password resets always outranks a 6-month-old resolved ticket about the same topic.

Popularity Signals

For KB articles, helpful votes provide a crowd-sourced relevance signal. An article with 342 helpful votes is more likely to be the right answer than one with 5 votes. This is the same principle as PageRank — popular content is more likely to be relevant.

The popularity boost is capped at 0.1 to prevent a popular-but-outdated article from outranking a new-but-accurate one.

Snippet Extraction

KB articles are long (500-2,000 words), but the response should cite a specific, relevant passage. Snippet extraction:

  • Splits content into paragraphs
  • Scores each by query term overlap
  • Returns the best paragraph (or best 3 sentences if the paragraph is too long)
  • The snippet includes character offsets for UI highlighting and a relevance score for confidence calculation.

    Architecture Pattern

    Customer Query
        │
        ├──→ FAQ Matcher ──→ Found? ──→ Return article + snippet
        │                       │
        │                       No
        │                       │
        └──→ Hybrid Search ──→ Score & Rank ──→ Top-K results
                  │
                  ├── Keyword match (title + content)
                  ├── Source type boost
                  ├── Popularity boost
                  └── Pre-filter by topic/category

    Category-Aware Search

    When the classifier says the topic is "authentication", the retriever can limit search to authentication-related documents before scoring. This narrows the search space and improves precision.

    Query Expansion

    "Can't log in" and "unable to access my account" mean the same thing but share no words. Query expansion adds synonyms from a support terminology map:

  • "log in" → "login", "sign in", "access", "authenticate"
  • "crash" → "freeze", "hang", "not responding"
  • "slow" → "performance", "loading", "latency"
  • What You'll Build

  • Walk through the FAQ fast path and understand when it fires vs falls through
  • Explore hybrid search with keyword matching and source boosting
  • See snippet extraction in action — how it finds the relevant paragraph
  • Extend with category-aware search, query expansion, or pgvector integration
  • Glossary

    TermMeaning
    FAQ fast pathTitle/tag matching for common questions (<1ms)
    Hybrid searchCombining keyword and semantic search
    Source boostingIncreasing scores for authoritative sources (KB > tickets)
    Snippet extractionFinding the most relevant paragraph in a long article
    Query expansionAdding synonyms to improve recall
    Reciprocal Rank FusionMethod for combining results from multiple search strategies

    This is chapter 3 of AI Customer Support Agent.

    Get the full hands-on course — free during early access. Build the complete system. Your projects become your portfolio.

    View course details