Agentic AI Notebook
RAG Engineering
Phase 3Module 21 of 22

Entity Resolution

Extractors emit surface strings. Without merging, the graph thinks those names are strangers and multi-hop retrieval dies. ER is the unglamorous step that makes Graph RAG work.

ER is the office assigning one employee number even if badges say Nishtha S., N. Singh, and Nishtha Singh.

Visual Workflows

Start here — scroll inside each diagram frame to explore, then use + / to zoom up to 200% if needed.

Overview

100%
Loading diagram...

Scroll inside the frame to explore · use + / − to zoom up to 200%

100%
Loading diagram...

Scroll inside the frame to explore · use + / − to zoom up to 200%

Resolve then link

100%
Loading diagram...

Scroll inside the frame to explore · use + / − to zoom up to 200%

Do not build Graph RAG on raw strings. Merge first.

If you skip ER

100%
Loading diagram...

Scroll inside the frame to explore · use + / − to zoom up to 200%

The graph thinks Acme and ACME are strangers. Multi-hop dies.

Key Takeaways

  • 1.Entity resolution decides that Acme Inc, ACME, and Acme Corporation are the same real-world thing and merges them to one canonical id.
  • 2.Normalize strings (case, Inc/LLC, punctuation).
  • 3.Block likely pairs so you do not compare every entity to every other.
  • 4.Score with similarity and optionally an LLM judge.
  • 5.Write a canonical node with an aliases list and attach all facts there.

Real Example

Scenario

Legal docs say 'Beta Corp.' and emails say 'Beta'. After ER, one node owns both aliases, so 'who acquired Beta?' hits the same company Acme bought.

What you would do

In RAG Engineering, apply Entity Resolution to this scenario: Legal docs say 'Beta Corp. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.

Practice Task

Open the Code Walkthrough below and run it locally. Change one parameter related to Entity Resolution (e.g. model, temperature, top_k, or tool name), observe the difference in output, and write 2–3 sentences explaining what changed.

Code Walkthrough

Highlighted lines show where Entity Resolution happens in the code.

Entity Resolution
1# Entity Resolution — minimal example2from openai import OpenAI3
4client = OpenAI()  # create API client5
6# Ask the model to explain this topic7response = client.chat.completions.create(  # core API call for Entity Resolution8    model="gpt-4o-mini",9    messages=[10        {"role": "system", "content": "You explain entity resolution clearly."},11        {"role": "user", "content": f"What is entity resolution?"},12    ],13    temperature=0,14)15print(response.choices[0].message.content)  # show output for debugging

Commands

Commands to Remember

  • Normalize: case, legal suffixes Inc/LLC, punctuation
  • Blocking: only compare likely pairs, not N-squared
  • Store aliases on the canonical entity
  • Without ER, Graph RAG retrieves fragments of the same company

Cheat Sheet

Quick recap

quick ref
  • Same real-world thing → one id
  • Normalize, block, then match
  • Store aliases on the canonical node
  • Skip ER and Graph RAG fragments

Common Mistakes

  • Matching only exact strings
  • Merging different companies that share a common name
  • No alias list — you cannot explain why two mentions joined