Permutation API in LanceDB that’s designed to facilitate the
process of training a model and explain how to use LanceDB as a data backend for training.
Data loading
Most model training frameworks iterate through data in batches and feed this data into the model. This process is often referred to as data loading. The simplest way to load data into a model is to iterate a LanceDB table in a loop and feed the data into the model.Permutation of the table.
Selecting rows
When training a model, we might not want to load all of the data. For example, we might filter out columns that are not needed for training. We might also divide the data into training and validation sets. Or we could divide the data into multiple sets for cross-validation. Whenever we create a permutation of the table, we have to first decide which rows we want to include (and in what order). This is stored in a permutation table which marks out the row ids that make up our data. Other decisions, such as which columns to include, and what transformations to apply, can be defined at read time and don’t require a separate permutation table.Permutation tables are tables, just like any other table in LanceDB. By default, they are
stored in memory but they can be persisted to storage as well. This is useful when you want to share a permutation
table across processes or nodes.
Selecting all rows
To select all rows, we can use thePermutation.identity method. This gives us a Permutation without requiring
us to create a separate permutation table. This allows us to refine our columns and apply transformations and can
be useful when the data loader itself is responsible for handling sampling and shuffling.
Filtering rows
If we only want to select a subset of rows, then we can use a filter. This will require us to create a permutation table which identifies which rows we want to include.Creating splits
LanceDB also provides several different methods for creating splits. These allow us to divide our dataset into smaller non-overlapping sets. The split can then be specified when creating thePermutation object to view
only a subset of the data.