Skip to content

Lesson 3 of 6 · 6 min · +100 XP

How is the training data for a language model cleaned?

Raw web text is messy, so it runs through a cleaning line before training. Filters strip menus and cookie banners, drop broken pages, remove spam and copies of the same text, keep mostly well-written sentences and blank out private details like emails and phone numbers. Most crawled text is thrown away; the cleaner the data, the better the model.

▶ Try it

Why it matters

A model learns whatever it reads, including spam, copies and phone numbers. Cleaning decides what the model will sound like and what it might repeat.

In 6 minutes you'll be able to

  • Anything you post publicly may end up in a crawl, so keep phone numbers and addresses off open pages.
  • When a model repeats spam phrases or odd boilerplate, it's a sign of what was in its data.
  • Ask AI providers how they filter private details; good ones describe it in their documentation.

What you'll practise

  1. Strip the page

    The crawler saved this news page. Tap every part that isn't the article itself.

    Harbour Daily
    🍪 We use cookies. Accept all?
    Home · News · Sport · Weather · Log in

    Town opens a library of things
    From Monday, residents can borrow drills, tents and sewing machines for free. “People were buying tools they used once,” says librarian Ines Moreau.
    SPONSORED: Lose 10 kg in 3 days!!! Click here
    © Harbour Daily · Privacy · Terms · Share on social
  2. Run the cleaning line

    Pages arrive one by one. Black out private details by tapping them, then send each page to the right bin.

    1. How bees find their way home (nature-notes.example/bees) → ✅ Keep

      Honeybees use the sun as a compass. On cloudy days they read patterns in the light, and they remember landmarks along the way, from trees to fences.

      A clear, well-written article. This is exactly the kind of text Vireo should learn from.

    2. CHEAP SHOES best cheap shoes BUY (best-cheap-shoes.example/cheap-shoes) → 🚫 Spam

      cheap shoes best cheap shoes buy now cheap shoes free cheap shoes best price click here cheap shoes!!!

      Keywords stuffed in for search engines, not people. A model that reads this learns to babble.

    3. Re: my bike chain squeaks (fixit-forum.example/squeaky-chain) → ✅ Keep

      Wipe the chain with a rag, put one drop of oil on each link and spin the pedals. Still squeaky? Write to me at maria.k@mailbox.example [EMAIL] or call 555-0142 [PHONE].

      Useful advice from a real person. Keep the advice, but only once the contact details are blacked out.

      • [EMAIL] maria.k@mailbox.example: An email address points to a real person. It goes, the helpful advice stays.
      • [PHONE] 555-0142: A phone number is private. A model that memorizes it could repeat it to anyone.
    4. How bees find their way home (copy-news.example/bees-home) → 📑 Duplicate

      Honeybees use the sun as a compass. On cloudy days they read patterns in the light, and they remember landmarks along the way, from trees to fences.

      Same fingerprint as the bee article you already saw. Repeated text makes a model memorize instead of learn.

    5. Loading… (shop.example/loading) → 🧩 Broken

      Accept all cookies? Yes · No · Menu · Home · Log in · Basket (0) · © All rights reserved · Loading… Loading…

      Only buttons and menus, no real sentences. Broken pages like this are thrown away.

    6. Tomato soup in 20 minutes (home-kitchen.example/tomato-soup) → ✅ Keep

      Soften an onion in olive oil, add two tins of tomatoes and a pinch of sugar, simmer for 15 minutes, then blend. Just like they make it in Naples.

      A clear recipe in real sentences. Into the training set it goes.

      • ✓ Naples: A city isn't a private detail, it's part of the recipe's story. Only details that point to a person need to go.
    7. Top 10 best top 10 reviews (top10-reviews.example/top-10-best) → 🚫 Spam

      Top 10 best products. Best top products review. This product is the best product for best results. Buy best product. Top best 10.

      Machine-made filler that repeats itself and says nothing. Quality filters drop it.

  3. Why bother cleaning?

    1. The same article appears 500 times in the crawl. Why keep only one copy?

      • Repeats push the model to memorize that text word for word (Answer)
      • Copies are fine, more data is always better
    2. Can a cleaning line catch every private detail?

      • No, filters miss things, so some can slip through (Answer)
      • Yes, computers find every name and number

Remember

A model is only as good as the text it learns from. Cleaning drops junk and copies and blanks out private details.

Most crawled text never reaches training. What's left is filtered, de-duplicated and scrubbed of private details.

Key facts

  • Removing duplicate text from training data made language models repeat memorized text far less often and train more efficiently. · Source: Lee et al., Deduplicating Training Data Makes Language Models Better, ACL 2022
  • Researchers showed that a language model could reproduce pieces of its training data word for word, including names, phone numbers and email addresses. · Source: Carlini et al., Extracting Training Data from Large Language Models, USENIX Security 2021
  • The C4 dataset was built by cleaning Common Crawl with simple rules: keep lines that end in punctuation, drop pages with placeholder text or code, and remove repeated passages. · Source: Raffel et al., Google, Exploring the Limits of Transfer Learning (T5), 2020
  • Data cleaning usually removes most of what a crawler collects, which is why teams start from very large crawls.

Updated:

Questions people ask

How do AI companies clean training data?

They extract the main text from each page, filter out spam, broken and low-quality pages, remove duplicates and blank out personal details such as emails and phone numbers. Many teams also use small models to score text quality.

Why are duplicates removed from training data?

Text a model sees many times is more likely to be memorized and repeated word for word. One copy is enough to learn from, and removing the rest saves computing time.

Is personal information removed from AI training data?

Usually some of it is: filters catch patterns like email addresses and phone numbers. But filters can miss details, so personal information can still slip through.

Related terms