What Is Data Cleaning? Steps, Examples and Use in AI

LLM foundationsRetrieval and dataPublished Updated By Simon Budziak

Data cleaning is the process of finding and fixing errors in raw data before it is used. It removes duplicates, fills or flags missing values, standardizes formats and corrects invalid entries, so that analysis, model training or retrieval works on records that mean what they appear to mean.

What are the steps of data cleaning?

  1. Profile first: count nulls, distinct values and outliers per column before changing anything.
  2. Remove exact and near duplicates, deciding which record survives.
  3. Standardize formats: dates, currencies, units, country codes, casing.
  4. Handle missing values: fill only where a rule justifies it, otherwise flag.
  5. Validate against rules, such as a tax number checksum or a date range, and route failures to a person.
  6. Log every change so the cleaned set can be rebuilt from the raw one.

Cleaning is one stage of a data pipeline, and it should run there on every load, not once in a notebook.

How is data cleaning different for LLMs and RAG?

Tabular cleaning fixes values. Text cleaning for a RAG system fixes documents: it strips navigation and boilerplate, removes outdated versions so the assistant cannot quote last year’s policy, deduplicates near-identical files and keeps metadata such as owner and date for filtering. For retrieval, deleting a stale document is often worth more than any tuning of the model. What survives then goes to document chunking.

How do we deduplicate terms before measuring them?

Before we pay to measure a list of candidate glossary terms, we clean the list in two passes. The first pass is mechanical: each term is turned into a URL slug, then normalized by dropping a small set of stopwords such as “ai”, “the” and “in”, so “AI in finance” and “finance AI” collide, and the published-page audit fails the build on any such collision. The second pass is judgment: the normalizer catches spelling only, so a person or an agent then decides whether “function calling” and “tool calling” are one concept. A variant becomes a section on the existing page, never a second record. Mechanical rules catch spelling; only judgment catches meaning.

Written with AI assistance and reviewed by Simon Budziak. The production notes come from systems Soba Labs builds and runs.

Frequently asked questions

What is the difference between data cleaning and data preprocessing?

Data cleaning fixes errors so the data is correct. Preprocessing is the wider preparation step that also transforms correct data into the shape a model needs, such as scaling numbers, encoding categories or chunking documents.

Can AI clean data automatically?

It can do much of the matching and standardizing, such as spotting near-duplicate companies or normalizing addresses, but a person should set the rules and review a sample, because an automated fix applied to a wrong rule spreads the error everywhere.

How long does data cleaning take?

On most projects it takes longer than the modeling. Budget for it explicitly and fix the source system where you can, otherwise the same errors arrive again with the next export.

Summarize this page with

Train your team to build this