Skip to content
This repository was archived by the owner on Dec 4, 2025. It is now read-only.
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 @@ -25,4 +25,9 @@ public class AllMiniLmL6V2QuantizedEmbeddingModel extends AbstractInProcessEmbed
protected OnnxBertBiEncoder model() {
return MODEL;
}

@Override
protected Integer knownDimension() {
return 384;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,12 @@ void should_embed_concurrently() throws Exception {
assertThat(embedding).isEqualTo(referenceEmbedding);
}
}

@Test
void should_return_correct_dimension() {

EmbeddingModel model = new AllMiniLmL6V2QuantizedEmbeddingModel();

assertThat(model.dimension()).isEqualTo(384);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public class AllMiniLmL6V2EmbeddingModel extends AbstractInProcessEmbeddingModel
protected OnnxBertBiEncoder model() {
return MODEL;
}

@Override
protected Integer knownDimension() {
return 384;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,12 @@ void should_return_token_usage() {

assertThat(model.embed("hi, how are you doing?").tokenUsage().inputTokenCount()).isEqualTo(7);
}

@Test
void should_return_correct_dimension() {

EmbeddingModel model = new AllMiniLmL6V2EmbeddingModel();

assertThat(model.dimension()).isEqualTo(384);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public class BgeSmallEnQuantizedEmbeddingModel extends AbstractInProcessEmbeddin
protected OnnxBertBiEncoder model() {
return MODEL;
}

@Override
protected Integer knownDimension() {
return 384;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,12 @@ void should_produce_normalized_vectors() {
assertThat(magnitudeOf(model.embed(repeat(oneToken, 999)).content()))
.isCloseTo(1, withPercentage(0.01));
}

@Test
void should_return_correct_dimension() {

EmbeddingModel model = new BgeSmallEnQuantizedEmbeddingModel();

assertThat(model.dimension()).isEqualTo(384);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ public class BgeSmallEnV15QuantizedEmbeddingModel extends AbstractInProcessEmbed
protected OnnxBertBiEncoder model() {
return MODEL;
}

@Override
protected Integer knownDimension() {
return 384;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,12 @@ void should_produce_normalized_vectors() {
assertThat(magnitudeOf(model.embed(repeat(oneToken, 999)).content()))
.isCloseTo(1, withPercentage(0.01));
}

@Test
void should_return_correct_dimension() {

EmbeddingModel model = new BgeSmallEnV15QuantizedEmbeddingModel();

assertThat(model.dimension()).isEqualTo(384);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ public class BgeSmallEnV15EmbeddingModel extends AbstractInProcessEmbeddingModel
protected OnnxBertBiEncoder model() {
return MODEL;
}

@Override
protected Integer knownDimension() {
return 384;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,12 @@ void should_produce_normalized_vectors() {
assertThat(magnitudeOf(model.embed(repeat(oneToken, 999)).content()))
.isCloseTo(1, withPercentage(0.01));
}

@Test
void should_return_correct_dimension() {

EmbeddingModel model = new BgeSmallEnV15EmbeddingModel();

assertThat(model.dimension()).isEqualTo(384);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public class BgeSmallEnEmbeddingModel extends AbstractInProcessEmbeddingModel {
protected OnnxBertBiEncoder model() {
return MODEL;
}

@Override
protected Integer knownDimension() {
return 384;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,12 @@ void should_produce_normalized_vectors() {
assertThat(magnitudeOf(model.embed(repeat(oneToken, 999)).content()))
.isCloseTo(1, withPercentage(0.01));
}

@Test
void should_return_correct_dimension() {

EmbeddingModel model = new BgeSmallEnEmbeddingModel();

assertThat(model.dimension()).isEqualTo(384);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public class BgeSmallZhQuantizedEmbeddingModel extends AbstractInProcessEmbeddin
protected OnnxBertBiEncoder model() {
return MODEL;
}

@Override
protected Integer knownDimension() {
return 512;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,12 @@ void should_produce_normalized_vectors() {
assertThat(magnitudeOf(model.embed(repeat(oneToken, 999)).content()))
.isCloseTo(1, withPercentage(0.01));
}

@Test
void should_return_correct_dimension() {

EmbeddingModel model = new BgeSmallZhQuantizedEmbeddingModel();

assertThat(model.dimension()).isEqualTo(512);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ public class BgeSmallZhV15QuantizedEmbeddingModel extends AbstractInProcessEmbed
protected OnnxBertBiEncoder model() {
return MODEL;
}

@Override
protected Integer knownDimension() {
return 512;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ public class BgeSmallZhV15EmbeddingModel extends AbstractInProcessEmbeddingModel
protected OnnxBertBiEncoder model() {
return MODEL;
}

@Override
protected Integer knownDimension() {
return 512;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,12 @@ void should_produce_normalized_vectors() {
assertThat(magnitudeOf(model.embed(repeat(oneToken, 999)).content()))
.isCloseTo(1, withPercentage(0.01));
}

@Test
void should_return_correct_dimension() {

EmbeddingModel model = new BgeSmallZhV15EmbeddingModel();

assertThat(model.dimension()).isEqualTo(512);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public class BgeSmallZhEmbeddingModel extends AbstractInProcessEmbeddingModel {
protected OnnxBertBiEncoder model() {
return MODEL;
}

@Override
protected Integer knownDimension() {
return 512;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,12 @@ void should_produce_normalized_vectors() {
assertThat(magnitudeOf(model.embed(repeat(oneToken, 999)).content()))
.isCloseTo(1, withPercentage(0.01));
}

@Test
void should_return_correct_dimension() {

EmbeddingModel model = new BgeSmallZhEmbeddingModel();

assertThat(model.dimension()).isEqualTo(512);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public class E5SmallV2QuantizedEmbeddingModel extends AbstractInProcessEmbedding
protected OnnxBertBiEncoder model() {
return MODEL;
}

@Override
protected Integer knownDimension() {
return 384;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,12 @@ void should_produce_normalized_vectors() {
assertThat(magnitudeOf(model.embed(repeat(oneToken, 999)).content()))
.isCloseTo(1, withPercentage(0.01));
}

@Test
void should_return_correct_dimension() {

EmbeddingModel model = new E5SmallV2QuantizedEmbeddingModel();

assertThat(model.dimension()).isEqualTo(384);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public class E5SmallV2EmbeddingModel extends AbstractInProcessEmbeddingModel {
protected OnnxBertBiEncoder model() {
return MODEL;
}

@Override
protected Integer knownDimension() {
return 384;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,12 @@ void should_produce_normalized_vectors() {
assertThat(magnitudeOf(model.embed(repeat(oneToken, 999)).content()))
.isCloseTo(1, withPercentage(0.01));
}

@Test
void should_return_correct_dimension() {

EmbeddingModel model = new E5SmallV2EmbeddingModel();

assertThat(model.dimension()).isEqualTo(384);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import static java.nio.file.Files.newInputStream;

public abstract class AbstractInProcessEmbeddingModel implements EmbeddingModel, TokenCountEstimator {
public abstract class AbstractInProcessEmbeddingModel extends DimensionAwareEmbeddingModel implements TokenCountEstimator {

protected static OnnxBertBiEncoder loadFromJar(String modelFileName, String tokenizerFileName, PoolingMode poolingMode) {
InputStream model = Thread.currentThread().getContextClassLoader().getResourceAsStream(modelFileName);
Expand Down