Skip to content
mentoor

Topic 3 of 5 · 4 min read

Using Hub datasets and their cards

Goal: Decide from a dataset card whether a dataset may be used for a stated purpose.

A dataset on the Hub is easy to load in two lines, which is why you must read its card before you decide to use it.

Check yourself · 1 of 3

What is the best first step before training on a dataset you found on the Hub?

Choose one answer

Why it matters

Loading is not permission. Data may carry a licence that forbids your use, contain personal information, or overlap with the benchmark you plan to evaluate on. Each of those turns into a legal or a measurement problem later.

How to do it

  1. Look first, load second. The dataset viewer on the page shows real rows, columns and splits. Scan fifty rows for junk, duplicates and personal details.
  2. Load and pin. Use the datasets library, stream large sets, and pin a revision like you do with models.
  3. Read the card for the purpose you have. Training, fine-tuning, evaluation and redistribution can have different rules.
  4. Check the licence and where the data came from. A card can say one licence while the content was scraped from sources with others. A permissive tag is not a clearance for the underlying text or images.
  5. Look for personal data. Names, emails, chats and medical or financial text. If the card does not say how it was handled, assume it was not.
  6. Check contamination. If your eval set or a public benchmark appears inside training data, scores are inflated. Compare n-grams or exact strings between the two.
from datasets import load_dataset

ds = load_dataset("acme-labs/support-tickets", split="train",
                  revision="a41b7c0", streaming=True)
for row in ds.take(5):
    print(row)

Before and after

Weak: "It is on the Hub and has 40k rows, so we fine-tune on it."

Better: "The card says CC BY-SA 4.0, scraped from a public forum, with usernames removed but free-text posts intact. Share-alike conditions and personal details in posts mean legal review before training a model we ship. For internal evaluation only, we can proceed."

# Quick overlap check between your eval prompts and a training set
train_texts = {r["text"].strip().lower() for r in ds.take(100000)}
leaked = [p for p in eval_prompts if p.strip().lower() in train_texts]
print(len(leaked), "eval prompts appear verbatim in training data")

What goes wrong

  • Treating the licence tag as clearance. The tag describes the compilation, not every item in it.
  • Evaluating on contaminated data. A model that has seen the answers looks better than it is.
  • Missing personal data. Fine-tuning on it can make a model repeat it.
  • Loading the latest. Data can be edited or removed upstream, so results stop being reproducible.

Examples

Deciding on a support-ticket dataset

The card lists CC BY-SA 4.0, source: a public forum, personal data: usernames removed. Free-text posts may still hold emails and names. Decision: usable for internal evaluation after a scan for emails and phone numbers; not cleared for training a shipped model until legal reviews the share-alike term.

A score that looks too good

Your model scores 94 percent on a public question set. You search the training data for the first ten words of each test question and find 31 percent verbatim. Report the score on the unseen 69 percent, or build a private test set.

Key points

  • Open the dataset viewer and read real rows before you load or train on anything.
  • Check the card against your exact purpose: training, evaluation and redistribution can be treated differently.
  • A licence tag covers the compilation; the underlying content can have other terms, so read the source section.
  • Assume personal data is present unless the card states how it was removed.
  • Test for overlap between training data and your evaluation set, because contamination inflates scores.

Common mistakes

  • Loading a dataset and training on it without reading the card.
  • Reading a permissive licence tag as clearance for every item in the data.
  • Reporting benchmark scores without checking whether the test set leaked into training.
  • Streaming the latest revision, so a later edit silently changes your results.

Check yourself · 2 of 3

A dataset card says licence MIT, but the data was scraped from several websites. What does the MIT tag tell you?

Choose one answer

Check yourself · 3 of 3

Your fine-tuned model scores very high on a public benchmark. What check most directly tests whether the score is inflated?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic