RAG-Based Benefit Matching Engine
A retrieval-augmented matching engine built with Python, LangChain, ChromaDB and Hugging Face embeddings. It takes benefits as they are worded in a policy and finds the best-matching entry in a standard benefit catalogue.
- ~85%
- of catalogue alignment automated
Problem statement
Problem statement
Once benefits are extracted from a policy, they still have to be mapped to a standard catalogue. The wording in policies rarely matches the catalogue wording, so the mapping was done by hand.
Business challenge
Business challenge
Exact and keyword matching fail when two descriptions mean the same thing but share few words. Pure semantic matching, on the other hand, can confidently pair things that only sound alike. The engine needed both signals.
Solution architecture
- 01
The benefit catalogue is embedded with a Hugging Face sentence-embedding model and indexed in ChromaDB.
- 02
Each extracted benefit is embedded and used to retrieve the nearest catalogue candidates by vector similarity.
- 03
Candidates are re-scored by combining semantic similarity with fuzzy string matching on names and key terms.
- 04
High-confidence matches are aligned automatically; the rest are returned as ranked recommendations for a reviewer.
01Indexing (offline)
Benefit catalogue
Standard names & descriptions
Embedding model
Hugging Face sentence embeddings
ChromaDB
Vector index + metadata
02Query (per benefit)
Extracted benefit
Name + description from policy
Query embedding
Same model as the index
Top-k retrieval
Nearest catalogue candidates
03Scoring
Fuzzy matcher
Token & string similarity
Score fusion
Semantic + lexical signals
04Decision
Auto-align
Above confidence threshold
Recommend
Ranked options for review
Workflow
- 1
Index the catalogue
Catalogue entries are normalized, embedded and stored in ChromaDB with their metadata.
- 2
Embed the benefit
Each extracted benefit is cleaned and embedded with the same model used for the index.
- 3
Retrieve candidates
A similarity search returns the top-k nearest catalogue entries.
- 4
Re-score
Fuzzy matching on names and key terms is combined with the semantic score.
- 5
Decide
Matches above the threshold are aligned automatically; others become ranked recommendations.
- 6
Learn from review
Reviewer decisions feed back into thresholds and catalogue synonyms.
Technology stack
- Python
- LangChain
- ChromaDB
- Hugging Face embeddings
- Sentence Transformers
- Fuzzy matching
- Vector search
Implementation details
- The same embedding model and text normalization are used at index and query time — a mismatch here is the most common silent failure in RAG systems.
- Catalogue metadata (category, benefit type) is stored with each vector so retrieval can be filtered before similarity is computed.
- The confidence threshold is a tunable setting, set from a labelled sample rather than guessed.
- Low-confidence matches are never dropped silently; they are surfaced with their scores so a reviewer can decide.
Engineering challenges
Similar wording, different benefits
Embeddings alone can pair benefits that read alike but differ in a key term. Combining semantic and lexical scores reduced these false positives.
Choosing the threshold
Too low and bad matches are auto-aligned; too high and reviewers do all the work. The threshold was calibrated against reviewed examples.
Catalogue drift
Catalogues change. Re-indexing had to be a routine, repeatable step rather than a one-time setup.
Business value and results
Business value
- Most catalogue alignment happens without manual effort.
- Reviewers spend their time on the genuinely ambiguous cases.
- Matching decisions are explainable: every match carries its scores.
Measured results
- ~85%of catalogue alignment automated
Figure is approximate and reflects the share of benefits aligned without manual intervention.
Screenshots, code and demo
Screenshots
Not published — the interface belongs to a client engagement.
Source code
Private — client-owned code.
Live demo
No public demo. Ask for a walkthrough.
Have an AI or Data Engineering challenge? Let's turn it into a working product.
Taking on a limited number of AI and data engineering projects. Typical reply within 2 business days.