liveBook · Manning

Chapter 4: Data engineering for large language models: Setting up for success

What you will learn in chapter 4 of LLMs in Production

The chapter introduces the model and data assets to prepare before training or finetuning an LLM, then previews how it will evaluate models and build a reusable dataset.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduces the model and data assets to prepare before training or finetuning an LLM, then previews how it will evaluate models and build a reusable dataset.

Key terms: data engineering, data assets, high-quality, consistent information, base model, foundation models, finetuning, datasets, tokenizer, embeddings, Slack dataset

4.1 Models are the foundation

This section introduces pretrained model weights as a starting point for task-specific LLMs and explains how to approach choosing a model or architecture.

Key terms: model weights, pretrained model, training data, open source models, benchmark-breaking records, architecture, model family

4.1.1 GPT

This section introduces the GPT family, traces its growth, distinguishes GPT models from ChatGPT and unrelated uses of the name, and explains why the book uses GPT-2.

Key terms: GPT, GPT-2, GPT-3, parameters, BookCorpus, WebText, ChatGPT, finetuned, reinforcement learning with human feedback, RLHF

4.1.2 BLOOM

This section introduces BLOOM’s transparent development, model variants, and licensing, then weighs its research contributions against its limitations as a foundation model.

Key terms: BLOOM, BigScience, BigScienceCorpus, 176B parameters, RAIL, BLOOMZ, multitask, finetuned, cross-lingual generalization, 46 languages

4.1.3 LLaMA

This section explains how LLaMA became a widely used model family and describes Llama 2’s licensing, sizes, training data, and finetuned variants.

Key terms: LLaMA, Meta, noncommercial license, weights, Llama 2, commercial license, 7B, 13B, 70B, curated dataset

4.1.4 Wizard

This section explains how the Wizard methodology makes instruction datasets more complex and how to use Wizard models for coding, math, and other tasks.

Key terms: WizardLM, Wizard methodology, high-complexity tasks, finetune, WizardCoder, WizardMath, human-like prose, talk-to-your-data applications

4.1.5 Falcon

This section introduces Falcon as an openly licensed LLM family and explains its competitive performance and training-data foundation.

Key terms: Falcon, Technology Innovation Institute, Apache 2.0, 7B, 40B, 180B, GPT-3, LLM leaderboards, RefinedWeb, Common Crawl

4.1.6 Vicuna

Vicuna shows how training on shared ChatGPT conversations can produce a capable, inexpensive model while creating risks when its training data does not cover a task.

Key terms: Vicuna, ShareGPT, ChatGPT, data coverage, data quality, model collapse, synthetic data, hallucinate, commercial use, personal projects

4.1.7 Dolly

This section explains why Dolly is useful as a starting point for adaptation despite weak comparative performance, and how its training data and open release differ by version.

Key terms: Dolly, finetuning, low-ranking adaptations, LoRAs, Dolly 1.0, Stanford Alpaca Dataset, Dolly 2.0, instruction-following dataset, commercial use license

4.1.8 OpenChat

The section introduces OpenChat’s training approach and task-specific models, then points readers toward comparing and evaluating model families for a project.

Key terms: OpenChat, Vicuna, ShareGPT, conditioning, weighted loss, human-preferred responses, OpenChat models, finetunings, coding, agents

4.2 Evaluating LLMs

Introduces why choosing and improving an LLM requires objective evaluation, and identifies the metric and dataset needed to do it.

Key terms: finetuning, model size, industry standards, metric, dataset, ground truth

4.2.1 Metrics for evaluating text

The section explains how ROUGE, BLEU, and entropy-based metrics evaluate generated text, and why their scores need careful interpretation.

Key terms: exact match, ground truth, semantically, syntactically, ROUGE, Recall-Oriented Understudy for Gisting Evaluation, N-grams, longest common subsequences, skip-bigrams, BLEU

4.2.2 Industry benchmarks

This section compares GLUE, SuperGLUE, and MMLU, shows how to try two of them, and explains why benchmark results need to be interpreted together and with care.

Key terms: benchmarks, evaluation metrics, GLUE, SuperGLUE, human parity, human baselines, few-shot, zero-shot, MultiRC, raw generated text

4.2.3 Responsible AI benchmarks

The section shows how to evaluate LLM bias by comparing metric results across demographic groups and argues for automating those checks alongside performance evaluations.

Key terms: industry benchmarks, bias, blind spots, segment the data, evaluation pipeline, toxicity, polarity, hurtfulness, HONEST, Regard

4.2.4 Developing your own benchmark

The section explains when to build a task-specific LLM benchmark and how OpenAI Evals and Hugging Face Evaluate support different evaluation needs.

Key terms: benchmark datasets, edge cases, custom list of prompts, expected responses, OpenAI’s Evals, Hugging Face’s Evaluate, registry, Hugging Face Hub, metric space, SQuAD

4.2.5 Evaluating code generators

This section shows how to evaluate code-generating LLMs by testing the code they produce and comparing the results, while recognizing the limits of automated tests.

Key terms: docstrings, prebuilt tests, profiler, security scanner, architectural fitness functions, coding challenges, edge cases, human in the loop

4.2.6 Evaluating model parameters

The section introduces evaluation of LLM training quality from model parameters, explains a WeightWatcher spectral plot, and clarifies why parameter analysis must complement task-based evaluation.

Key terms: model parameters, weightwatcher, GPT-2, overtrained, undertrained, spectral analysis plots, eigenvalues, tail, heavy tail, Empirical Spectral Density (ESD)

4.3 Data for LLMs

This section argues that high-quality data is central to LLM training and previews how to find, assess, and prepare datasets.

Key terms: high-quality training data, clever modeling, number of parameters, size of training data, common datasets, processing and preparation techniques

4.3.1 Datasets you should know

This section surveys commonly used LLM datasets and corpora, showing how their sources, coverage, freshness, and curation affect model behavior and dataset choice.

Key terms: training data, datasets, Wikitext, Wiki-40B, Europarl, parallel corpora, Common Crawl, C4, OpenWebText, self-supervised pretraining

4.3.2 Data cleaning and preparation

This section explains how to curate LLM data around the intended task, using instruction formats, speech-act analysis, and targeted annotation rather than relying on raw text volume alone.

Key terms: self-supervised, schema, distribution, normalization, scaling, bias, instruct schema, instruction tuning, ###Instruction, ###Input

4.4 Text processors

Introduces the conversion of training text into numbers and explains why use-case-specific tokenization and embeddings matter for LLM performance.

Key terms: tokenization, byte-pair encoding (BPE), SentencePiece, embeddings, unknown tokens, <UKN>, encoded semantics, tokenize

4.4.1 Tokenization

This section explains how tokenization choices shape what an LLM can process, compares word, character, and subword approaches, and identifies considerations for training a tokenizer on your own data.

Key terms: tokenization strategy, GOAT 7B, GPT-4, Llama, digits, tokenization, encode, decode, whitespace, word-to-integer dictionary

4.4.2 Embeddings

This section explains how embeddings add context to tokenized text, enable similarity search and retrieval-augmented generation, and can be extracted and used in practice.

Key terms: tokenization, embeddings, positional and semantic encodings, distance, dimensional space, similarity search, retrieval-augmented generation, RAG, prompting time, Boston Housing dataset

4.5 Preparing a Slack dataset

The section introduces a Slack-data preparation exercise for an LLM chatbot and explains why a chatbot could help answer recurring workplace questions.

Key terms: Slack data, user's data, parquet file, HR help channel, FAQ pages, chatbot

4.6 Summary

This summary connects model choice and evaluation with the data preparation and text-processing decisions that shape an LLM’s performance.

Where this is used later

Concepts explained in this chapter

← Chapter 3: Large language model operations: Building a platform for LLMs Chapter 5: Training large language models: How to generate the generator →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.