Data

Data is a fundamental concept across various domains, each with its unique context and application. In the realm of large language models (LLMs), machine learning, computer-aided design (CAD), and general data processing, data plays a crucial role in driving analysis, model training, and design processes. Below, we explore the concept of data as discussed in different contexts.

Data Cleaning and Sorting

In general data processing, as highlighted in The Quick Python Book, Fourth Edition, data often comes in text-based files that may contain issues such as null values, illegal values, extra whitespace, and unsorted data. These issues can impede effective processing and analysis. Therefore, cleaning and sorting are essential steps in preparing data for further use. Cleaning involves removing or correcting erroneous data entries, filling in missing values, and eliminating unnecessary whitespace. Sorting organizes the data in a specific order, which can be crucial for certain types of analysis or for improving the efficiency of data processing tasks.

Data in Machine Learning

In the context of machine learning, particularly with PyTorch, data often refers to tabular data, as discussed in Deep Learning with PyTorch, Second Edition. This structured collection of independent samples is organized in rows, with each column containing specific information about the samples. For machine learning models, it is crucial to encode this data into a format that the models can process, typically by converting it into PyTorch tensors. Numerical data is straightforward to convert, while categorical data requires additional processing, such as one-hot encoding or label encoding, to transform it into a numerical format suitable for tensor conversion.

Data in Large Language Model Training

In training large language models (LLMs), data refers to input–target pairs essential for the learning process, as explained in Build a Large Language Model (From Scratch). These pairs are generated using a sliding window approach, crucial for creating input blocks and corresponding target tokens for next-word prediction tasks. The pretraining stage involves processing text one word at a time, training models with millions to billions of parameters. Preparing input text involves tokenization and encoding, where text is split into tokens and encoded into vector representations. Advanced tokenization schemes, such as byte pair encoding, are often used to handle the vast vocabulary and diverse linguistic structures in natural language.

Figure 2.1 Figure 2.1 The three main stages of coding an LLM. This chapter focuses on step 1 of stage 1: implementing the data sample pipeline.

Data in Computer-Aided Design (CAD)

In the realm of Computer-Aided Design (CAD), data representation is a critical component that encompasses a wide array of curves and surfaces, as described in Geometry for Programmers. Non-Uniform Rational B-Splines (NURBS), sweep surfaces, and surfaces of revolution are commonly used in CAD models, allowing for intricate and precise designs. The data model in CAD is designed to be highly flexible and adaptable, incorporating sequences of operations that enable modifications and adjustments without starting from scratch. Operations within CAD systems include Boolean operations and offsets, which require sophisticated computational techniques to manipulate the data and achieve desired design outcomes.

In summary, data is a versatile and essential element across various fields, each requiring specific methods for processing, encoding, and manipulation to achieve effective results in analysis, model training, and design.

| Book Title | Usage of Data | Technical Depth | Connections to Other Concepts | Examples Used | Practical Application |
|------------|---------------|-----------------|-------------------------------|---------------|-----------------------|
| [The Quick Python Book, Fourth Edition](https://www.manning.com/books/the-quick-python-book-fourth-edition) | Discusses data as text-based files with issues like null values and unsorted data, emphasizing the importance of cleaning and sorting. [more](https://livebook.manning.com/book/the-quick-python-book-fourth-edition/chapter-21/1) | Focuses on data cleaning and sorting techniques. [more](https://livebook.manning.com/book/the-quick-python-book-fourth-edition/chapter-21/1) | Connects data preparation to effective processing and analysis. [more](https://livebook.manning.com/book/the-quick-python-book-fourth-edition/chapter-21/1) | Examples of erroneous data entries and whitespace issues. [more](https://livebook.manning.com/book/the-quick-python-book-fourth-edition/chapter-21/1) | Practical steps for preparing data for analysis. [more](https://livebook.manning.com/book/the-quick-python-book-fourth-edition/chapter-21/1) |
| [Deep Learning with PyTorch, Second Edition](https://www.manning.com/books/deep-learning-with-pytorch-second-edition) | Describes data as tabular, structured collections for machine learning, focusing on encoding for PyTorch. [more](https://livebook.manning.com/book/deep-learning-with-pytorch-second-edition/chapter-4/1) | Explains tensor conversion and encoding techniques. [more](https://livebook.manning.com/book/deep-learning-with-pytorch-second-edition/chapter-4/1) | Links data encoding to machine learning model training. [more](https://livebook.manning.com/book/deep-learning-with-pytorch-second-edition/chapter-4/1) | Examples of numerical and categorical data encoding. [more](https://livebook.manning.com/book/deep-learning-with-pytorch-second-edition/chapter-4/1) | Application in building and training models with PyTorch. [more](https://livebook.manning.com/book/deep-learning-with-pytorch-second-edition/chapter-4/1) |
| [Build a Large Language Model (From Scratch)](https://www.manning.com/books/build-a-large-language-model-from-scratch) | Focuses on input-target pairs for LLM training, using a sliding window approach. [more](https://livebook.manning.com/book/build-a-large-language-model-from-scratch/chapter-2/1) | Details pretraining, tokenization, and encoding processes. [more](https://livebook.manning.com/book/build-a-large-language-model-from-scratch/chapter-2/1) | Connects data preparation to LLM capabilities and performance. [more](https://livebook.manning.com/book/build-a-large-language-model-from-scratch/chapter-2/1) | Examples of tokenization and encoding strategies. [more](https://livebook.manning.com/book/build-a-large-language-model-from-scratch/chapter-2/1) | Practical strategies for effective LLM training. [more](https://livebook.manning.com/book/build-a-large-language-model-from-scratch/chapter-2/1) |
| [Geometry for Programmers](https://www.manning.com/books/geometry-for-programmers) | Discusses data representation in CAD, focusing on curves and surfaces like NURBS. [more](https://livebook.manning.com/book/geometry-for-programmers/chapter-11/18) | Explores complex operations like Boolean operations and offsets. [more](https://livebook.manning.com/book/geometry-for-programmers/chapter-11/34) | Links data models to design processes and iterative refinement. [more](https://livebook.manning.com/book/geometry-for-programmers/chapter-11/18) | Examples of CAD operations and geometric entities. [more](https://livebook.manning.com/book/geometry-for-programmers/chapter-11/34) | Application in engineering and design through CAD systems. [more](https://livebook.manning.com/book/geometry-for-programmers/chapter-11/18) |

FAQ (Frequently asked questions)

How do operations in CAD differ from operations with signed distance functions (SDFs)?

What types of data can be found in tabular data?