Documentation Blog Free tools [email protected]Log in

How to create an LLM dataset: sourcing, formatting and quality control

An LLM dataset pipeline: raw web sources collected, cleaned and deduplicated, structured into examples, quality-checkedSourcesweb · docs · scrapeClean + dedupestrip noise, PIInear-dup removalStructureprompt / completionor chat turnsJSONLQCtrain-ready

Creating an LLM dataset is a pipeline, not a download: you decide what format your training goal needs, source raw text, clean and deduplicate it hard, structure it into examples, and quality-check before a single training step. Model quality is bounded by dataset quality — which is why teams spend far more time here than on the training run itself.

Start from the goal: which kind of dataset?

Before collecting anything, pin down what you are training and pick the matching format — they are not interchangeable:

GoalDataset shapeExample unit
Continued pre-training / domain adaptationRaw text corpusCleaned documents
Instruction fine-tuningPrompt → completion pairs{instruction, output}
Chat / assistant tuningMulti-turn conversations{messages: [system, user, assistant]}
Preference tuning (DPO/RLHF)Ranked pairs{prompt, chosen, rejected}

Most applied projects want instruction or chat data. Guides from AWS and the fine-tuning ecosystem converge on JSONL as the interchange format — one example per line — because it streams cleanly and every training framework reads it.

Source the raw material

Data comes from three places, usually in combination. Existing internal data — support tickets, docs, transcripts — is gold for domain models because it already reflects your task; it needs privacy scrubbing before anything else. Public datasets on hubs like Hugging Face give you a base to build on and a quality bar to beat. The open web is where you go for coverage, freshness or a domain no dataset covers — and this is a collection problem, not a training one. Scraping documentation, articles, product data or forum discussions at scale means fetching past blocks and turning messy HTML into clean text. A scraping API that returns Markdown is well suited here because Markdown preserves structure — headings, lists, tables — that raw HTML buries and plain-text extraction destroys, and structure is signal a model can learn from. For whole documentation sites or knowledge bases, a crawl collects every page in one job. We cover the collection side in depth in how to get data for AI.

Clean and deduplicate — where quality is won

Raw collected text is not a dataset. The cleaning stage is what separates a model that works from one that memorizes garbage:

  1. Strip boilerplate — navigation, ads, footers, cookie banners. Markdown-first collection front-loads most of this.
  2. Remove PII unless it is essential and lawful to keep — names, emails, IDs. This is a compliance requirement, not a nicety.
  3. Deduplicate aggressively. Near-duplicate documents are the single biggest quality killer in web-sourced data: they waste training compute and cause memorization. Use fuzzy matching (MinHash/LSH), not just exact-match, because the web is full of near-copies.
  4. Filter for quality — drop truncated, low-information or off-domain text with length and heuristic filters.
  5. Normalize encoding, whitespace and formatting so examples are consistent.

Structure into examples

Now shape the cleaned text into your chosen format. For instruction tuning, each example is an instruction and its ideal output; for chat, a conversation with roles. This is often the most labor-intensive step because good examples frequently need human authoring or careful templating — you cannot always mechanically derive "the ideal answer" from scraped text. A common accelerator is using a strong existing model to draft candidate examples from your raw corpus, then having humans review and correct them; it scales authoring without abandoning quality control. Keep a held-out split aside now, before any training, so your evaluation is honest.

Quality-check before you train

Never trust a dataset you have not looked at. Read a random sample by hand — a hundred examples will surface problems no metric catches. Check the distribution: is one source or topic dominating? Are lengths reasonable? Do the labels or completions actually answer the prompts? Automated checks (format validation, length histograms, duplicate rates, PII scans) catch the systematic errors; manual reading catches the subtle ones. Budget real time for this — a day spent auditing the dataset saves a week diagnosing a model that trained fine on bad data.

The build-vs-buy reality

For a domain model on data only you have, you build the pipeline — no shortcut exists for your proprietary tickets and docs. For coverage that requires the open web, the collection layer is the hard, ongoing part, and it is separable: describe the dataset you need and let it be assembled for you. That is what our AI web scraping service does — searches, maps and scrapes sources into structured CSV or JSON — while the underlying web-data APIs give you each layer (search, scrape, crawl, map) to wire into your own cleaning and formatting steps. Either way, the cleaning, dedup and structuring remain yours: that is where dataset quality — and therefore model quality — is actually decided.

Sources & further reading

FAQ

Quick answers on how to create llm dataset.

Something else? Ask us →

What format should an LLM dataset be in?

JSONL is the standard interchange format — one example per line — because it streams efficiently and every training framework reads it. The example shape depends on your goal: cleaned documents for pre-training, {instruction, output} pairs for instruction tuning, {messages:[...]} for chat, {prompt, chosen, rejected} for preference tuning.

How much data do I need to fine-tune an LLM?

Far less than pre-training and quality beats quantity: many instruction-tuning projects see strong results from a few hundred to a few thousand high-quality, diverse examples. A thousand carefully curated, deduplicated examples typically outperform tens of thousands of noisy, near-duplicate ones.

Can I scrape the web to build a training dataset?

Yes, and it is common for coverage a public dataset doesn't provide. Collect public pages, convert to clean Markdown to preserve structure, then deduplicate and filter hard. Respect robots.txt and copyright, scrub personal data, and remember that scraped text is raw material, not a finished dataset.

What is the most important step in dataset creation?

Cleaning and deduplication. Near-duplicate and low-quality documents are the biggest quality killers in web-sourced data — they waste compute and cause the model to memorize rather than generalize. Aggressive fuzzy deduplication plus quality filtering does more for model performance than collecting more raw data.

How do I create instruction-tuning examples from raw text?

Templating works for structured sources; for the rest, a common pattern is using a strong existing model to draft candidate instruction-output pairs from your raw corpus, then having humans review and correct them. This scales authoring while keeping a human in the loop. Always hold out an evaluation split before training.

Get the raw material without the collection burden

Scrape sources into clean, structured Markdown or JSON ready for your cleaning pipeline — or describe the whole dataset and let Quantic AI build it. Pay per success, $2 free every month.

Related reading