Fine-tuning is mostly about data. The model learns only what your examples show it. So let's learn the tool we'll use to load, and prepare, every example. The datasets library.
Training data usually lives in files. A very common format is JSON lines, with the ending dot j s o n l. Each line is one example, written as a small JSON object. It's easy to read, easy to add to, and works with any language. Our Riverside Books data uses it.
Load dataset reads our file. JSON says the format. Split equals train gives us one dataset. Then we print the dataset, the first row, and the first five intents. Run it. Five hundred and twenty seven rows, with three columns. Message, intent, and book. A row is just a Python dictionary. And asking for a column gives us a list.
app.pypython
from datasets import load_datasetds = load_dataset("json", data_files="tickets_train.jsonl", split="train")print(ds)print(ds[0])print(ds["intent"][:5])
Output
Dataset({
features: ['message', 'intent', 'book'],
num_rows: 527
})
{'message': 'Hello! The driver was rude when delivering Dune.', 'intent': 'complaint',
'book': 'Dune'}
['complaint', 'stock', 'return', 'return', 'price']
Why use this library, instead of a simple list or pandas? Because datasets can handle data far bigger than your memory. It saves results on disk, so repeated work is fast. And it plugs straight into the Hugging Face trainers. You can also turn any dataset into pandas, with to pandas, whenever you like.
Let's recap. Training data often lives in JSON lines files. Load dataset reads them. A row is a dictionary, and a column is a list. Next, changing, and filtering, our data.