AI & Data

Preparing Data for AI Models: Converting Datasets into LLM-Ready Formats

March 11, 2026·9 min read
Preparing Data for AI Models: Converting Datasets into LLM-Ready Formats
In this article
  1. 1.Step 1: Convert Raw Documents to Plain Text
  2. 2.Step 2: Clean and Normalise Text
  3. 3.Step 3: Choose the Right Format for Your Use Case
  4. 4.Step 4: Tokenization and Context Length

The quality and format of training data determines the quality of your AI model. Raw documents must be converted, cleaned, and structured before they can train or fine-tune an LLM.

Step 1: Convert Raw Documents to Plain Text

Source FormatConversion MethodOutput
PDF (text)pdfplumber, PyMuPDFPlain text (.txt)
PDF (scanned)OCR — instantconvert.io AI, Azure OCRPlain text (.txt)
DOCXpython-docx or pandocPlain text / Markdown
XLSXpandas read_excel()CSV or JSON
HTML/WebBeautifulSoup, TrafilaturaPlain text
AudioWhisper (OpenAI) transcriptionPlain text

Step 2: Clean and Normalise Text

  • Remove headers, footers, page numbers — these repeat and add noise
  • Fix encoding issues — UTF-8 normalisation
  • Remove boilerplate — cookie notices, navigation menus
  • Deduplicate — near-duplicate documents bias training
  • Language filtering — for monolingual models

Step 3: Format for Your Use Case

Pre-training (from scratch)

{"text": "The full text of document..."} {"text": "The full text of document 2..."}

Supervised Fine-tuning (SFT)

{"messages": [{"role": "user", "content": "Summarise..."}, {"role": "assistant", "content": "Summary: ..."}]}

RAG (Retrieval-Augmented Generation)

Documents are chunked (512–1024 tokens) and embedded as vectors in Pinecone, Chroma, or Weaviate. No training required.

Use instantconvert.io's AI document tools to extract and clean text from PDFs and images for AI processing.

Frequently Asked Questions

What file format should training data be in for LLMs?

Pre-training data: JSONL (one JSON object per line) where each line has a 'text' field. Fine-tuning (SFT): JSONL with messages array in OpenAI chat format. RAG: chunked text embedded as vectors in a vector database. JSONL is the most universal format.

How do I convert PDF documents to LLM training data?

Step 1: Extract text from PDFs (pdfplumber, PyMuPDF for native; OCR for scanned). Step 2: Clean — remove headers, footers, page numbers. Step 3: Chunk into appropriate sizes (512–2048 tokens). Step 4: Save as JSONL with {"text": "..."} format.

What is the difference between pre-training data and fine-tuning data?

Pre-training: large volumes of plain text to teach the model language patterns and world knowledge. Fine-tuning (SFT): instruction-response pairs to teach the model to follow specific instructions. RAG doesn't require training data — documents are retrieved at inference time.

How many tokens is a typical document page?

A typical A4 page of English text contains approximately 250–350 words, which is roughly 330–460 tokens (using GPT tokenization). A 100-page document is approximately 33,000–46,000 tokens.

What tools can I use to convert documents to LLM training data?

Python libraries: pdfplumber (PDF text), python-docx (DOCX), pandas (CSV/Excel), BeautifulSoup (HTML). For OCR: instantconvert.io's AI Tools for the extraction step. For chunking: LangChain's text splitters. For embedding: OpenAI, Cohere, or Sentence Transformers.

Related Articles

Try it now — takes 10 seconds

No sign-up. No watermarks. Completely free.

Start Converting Free →