Here's our checker. For each split, we count problems. An intent we don't know is a problem. An empty message is a problem. And the book in the answer should appear in the message. Run it. A hundred and one problems! Let's look closer.
app.pypython
from datasets import load_datasetINTENTS = {"order_status", "return", "price", "stock", "complaint"}data = load_dataset("json", data_files={"train": "tickets_train.jsonl", "test": "tickets_test.jsonl"})for split, rows in data.items(): problems = 0 for row in rows: if row["intent"] not in INTENTS: problems += 1 if not row["message"].strip(): problems += 1 if row["book"] and row["book"] not in row["message"]: problems += 1 print(f"{split:5} {len(rows):4} rows {problems} problems")
Output
train 527 rows 101 problems
test 77 rows 15 problems
Many customers type in lower case, like persuasion, with a small p. Our check compared the exact capital letters, so it was too strict. The data was fine. The check was wrong. We compare lower case versions instead. Run it. Zero problems, in both splits.
app.pypython
from datasets import load_datasetINTENTS = {"order_status", "return", "price", "stock", "complaint"}data = load_dataset("json", data_files={"train": "tickets_train.jsonl", "test": "tickets_test.jsonl"})for split, rows in data.items(): problems = 0 for row in rows: if row["intent"] not in INTENTS: problems += 1 if not row["message"].strip(): problems += 1 if row["book"] and row["book"].lower() not in row["message"].lower(): problems += 1 print(f"{split:5} {len(rows):4} rows {problems} problems")
Now try it yourself. Add a check that every message is shorter than three hundred characters. Add a check for duplicate messages. And run the privacy scan on the test split too.
Let's recap. Write one script that checks every row. When it finds problems, ask if the data is wrong, or the check. And run it every time the data changes. Next, how to measure a fine-tuned model.