Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

public record BQ(
@SerializedName("enabled") boolean enabled,
@SerializedName("rescore_limit") Integer rescoreLimit,
@SerializedName("rescoreLimit") Integer rescoreLimit,
@SerializedName("rescoreFactor") Float rescoreFactor,
@SerializedName("cache") Boolean cache) implements Quantization {

@Override
Expand All @@ -31,12 +32,16 @@ public static BQ of(Function<Builder, ObjectBuilder<BQ>> fn) {
}

public BQ(Builder builder) {
this(builder.enabled, builder.rescoreLimit, builder.cache);
this(builder.enabled,
builder.rescoreLimit,
builder.rescoreFactor,
builder.cache);
}

public static class Builder implements ObjectBuilder<BQ> {
private boolean enabled = true;
private Integer rescoreLimit;
private Float rescoreFactor;
private Boolean cache;

public Builder enabled(boolean enabled) {
Expand All @@ -49,6 +54,11 @@ public Builder rescoreLimit(int rescoreLimit) {
return this;
}

public Builder rescoreFactor(float rescoreFactor) {
this.rescoreFactor = rescoreFactor;
return this;
}

public Builder cache(boolean enabled) {
this.cache = enabled;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ public record PQ(
@SerializedName("enabled") boolean enabled,
@SerializedName("centroids") Integer centroids,
@SerializedName("segments") Integer segments,
@SerializedName("encoder_type") EncoderType encoderType,
@SerializedName("encoder_distribution") EncoderDistribution encoderDistribution,
@SerializedName("training_limit") Integer trainingLimit,
@SerializedName("bit_compression") Boolean bitCompression) implements Quantization {
@SerializedName("encoder") Encoder encoder,
@SerializedName("trainingLimit") Integer trainingLimit,
@SerializedName("rescoreLimit") Integer rescoreLimit,
@SerializedName("rescoreFactor") Float rescoreFactor,
@SerializedName("bitCompression") Boolean bitCompression) implements Quantization {

public enum EncoderType {
@SerializedName("kmeans")
Expand All @@ -30,6 +31,11 @@ public enum EncoderDistribution {
LOG_NORMAL;
}

public record Encoder(
@SerializedName("type") EncoderType type,
@SerializedName("distribution") EncoderDistribution distribution) {
}

@Override
public Quantization.Kind _kind() {
return Quantization.Kind.PQ;
Expand All @@ -48,24 +54,40 @@ public static PQ of(Function<Builder, ObjectBuilder<PQ>> fn) {
return fn.apply(new Builder()).build();
}

public EncoderType encoderType() {
if (this.encoder == null) {
return null;
}
return this.encoder.type();
}

public EncoderDistribution encoderDistribution() {
if (this.encoder == null) {
return null;
}
return this.encoder.distribution();
}

public PQ(Builder builder) {
this(
builder.enabled,
builder.centroids,
builder.segments,
builder.encoderType,
builder.encoderDistribution,
builder.encoder,
builder.trainingLimit,
builder.rescoreLimit,
builder.rescoreFactor,
builder.bitCompression);
}

public static class Builder implements ObjectBuilder<PQ> {
private boolean enabled = true;
private Integer centroids;
private Integer segments;
private EncoderType encoderType;
private EncoderDistribution encoderDistribution;
private Encoder encoder;
private Integer trainingLimit;
private Integer rescoreLimit;
private Float rescoreFactor;
private Boolean bitCompression;

public Builder enabled(boolean enabled) {
Expand All @@ -84,12 +106,20 @@ public Builder segments(int segments) {
}

public Builder encoderType(EncoderType encoderType) {
this.encoderType = encoderType;
if (this.encoder == null) {
this.encoder = new Encoder(encoderType, null);
} else {
this.encoder = new Encoder(encoderType, this.encoder.distribution);
}
return this;
}

public Builder encoderDistribution(EncoderDistribution encoderDistribution) {
this.encoderDistribution = encoderDistribution;
if (this.encoder == null) {
this.encoder = new Encoder(null, encoderDistribution);
} else {
this.encoder = new Encoder(this.encoder.type, encoderDistribution);
}
return this;
}

Expand All @@ -98,6 +128,16 @@ public Builder trainingLimit(int trainingLimit) {
return this;
}

public Builder rescoreLimit(int rescoreLimit) {
this.rescoreLimit = rescoreLimit;
return this;
}

public Builder rescoreFactor(float rescoreFactor) {
this.rescoreFactor = rescoreFactor;
return this;
}

public Builder bitCompression(boolean enabled) {
this.bitCompression = enabled;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

public record RQ(
@SerializedName("enabled") boolean enabled,
@SerializedName("rescore_limit") Integer rescoreLimit,
@SerializedName("rescoreLimit") Integer rescoreLimit,
@SerializedName("rescoreFactor") Float rescoreFactor,
@SerializedName("bits") Integer bits,
@SerializedName("cache") Boolean cache) implements Quantization {

Expand All @@ -32,12 +33,17 @@ public static RQ of(Function<Builder, ObjectBuilder<RQ>> fn) {
}

public RQ(Builder builder) {
this(builder.enabled, builder.rescoreLimit, builder.bits, builder.cache);
this(builder.enabled,
builder.rescoreLimit,
builder.rescoreFactor,
builder.bits,
builder.cache);
}

public static class Builder implements ObjectBuilder<RQ> {
private boolean enabled = true;
private Integer rescoreLimit;
private Float rescoreFactor;
private Integer bits;
private Boolean cache;

Expand All @@ -51,6 +57,11 @@ public Builder rescoreLimit(int rescoreLimit) {
return this;
}

public Builder rescoreFactor(float rescoreFactor) {
this.rescoreFactor = rescoreFactor;
return this;
}

public Builder bits(int bits) {
this.bits = bits;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

public record SQ(
@SerializedName("enabled") boolean enabled,
@SerializedName("rescore_limit") Integer rescoreLimit,
@SerializedName("training_limit") Integer trainingLimit,
@SerializedName("rescoreLimit") Integer rescoreLimit,
@SerializedName("rescoreFactor") Float rescoreFactor,
@SerializedName("trainingLimit") Integer trainingLimit,
@SerializedName("cache") Boolean cache) implements Quantization {

@Override
Expand All @@ -32,12 +33,17 @@ public static SQ of(Function<Builder, ObjectBuilder<SQ>> fn) {
}

public SQ(Builder builder) {
this(builder.enabled, builder.rescoreLimit, builder.trainingLimit, builder.cache);
this(builder.enabled,
builder.rescoreLimit,
builder.rescoreFactor,
builder.trainingLimit,
builder.cache);
}

public static class Builder implements ObjectBuilder<SQ> {
private boolean enabled = true;
private Integer rescoreLimit;
private Float rescoreFactor;
private Integer trainingLimit;
private Boolean cache;

Expand All @@ -51,6 +57,11 @@ public Builder rescoreLimit(int rescoreLimit) {
return this;
}

public Builder rescoreFactor(float rescoreFactor) {
this.rescoreFactor = rescoreFactor;
return this;
}

public Builder trainingLimit(int trainingLimit) {
this.trainingLimit = trainingLimit;
return this;
Expand Down
28 changes: 20 additions & 8 deletions src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,8 @@ public static Object[][] testCases() {
.encoderType(PQ.EncoderType.TILE)
.segments(16)
.trainingLimit(1024)
.rescoreLimit(2048)
.rescoreFactor(3.14f)
.bitCompression(true)))),
"""
{
Expand All @@ -1206,11 +1208,15 @@ public static Object[][] testCases() {
"pq": {
"enabled": true,
"centroids": 8,
"encoder_distribution": "normal",
"encoder_type": "tile",
"encoder": {
"distribution": "normal",
"type": "tile"
},
"segments": 16,
"training_limit": 1024,
"bit_compression": true
"trainingLimit": 1024,
"rescoreLimit": 2048,
"rescoreFactor": 3.14,
"bitCompression": true
}
}
}
Expand All @@ -1221,6 +1227,7 @@ public static Object[][] testCases() {
SelfProvidedVectorizer.of(none -> none
.quantization(Quantization.sq(sq -> sq
.rescoreLimit(10)
.rescoreFactor(3.14f)
.trainingLimit(1024)
.cache(true)))),
"""
Expand All @@ -1230,8 +1237,9 @@ public static Object[][] testCases() {
"vectorIndexConfig": {
"sq": {
"enabled": true,
"rescore_limit": 10,
"training_limit": 1024,
"rescoreLimit": 10,
"rescoreFactor": 3.14,
"trainingLimit": 1024,
"cache": true
}
}
Expand All @@ -1243,6 +1251,7 @@ public static Object[][] testCases() {
SelfProvidedVectorizer.of(none -> none
.quantization(Quantization.rq(rq -> rq
.rescoreLimit(10)
.rescoreFactor(3.14f)
.bits(8)))),
"""
{
Expand All @@ -1251,7 +1260,8 @@ public static Object[][] testCases() {
"vectorIndexConfig": {
"rq": {
"enabled": true,
"rescore_limit": 10,
"rescoreLimit": 10,
"rescoreFactor": 3.14,
"bits": 8
}
}
Expand All @@ -1263,6 +1273,7 @@ public static Object[][] testCases() {
SelfProvidedVectorizer.of(none -> none
.quantization(Quantization.bq(bq -> bq
.rescoreLimit(10)
.rescoreFactor(3.14f)
.cache(true)))),
"""
{
Expand All @@ -1271,7 +1282,8 @@ public static Object[][] testCases() {
"vectorIndexConfig": {
"bq": {
"enabled": true,
"rescore_limit": 10,
"rescoreLimit": 10,
"rescoreFactor": 3.14,
"cache": true
}
}
Expand Down
Loading