Skip to the content.
Building an Intent Matching Engine | AI Systems Design From Scratch

Connect with Amin Boulouma Official

🏠 Documentation Hub 📝 Engineering Blog 💻 GitHub Repository

Intent Matching: From Raw Input to Structured Response

Amin Boulouma, Software Engineer

Building a conversational interface requires a mechanism to translate vague, human-readable input into specific, actionable “intents.” An IntentMatchingEngine is the bridge between chaotic user input and your application’s logic.

The Normalization Layer

Raw input is noisy. Users include punctuation, varying capitalization, and extraneous whitespace. The _normalize_text method is critical because it forces the input into a predictable format before processing begins.

Keyword Density Scoring

Rather than relying on brittle “exact match” logic, we use a scoring-based approach. Each intent is associated with a set of keywords; for every keyword found in the user input, the score for that intent increases.

for intent_name, data in self.intents.items():
    current_score = 0
    for keyword in data["keywords"]:
        if keyword in normalized_input:
            current_score += 1

Why Scoring Beats Exact Matching

  1. Fault Tolerance: If a user says “Please list all containers,” the engine still matches the list intent because the keyword “list” is detected, even though the overall sentence structure differs from the defined target.
  2. Ambiguity Resolution: If an input matches multiple intents, the highest score wins, providing a simple yet effective way to resolve competing interpretations of user input.

Architectural Workflow

The engine follows a linear, deterministic path for every input received:

  1. Normalization: Strip noise, normalize case.
  2. Scoring: Evaluate the cleaned string against all registered intent keyword pools.
  3. Thresholding: Determine if the highest_score is sufficient to trigger a response.
  4. Fallback: If no match passes the score threshold, return a “rephrase” prompt to the user.

Best Practices

By prioritizing normalization and using a score-based evaluation, you build a foundation that is predictable, easy to debug, and highly extensible.

Connect with Amin Boulouma Official