liveBook · Manning

Exact string matching

As explained in Building Reliable AI Systems

A matching technique that considers two strings a match only when their text is identical.

Exact string matching treats two strings as a match only when their text is identical. In an LLM system, it can serve two different jobs: finding a cached response for a repeated query and checking a specific value in an agent’s claim against grounding data. The match is predictable, but it is not, by itself, proof that an answer is correct. section 9.2.3 section 9.1.1

if "What are your store hours?" in local_dictionary_cache:
    return local_dictionary_cache["What are your store hours?"]

A dictionary lookup illustrates the simplest cache: return a stored response when the incoming query exactly matches a stored key. section 9.2.3

This cache avoids another LLM call when a user or script repeats a query verbatim. It misses differently phrased questions with the same answer, such as “What time do you close?” and “When are you open?” Semantic caching is an alternative when that reuse matters. section 9.2.3

For hallucination checks, exact matching is one automated option for specific values alongside semantic similarity and rules for structured data such as prices and dates. Flag discrepancies or unsupported claims for review; nuanced adversarial cases may need domain experts rather than a string comparison alone. section 9.1.1

How Building Reliable AI Systems covers it

How deep it goes
Shows a Python dictionary lookup and identifies value checking, but does not provide a complete claim-validation implementation.
Examples
Contrasts verbatim store-hours queries with differently phrased questions and uses warranty, shipping, and return-policy claims as validation targets.
What you can do after
Apply it via a Python dictionary to reuse verbatim-query responses, and evaluate its limits when checking claims or near-duplicate queries.
How it connects
Connects exact matching to caching, semantic caching, grounding data, and hallucination evaluation.

This explainer was generated by Manning's knowledge graph from the text of Building Reliable AI Systems. The section links point to the parts of the book it draws on.