Skip to content

Univo

Find duplicate records without crossing your rules. A different customer, environment or tax number rules a match out, whatever the score. Fuzzy and semantic matching, in Python, on your machine.

Get started See a real example

pip install univo

Five clients named Northwind. One is a duplicate.

# Tenant Name Activity VAT Compared with client 1
1 shop Northwind Traders online clothing store FR401 the record we check
2 shop Northwnd Traders shop selling clothes on the internet FR401 ✓ Duplicate score 0.91: a typo, and the same activity in other words
3 shop Northwind Traders steel manufacturer none ✕ Not a duplicate score 0.53: same name, another business
4 shop Northwind Traders online clothing store FR999 ✕ Ruled out another VAT number, whatever the score
5 bank Northwind Traders online clothing store FR401 ✕ Never compared another tenant

The code, and what it prints:

from univo import Exact, Finder, Schema, Text

schema = Schema(
    id_field="id",
    partition_by=["tenant"],                    # tenants are never compared
    fields={
        "name": Text(),                         # spelling: typos and case
        "activity": Text(mode="semantic"),      # meaning, with a local model
        "vat": Exact(conflict="reject"),        # a different VAT number rules a match out
    },
)
clients = [
    {"id": 1, "tenant": "shop", "name": "Northwind Traders", "activity": "online clothing store", "vat": "FR401"},
    {"id": 2, "tenant": "shop", "name": "Northwnd Traders", "activity": "shop selling clothes on the internet", "vat": "FR401"},
    {"id": 3, "tenant": "shop", "name": "Northwind Traders", "activity": "steel manufacturer", "vat": None},
    {"id": 4, "tenant": "shop", "name": "Northwind Traders", "activity": "online clothing store", "vat": "FR999"},
    {"id": 5, "tenant": "bank", "name": "Northwind Traders", "activity": "online clothing store", "vat": "FR401"},
]
for match in Finder(schema=schema).find(clients).matches:
    print(match.left_id, match.right_id, round(match.score, 2), match.reasons)
1 2 0.91 ['name: edit_distance', 'activity: semantic', 'vat: exact']

Spelling catches the typo, the local model reads the meaning of the activity, and the rules keep clients 4 and 5 out, even with min_score=0.01. The first run downloads the 15 MB model once; it then works offline.

No training, no API key, no server: records never leave your machine.

What it is for

Supplier lists, customer exports, scraped catalogs: group proposes which rows to merge. A veto keeps apart records that must never match.

from univo import Exact, Finder, Schema, Text

suppliers = [
    {"id": "A-17", "name": "Northwind Traders SAS", "city": "Lyon", "vat": "FR401"},
    {"id": "B-03", "name": "NORTHWIND TRADERS", "city": "LYON", "vat": "FR401"},
    {"id": "B-09", "name": "Northwind Trading", "city": "Paris", "vat": "FR777"},
    {"id": "A-21", "name": "Contoso Ltd", "city": "Leeds", "vat": None},
]
schema = Schema(id_field="id", fields={"name": Text(), "city": Text(), "vat": Exact(conflict="reject")})
groups = Finder(schema=schema).group(suppliers, min_score=0.7)
print([group.members for group in groups.groups])
[('A-17', 'B-03')]

B-09 has another VAT number, so it stays apart. On real data: nine lists of Chicago's early childhood sites.

Sign-ups, leads, tickets: check a record before storing it. In the Chicago example, a check against about 1,300 to 2,000 stored records took 0.12 ms at the median on a laptop (measured); the time grows with the records of a partition.

from univo import Exact, Finder, Schema, Text

finder = Finder(schema=Schema(id_field="id", fields={"name": Text(), "email": Exact()}))
finder.add([{"id": 1, "name": "Ada Lovelace", "email": "ada@example.org"}])

for signup in [
    {"id": 2, "name": "Ada Lovelace", "email": "ada@example.org"},
    {"id": 3, "name": "Ada Lovelce", "email": None},
    {"id": 4, "name": "Grace Hopper", "email": "grace@example.org"},
]:
    print(signup["id"], finder.check_or_add(signup).status)
2 matched
3 review
4 inserted

review means a similar record exists and nothing was stored: your application decides.

In a multi-tenant application, a record only matches records of its own tenant, and search only reads that tenant.

from univo import Finder, Schema, Text

schema = Schema(id_field="id", partition_by=["tenant"], fields={"name": Text()})
finder = Finder(schema=schema)
finder.add([
    {"id": 1, "tenant": "acme", "name": "Globex Corporation"},
    {"id": 2, "tenant": "initech", "name": "Globex Corporation"},
])
report = finder.search({"id": 3, "tenant": "acme", "name": "Globex Corporaton"})
print([match.right_id for match in report.matches])
[1]

Questions, descriptions, product titles: semantic fields compare meaning with a local model, downloaded once and run offline. The small default model catches close rewordings like this one, not every paraphrase.

from univo import Finder, Schema, Text

questions = [
    "How do I reset my password?",
    "What is the way to reset my password?",
    "How can I delete my account?",
    "Steps to change the password I forgot",
]
finder = Finder(schema=Schema(fields={"text": Text(mode="semantic")}))
report = finder.find([{"text": q} for q in questions], min_score=0.7)
for match in report.matches:
    print(questions[match.left_id], "~", questions[match.right_id], round(match.score, 2))
How do I reset my password? ~ What is the way to reset my password? 0.74

Services, hosts, settings: nested fields by path, hostnames normalized, environments as vetoes.

from univo import Exact, Finder, Schema, Text

services = [
    {"id": "svc-1", "name": "billing-api", "env": "prod", "db": {"host": "db1.internal", "port": 5432}},
    {"id": "svc-2", "name": "billing-api", "env": "prod", "db": {"host": "DB1.internal.", "port": 5432}},
    {"id": "svc-3", "name": "billing-api", "env": "staging", "db": {"host": "db1.internal", "port": 5432}},
]
schema = Schema(
    id_field="id",
    fields={
        "name": Text(),
        "env": Exact(conflict="reject"),
        "db.host": Exact(normalizer="hostname"),
        "db.port": Exact(),
    },
)
report = Finder(schema=schema).find(services)
print([(m.left_id, m.right_id, m.kind, round(m.score, 2)) for m in report.matches])
[('svc-1', 'svc-2', 'exact', 1.0)]

DB1.internal. and db1.internal are one hostname; svc-3 runs in staging and never matches production.

Rules hold where similarity fails

Two configurations that differ only by prod and staging look almost identical to an embedding model. Univo checks partitions and vetoes before any score.

SemHash does not claim to handle partitions or discriminant fields; its users filter them in their own code. Method and every result: benchmarks.

On real data

Nine public lists of Chicago's early childhood sites, the dataset of the Dedupe example:

3,337
rows from 9 sources, for 1,162 real sites
889
groups of proposed duplicates, without labelling
96%
precision on sites held out from tuning
0.1 s
for the whole dataset, on an Apple M2 laptop

Read the walkthrough

Measured, not promised

Synthetic company names, one partition. Univo's search is exhaustive; SemHash's index is approximate. Results depend on your data: measure on a sample of yours. Method and every result: benchmarks.

The default model loads in about 10 ms and adds 20 MiB of memory (measured).

Next