Skip to content

Commit

Permalink
Misc cleanup of KMPPClusterer after recent change. Expose MAX_PQ_TRAI…
Browse files Browse the repository at this point in the history
…NING_SET_SIZE.
  • Loading branch information
jkni committed Feb 8, 2024
1 parent 335a24d commit e800853
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;

/**
Expand All @@ -40,20 +39,22 @@ public class KMeansPlusPlusClusterer {
private final float[][] centroidNums;

/**
* Constructs a KMeansPlusPlusFloatClusterer with the specified number of clusters,
* maximum iterations, and distance function.
* Constructs a KMeansPlusPlusFloatClusterer with the specified points and number of clusters.
*
* @param points the points to cluster.
* @param k number of clusters.
*/
public KMeansPlusPlusClusterer(float[][] points, int k) {
this(points, chooseInitialCentroids(points, k));
}

/**
* Constructs a KMeansPlusPlusFloatClusterer with the specified number of clusters,
* maximum iterations, and distance function.
* Constructs a KMeansPlusPlusFloatClusterer with the specified points and initial centroids.
* <p>
* The initial centroids provided as a parameter are copied before modification.
*
* @param points the points to cluster.
* @param centroids the initial centroids.
*/
public KMeansPlusPlusClusterer(float[][] points, float[][] centroids) {
this.points = points;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
import io.github.jbellis.jvector.disk.Io;
import io.github.jbellis.jvector.disk.RandomAccessReader;
import io.github.jbellis.jvector.graph.RandomAccessVectorValues;
import io.github.jbellis.jvector.util.ExplicitThreadLocal;
import io.github.jbellis.jvector.util.PhysicalCoreExecutor;
import io.github.jbellis.jvector.util.ExplicitThreadLocal;
import io.github.jbellis.jvector.util.RamUsageEstimator;
import io.github.jbellis.jvector.vector.VectorUtil;

Expand All @@ -47,7 +45,7 @@
public class ProductQuantization implements VectorCompressor<byte[]> {
static final int CLUSTERS = 256; // number of clusters per subspace = one byte's worth
static final int K_MEANS_ITERATIONS = 6;
static final int MAX_PQ_TRAINING_SET_SIZE = 128000;
public static final int MAX_PQ_TRAINING_SET_SIZE = 128000;

final float[][][] codebooks;
private final int M; // codebooks.length, redundantly reproduced for convenience
Expand Down

0 comments on commit e800853

Please sign in to comment.