The variable heavy chain portion of the Fab is coded for by a combination of 3 genes, called VH, DH, and JH. The variable light chain portion of the Fab consists of either a kappa chain or a lambda chain coded for by a combination of 2 genes, VL and JL. In the DNA of each B-lymphocyte there are multiple forms of each one of these variable determinant genes. Although the exact number of each gene isn't known and varies from person, there are approximately 38-46 VH genes; 23 DH genes; 6 JH genes; 34-38 kappa VL genes; 5 kappa JL genes; 29-33 lambda VL genes; and 4-5 lambda JL genes.
Through random gene-splicing, any combination of the multiple forms of each gene can join together resulting in thousands of possible gene combinations. This is known as combinatorial diversity.
Additionally, specialized enzymes in the B-lymphocyte cause splicing inaccuracies where additional nucleotides are added or deleted at the various gene junctions to generate a great deal of further diversity. This is called junctional diversity but is not shown in this animation.