data-estate / README.md
EMTIAZZ's picture
Refreshed synthetic data (new seed, company, id scheme, counts)
d385479 verified
|
Raw
History Blame Contribute Delete
12.4 kB
---
pretty_name: Insurance Claims & Customer Data (Synthetic Sandbox)
license: other
license_name: mixed-see-card
language:
- en
tags:
- insurance
- rag
- data-engineering
- synthetic
- ocr
- mlops
task_categories:
- question-answering
- table-question-answering
- image-to-text
size_categories:
- 1K<n<10K
---
## Quick start — get everything in one command
```bash
pip install -U huggingface_hub
hf download EMTIAZZ/data-estate --repo-type dataset --local-dir ./data-estate
```
This downloads **everything** (all tables, PDFs, scanned images, emails, and transcripts) into
`./data-estate`. See [How to download](#how-to-download) for more ways.
---
## Hints
These are **hints, not answers**. They point out what to look for in each kind of data and what
to think about. Picking the tools and building the pipeline is your job.
All the data is connected: the same customer, policy, and claim show up in many places. Keep that
connection through every step, so any answer can be traced back to where it came from.
### The kinds of data, and what to think about
| Kind of data | How to ingest it (batch / streaming) | Where to keep it |
|---|---|---|
| Customer records (tables) | Load all the old data once (**batch**), then capture new changes as they happen (**streaming**) | A database with tables you can join |
| Policy and claim records (tables) | Same — load everything once (**batch**), then keep capturing changes (**streaming**) | A database with tables you can join |
| PDFs and scanned forms (images — you must read the text out first) | Load the old pile once (**batch**); when a new file arrives, read it then (**streaming**) | Keep the original files; put the text you pull out in a database, and also in a **retrieval (search) index** |
| Emails (with reply history; personal info inside the text) | Load the old emails once (**batch**); **stream** new ones as they arrive | Keep the originals; put the text in a **retrieval (search) index** |
| Call transcripts (spoken chats; personal info inside the text) | Load the old ones once (**batch**); **stream** new ones as calls finish | Keep the originals; put the text in a **retrieval (search) index** |
| Reference support text | Just load it once (**batch**) | A database / search index |
### Where to store things
- **Original files:** keep every file exactly as it came in, so you can always redo the work.
- **Cleaned data:** **normalized, deduplicated** tables — cleaned to one common format with
duplicates removed — so you can join them.
- **Search data:** text turned into **embeddings** (numbers that capture meaning) kept in a
**retrieval index**. Think about mixing keyword search with **semantic** (meaning-based)
search, and keeping each customer's data separate.
- **History:** a note of where each piece of data came from (file → cleaned → search → answer).
### Q1 — ingesting the data (batch vs. streaming)
Decide which data you load **once** (the old history) and which data **keeps changing**. The
tables can be loaded once and then kept up to date. The files (documents, emails, calls) can be
loaded in bulk, then new ones handled as they arrive. The main question: where does **batch**
loading fit (big one-time loads), and where does **streaming** fit (handling items as they
arrive)?
### Q2 — clean, deduplicate, and normalize (and handle personal info)
- Personal info is **not only in the obvious table columns** — it's also inside the email text,
the call transcripts, and printed on the documents. So you must find it in the free text too,
after you pull the text out.
- **Deduplicate:** some customer records are the **same person saved more than once**, under
different IDs, with small differences (capital letters, spaces, a changed phone format). Match
people by who they are, not by their ID. For documents, compare both the image and the text;
for emails, don't count the same quoted message twice.
- **Normalize:** the tables don't use the **same column names or date format** — clean them into
one common shape.
### Q3 — getting data ready for search (chunks, embeddings, retrieval index)
- Split each kind of data into **chunks** in a sensible way: long documents, single table rows,
one email at a time, or one part of a conversation.
- Turn the chunks into **embeddings** and store them in a **retrieval index**. Only re-embed the
data that **changed**. Keep each customer's data separate. Think about how this stays fast with
millions of items, and how to mix keyword search with **semantic** (meaning-based) search.
### Q4 — preparing data to train models
- Build training and test sets from the **cleaned** data. Remove personal info first. Make sure
the **same person is never in both the training set and the test set**.
- When an input has a known correct answer (for example, a document and the values it should
produce), build those input–answer pairs from the connected records.
- Plan how you **save versions** of your datasets, track your experiments, and undo a change if
needed.
### Q5 — keeping it healthy over time
- Keep an eye on **health** (is the data fresh? did reading the files work? is anything piling
up?), **changes over time** (new kinds of records or new form layouts), and **answer quality**
(does each answer point to a real source?).
- Keep a record of **where each piece of data came from**, control **who can see what**, and plan
for **changes to the tables** so they don't quietly break your joins.
---
## What's inside
```
data-estate/
├── structured/ # the tables (load into a database)
│ ├── crm_customers.csv # customers + personal info
│ ├── erp_policies.csv # policies (different column names + date format)
│ ├── claims.csv # claims, linked to policies + customers
│ └── postgres_dump.sql # ready-to-load database file for all three tables
├── documents/ # claim forms
│ ├── pdf/<claim_no>.pdf # 450 claim-form PDFs
│ └── scans/<claim_no>.png # the same 450 forms as messy "scanned" images
├── emails/thread_*.txt # 700 support email threads (reply history + personal info)
├── transcripts/call_*.txt # 350 call transcripts (filler words + spoken personal info)
├── real/ # extra real support-chat data
│ ├── customer_support_faqs/data.csv
│ └── bitext_customer_support/data.csv
├── *_index.json # simple lists of the emails / calls / documents
├── MANIFEST.json # counts + how things connect + the messy parts
├── examples/quickstart.py # a ready-to-run example (load, join, read a file)
└── generate.py # the script that made the synthetic data
```
### The table files (in `structured/`)
| File | Comes from | Main columns | Notes |
|---|---|---|---|
| `crm_customers.csv` | CRM | `customer_id`, `full_name`, `email`, `phone`, `dob`, `ssn`, address… | lowercase names, ISO dates. **About 8% are duplicate rows.** |
| `erp_policies.csv` | ERP | `PolicyNo`, `CustomerID`, `LineOfBusiness`, `Premium`, `EffectiveDate`… | different name style, **`MM/DD/YYYY` dates** (different on purpose). |
| `claims.csv` | claims | `claim_no`, `policy_no`, `customer_id`, `line`, `filed_date`, `amount_claimed`, `status` | links policies and customers. |
### The files (documents, emails, calls)
- **`documents/scans/<claim_no>.png`** — claim forms made to look like real scans (gray, tilted,
noisy, blurry). **Read the text and fields out of these images.**
- **`documents/pdf/<claim_no>.pdf`** — the clean PDF of each form.
- **`emails/thread_*.txt`** — back-and-forth support emails with reply history; the customer's
**personal info is in the signature**.
- **`transcripts/call_*.txt`** — agent/customer phone chats with filler words ("um", "uh") and
**personal info said out loud** (phone, date of birth).
### How everything connects
```
crm_customers.customer_id ─┐
├─► erp_policies.CustomerID
│ └─ erp_policies.PolicyNo ─► claims.policy_no
└─► claims.customer_id
└─ claims.claim_no ─► documents/{pdf,scans}/<claim_no>
─► emails (subject + body)
─► transcripts (header + body)
```
The **same person shows up in a claim, a scanned form, an email, and a call.** That's what makes
joining, cleaning, and tracing the data a real challenge.
### The messy parts (on purpose)
- **Duplicate customers:** the same person saved under different IDs, with capital-letter,
spacing, and typo changes, different phone formats, slightly different emails, and some missing
fields.
- **Different table styles:** one table uses lowercase names + ISO dates, the other uses
CamelCase names + `MM/DD/YYYY` dates.
- **Personal info inside text:** in emails, transcripts, and scanned forms.
- **Messy scans:** hard to read, like real scans.
### How much data
| Data | Count |
|---|---|
| Customer rows (including duplicates) | 2,592 |
| Policies | 3,100 |
| Claims | 3,900 |
| Scanned forms (PNG) + PDFs | 450 + 450 |
| Support email threads | 700 |
| Call transcripts | 350 |
| Extra real support records | 1,700 |
---
## How to download
### Option A — one command, everything (easiest)
```bash
pip install -U huggingface_hub
hf download EMTIAZZ/data-estate --repo-type dataset --local-dir ./data-estate
```
### Option B — Python, everything
```python
from huggingface_hub import snapshot_download
path = snapshot_download(repo_id="EMTIAZZ/data-estate",
repo_type="dataset", local_dir="data-estate")
print("downloaded to:", path)
```
### Option C — only part of it (just the images, or just the tables)
```python
from huggingface_hub import snapshot_download
# only the scanned images:
snapshot_download("EMTIAZZ/data-estate", repo_type="dataset",
local_dir="scans_only", allow_patterns=["documents/scans/*"])
# only the tables:
snapshot_download("EMTIAZZ/data-estate", repo_type="dataset",
local_dir="tables_only", allow_patterns=["structured/*"])
```
### Option D — one file, no extra tools
```python
import pandas as pd
url = "https://huggingface.co/datasets/EMTIAZZ/data-estate/resolve/main/structured/claims.csv"
claims = pd.read_csv(url) # loads straight from the web
```
```bash
# or with curl:
curl -L -o claims.csv "https://huggingface.co/datasets/EMTIAZZ/data-estate/resolve/main/structured/claims.csv"
```
### Option E — git clone (needs git-lfs for the images/PDFs)
```bash
git lfs install
git clone https://huggingface.co/datasets/EMTIAZZ/data-estate
```
---
## How to use it
### Load and join the tables
```python
import pandas as pd
root = "data-estate" # the folder you downloaded
cust = pd.read_csv(f"{root}/structured/crm_customers.csv")
pol = pd.read_csv(f"{root}/structured/erp_policies.csv")
claims = pd.read_csv(f"{root}/structured/claims.csv")
# join the three tables (the column names don't match, so map them):
full = (claims
.merge(cust, on="customer_id", how="left")
.merge(pol, left_on="policy_no", right_on="PolicyNo", how="left"))
print(full.shape)
```
### Load the tables into a database
```bash
createdb insurance
psql -d insurance -f data-estate/structured/postgres_dump.sql
```
### Open a scanned form and find its correct values
```python
from PIL import Image
import pandas as pd, glob, os
root = "data-estate"
scan = sorted(glob.glob(f"{root}/documents/scans/*.png"))[0]
claim_no = os.path.basename(scan).replace(".png", "")
img = Image.open(scan) # read the text out of this image
truth = pd.read_csv(f"{root}/structured/claims.csv").query("claim_no == @claim_no")
print(claim_no, img.size, "\ncorrect values:\n", truth.T)
```
### Read an email or a transcript
```python
print(open(f"{root}/emails/thread_0000.txt").read())
print(open(f"{root}/transcripts/call_0000.txt").read())
```
### Or just run the example
```bash
python data-estate/examples/quickstart.py data-estate
```