DEV Community

Cover image for Day 05/90: Duplicate Records in RAG — When Different Names Refer to the Same Entity
Rimsha Kanwal
Rimsha Kanwal

Posted on

Day 05/90: Duplicate Records in RAG — When Different Names Refer to the Same Entity

Imagine a RAG system that retrieves all the right documents.

The customer record is there. The support ticket is available. The related development issue has been documented.

But when the system connects everything, it ends up linking the wrong records.

So what went wrong?

The problem isn't necessarily retrieval. Sometimes, it's entity resolution.

In enterprise systems, the same customer, company, or product can appear under different names, identifiers, and formats. Even when a RAG system retrieves relevant information, it may fail to recognize which records belong to the same real-world entity.

This creates an interesting challenge: How can a RAG system connect the right information without accidentally combining records that belong to different entities?

1. The Problem: One Customer, Three Different Records

Consider an enterprise AI assistant connected to Salesforce, Zendesk, and Jira.

A user asks:

Which support issues are still unresolved for Al Noor Trading?

The system finds these records:

System Customer Name Record
Salesforce Al Noor Trading LLC Customer ID: 1042
Zendesk Al-Noor Trading Ticket #582
Jira ALNOOR Trading Issue #DEV-219

These are fictional records used to explain the problem.

At first glance, the names look almost identical.

They might all refer to the same company.

But how does the system know that?

A vector search may retrieve all three records because their contents are semantically similar. However, similarity alone doesn't confirm that they refer to the same organization.

Semantic similarity is not the same as entity identity.

Two different companies can have similar names. Meanwhile, the same company may have completely different identifiers across business systems.

This leads to two common problems:

  • False split: Records belonging to the same entity are treated as separate entities.
  • False merge: Records belonging to different entities are incorrectly combined.

Both can produce inaccurate answers, even when the relevant documents are available.

2. Why Better Embeddings Aren't Always Enough

When a RAG system retrieves incorrect information, improving the embedding model often seems like a reasonable solution.

But embeddings primarily capture semantic relationships. They don't guarantee real-world identity.

Think about these questions:

  • Is "Al Noor Trading LLC" the same company as "Al-Noor Trading"?
  • Does the support ticket belong to the main company or one of its subsidiaries?
  • Is an older CRM record still valid?
  • Which record should be trusted when two systems disagree?

These questions involve more than text similarity.

They require understanding identifiers, relationships, timestamps, and data sources.

An embedding model may help identify potentially matching records, but an additional verification process is needed before treating them as the same entity.

That's where entity resolution becomes important.

3. Understanding Entity Resolution

Entity resolution is the process of identifying records that refer to the same real-world entity, even when their representations differ.

A simplified workflow looks like this:

Raw Records → Candidate Matching → Match Verification → Canonical Entity → Linked Evidence

Here's how each step works.

Step 1: Collect Records

Gather records from different sources, such as CRM platforms, customer support systems, databases, and internal documents.

Step 2: Generate Candidate Matches

Identify records that might represent the same entity.

Matching signals can include names, email addresses, business identifiers, locations, and other available attributes.

Step 3: Verify the Matches

Determine whether the candidate records actually refer to the same entity.

This may involve rule-based matching, similarity scoring, machine learning models, or human review.

Step 4: Assign a Canonical Identifier

Verified records can be associated with a shared entity identifier.

For example:

canonical_entity: customer_1042

aliases:
  - Al Noor Trading LLC
  - Al-Noor Trading
  - ALNOOR Trading

customer_records:
  - system: Salesforce
    id: "1042"

related_records:
  - system: Zendesk
    record_type: support_ticket
    id: "582"

  - system: Jira
    record_type: development_issue
    id: "DEV-219"
Enter fullscreen mode Exit fullscreen mode

Here, the support ticket and development issue are linked to the verified customer identity. They aren't treated as duplicate customer records themselves.

This distinction matters.

Entity resolution doesn't mean merging everything that looks similar.

The original records, source identifiers, timestamps, and evidence still need to be preserved.

If two records cannot be confidently matched, leaving the relationship unresolved is often safer than creating a false connection.

4. What Does Research Tell Us?

Entity matching has been studied extensively in database systems and machine learning.

One notable approach is Ditto, which uses pretrained language models to compare record pairs.

Instead of depending entirely on manually designed matching rules, it frames entity matching as a classification problem.

The underlying idea is that language models can help recognize equivalent entities even when their textual representations differ.

Another important research direction focuses on heterogeneity in entity matching.

Real-world systems rarely store data in a consistent format. Differences in structure, terminology, language, and representation make matching more difficult.

For example, a company might appear as:

  • Al Noor Trading LLC
  • Al-Noor Trading
  • شركة النور للتجارة

These names may refer to the same organization, but language and spelling differences create additional matching challenges.

Research into entity matching helps explain why simple string comparisons are often insufficient for complex enterprise datasets.

However, stronger matching models don't automatically guarantee better RAG answers.

Correct entity identification still needs to be combined with reliable retrieval and evidence handling.

5. How Can RAG Systems Handle Duplicate Records?

There are several possible approaches, each with different levels of complexity.

Approach 1: Retrieval Without Entity Resolution

A basic RAG pipeline retrieves documents using keyword search, vector search, or hybrid retrieval.

The LLM receives the retrieved documents and generates an answer.

This approach is relatively simple, but it depends heavily on the retrieved context.

If records use inconsistent names, the model may miss important connections or make incorrect assumptions about entity identity.

Approach 2: Normalization and Rule-Based Matching

A more structured approach standardizes records before matching them.

Common techniques include:

  • Converting text to a consistent case.
  • Normalizing punctuation and whitespace.
  • Standardizing known abbreviations and naming variations.
  • Comparing reliable business identifiers.
  • Using exact matches where stable identifiers are available.

These techniques can reduce unnecessary differences between records.

However, normalization cannot solve every problem.

Two unrelated organizations may still have similar names, and different subsidiaries may share identifying information.

Approach 3: Entity-Aware Retrieval

A more advanced system introduces entity resolution into the retrieval architecture.

Instead of relying only on document similarity, the system also uses verified entity relationships to identify relevant records.

For example, when a user asks about Al Noor Trading, the system can use a verified customer identifier to locate related support tickets and development issues.

A knowledge graph or relational database can help represent these connections.

The retrieval pipeline can then combine semantic search results with entity-linked evidence before passing the context to the LLM.

The goal is not simply to retrieve more documents.

The goal is to retrieve evidence associated with the correct entity.

6. How Should Entity-Aware RAG Be Evaluated?

A system shouldn't be considered reliable just because its final answer sounds convincing.

Entity matching and answer generation need to be evaluated separately.

Entity Matching Precision

Of all the predicted entity matches, how many are actually correct?

High precision means fewer unrelated records are incorrectly connected.

Entity Matching Recall

Of all the genuine matching records, how many does the system successfully identify?

High recall means fewer valid relationships are missed.

False Merge Rate

How frequently does the system incorrectly combine records belonging to different entities?

This is especially important when dealing with financial, customer, or other sensitive enterprise information.

Answer Accuracy

Can the system correctly answer questions that require information from multiple connected records?

Citation Correctness

Does the final answer reference documents or records that genuinely support its claims?

These measurements help distinguish between an entity matching problem, a retrieval problem, and a generation problem.

For example, even if the system correctly identifies the customer, it might still produce an incorrect answer when two sources contain conflicting information.

That's a different failure mode, and it needs to be evaluated separately.

7. The Risk of Incorrect Entity Matching

Entity-aware retrieval sounds promising, but it introduces additional risks.

Suppose two separate companies have nearly identical names.

If the system incorrectly merges their identities, it might retrieve financial records, support tickets, or internal documents associated with the wrong organization.

That incorrect relationship can affect every later retrieval step.

In some situations, a false merge may be more damaging than a missed match.

This is why reliable entity resolution requires more than a similarity threshold.

Depending on the application, it may also need confidence scores, source verification, provenance tracking, ambiguity handling, and manual review.

A knowledge graph can organize relationships, but it cannot guarantee that those relationships are correct.

A more complex retrieval architecture is only useful when it improves reliability without introducing unacceptable errors.

8. Final Takeaway

Duplicate records might look like a simple data-cleaning issue, but they can become a serious challenge for enterprise RAG systems.

Retrieving the right documents isn't always enough.

The system also needs to understand which records refer to the same entity, which relationships are trustworthy, and when the available evidence is insufficient to establish a connection.

This becomes especially important in applications connected to multiple databases, business platforms, and multilingual knowledge sources.

The central question is:

Are we retrieving information about the correct real-world entity, or simply retrieving text that looks related?

Entity resolution provides one way to address this challenge.

But the quality of the final answer still depends on how accurately those relationships are established, maintained, and used during retrieval.

Reliable RAG is not just about finding relevant information.

It's also about connecting the right information to the right entity.


Let's Discuss

Have you encountered duplicate records or inconsistent entity names while working with RAG systems, databases, or AI agents?

How would you prevent a RAG system from confusing two different customers or organizations with similar names?

I'd like to hear your thoughts.

Top comments (0)