liveBook · Manning

Preprocessing

As explained in Software Testing with Generative AI

Data preprocessing is the preparation and transformation of data into a form suitable for model training or fine-tuning.

Data preprocessing prepares raw documentation, support material, or source code for model training by parsing it into a structured dataset. For instruction-based fine-tuning, records commonly contain instructions, inputs, and expected outputs. The central problem is preserving enough context for each record to teach a useful behavior. section 12.2.1 section 12.2.2

A practical preprocessing workflow includes:

  • Choose a record structure that matches the desired training task, such as instruction, input, and output fields. section 12.2.2
  • Parse unstructured documentation or code into records, using automation when the corpus is large and manual curation when its cost is acceptable. section 12.2.1
  • Preserve logical context instead of splitting code indiscriminately into isolated lines such as `}` or `@Autowired`. section 12.2.1
  • Design and encode the prompt format so the fine-tuning process can combine instruction and input data consistently. section 12.2.2
  • Run the prepared data through a tokenizer before fine-tuning so text becomes tokens ready for training. section 12.2.4

Avoiding context-free code records

A line-by-line parser can produce a table containing isolated fragments: `1, @RequestMapping(...)`, `2, public ResponseEntity<Branding>...`, and `3, SQLException`. A context-preserving parser instead groups the controller declaration, injected service, endpoint annotation, method body, and return statement into a coherent record. That record can support an instruction such as “How does the method getBranding work?” with a code-based answer. section 12.2.1

{"instruction": "What is the class declaration for
➥BrandingServiceIT","output": "@ExtendWith
➥@SpringBootTest
➥@ActiveProfiles
public class BrandingServiceIT { }"}
{"instruction": "How does the method setup Restito work for
➥BrandingServiceIT?","output": "
➥@BeforeEach
➥public void setupRestito(){
➥whenHttp(server).match(post("/auth/validate"))
➥.then(status(HttpStatus.OK_200));
➥}"}

Browse paired instruction-and-output records showing how parsed Java test code becomes fine-tuning data. section 12.2.1

How Software Testing with Generative AI covers it

How deep it goes
Explains schemas, parsing choices, prompt encoding, and tokenization, but stops short of detailing tokenizer internals.
Examples
Uses JSONL instruction-output pairs and Java controller and test-code fragments to contrast coherent records with isolated lines.
What it assumes
Assumes raw domain documents or code and a target dataset schema, while teaching how to structure and parse them.
What you can do after
Apply it via Axolotl to tokenize a prepared dataset before launching a fine-tuning run.
How it connects
Connects data preprocessing with fine-tuning, instruction tuning, prompt design, tokenization, and the Alpaca dataset format.

Also explained in

Compare how 22 books explain preprocessing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Testing with Generative AI. The section links point to the parts of the book it draws on.