flowchart TD Query["User Query
Book 2 tickets to Boston
on March 15th for John Smith"]:::inputNode subgraph Rules["Rules - Fast, high precision"] direction TB Regex["Regex patterns"]:::ruleNode DateP["Date parser
extracts March 15th"]:::ruleNode NumE["Number extractor
extracts 2"]:::ruleNode Regex --> DateP --> NumE end subgraph ML["ML Model - Balanced accuracy and coverage"] direction TB BERT["BERT-based NER"]:::mlNode TokC["Token classification"]:::mlNode MLout["Person John Smith 0.94
Location Boston 0.89"]:::mlNode BERT --> TokC --> MLout end subgraph LLM["LLM - Flexible fallback"] direction TB GPT["GPT-4 few-shot prompt"]:::llmNode Custom["Custom extraction"]:::llmNode Fallback["Fallback for
ambiguous cases"]:::llmNode GPT --> Custom --> Fallback end Query --> Rules Query --> ML Query --> LLM Merge["Merging Layer
Conflict resolution
Priority Rules then ML then LLM
Confidence aggregation"]:::mergeNode Rules --> Merge ML --> Merge LLM --> Merge Link["Entity Linking - Canonicalization
Knowledge base lookup
Boston to Boston MA BST-MA-US
John Smith to Account 7834"]:::linkNode Merge --> Link Output["Structured Entity Dictionary
quantity 2
destination Boston MA
destination_id BST-MA-US
date 2024-03-15
passenger John Smith
passenger_id 7834"]:::outputNode Link --> Output classDef inputNode fill:#455a64,stroke:#263238,stroke-width:2px,color:#fff,font-size:14px classDef ruleNode fill:#2e7d32,stroke:#1b5e20,stroke-width:2px,color:#fff,font-size:14px classDef mlNode fill:#1976d2,stroke:#0d47a1,stroke-width:2px,color:#fff,font-size:14px classDef llmNode fill:#7b1fa2,stroke:#4a148c,stroke-width:2px,color:#fff,font-size:14px classDef mergeNode fill:#ef6c00,stroke:#e65100,stroke-width:2px,color:#fff,font-size:14px classDef linkNode fill:#00897b,stroke:#00695c,stroke-width:2px,color:#fff,font-size:14px classDef outputNode fill:#616161,stroke:#212121,stroke-width:2px,color:#fff,font-size:14px linkStyle default stroke:#888,stroke-width:2px,font-size:14px
Color Key
Input query
Rules (deterministic)
ML model (BERT NER)
LLM fallback
Merging logic
Entity linking
Structured output

Component Details

Hover over a box to learn what each extraction stage does.