Skip to content

Commit a1818c9

Browse files
vjuranekNaros
authored andcommitted
DBZ-9063 Allow some volatility in embeddings comparison
1 parent 2522956 commit a1818c9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

debezium-ai/debezium-ai-embeddings-ollama/src/test/java/io/debezium/ai/embeddings/EmbeddingsOllamaIT.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import org.apache.kafka.connect.data.Struct;
1616
import org.apache.kafka.connect.source.SourceRecord;
17+
import org.assertj.core.data.Offset;
1718
import org.junit.AfterClass;
1819
import org.junit.BeforeClass;
1920
import org.junit.Test;
@@ -60,7 +61,10 @@ public void testOllamaEmbeddings() throws InterruptedException, IOException {
6061
assertThat(payloadStruct.getStruct("after").getString("product")).contains("a product");
6162
List<Float> embeddings = payloadStruct.getStruct("after").getArray("prod_embedding");
6263
assertThat(embeddings.size()).isEqualTo(384);
63-
assertThat(embeddings).startsWith(-0.07157089f, 0.022460647f, -0.02369636f, -0.0143798785f, 0.0048304256f, 0.020285256f, 0.20442571f, 0.057290666f, 0.054607023f,
64-
-0.030602805f);
64+
65+
final Offset<Float> offset = Offset.offset(0.001f);
66+
assertThat(embeddings.get(0)).isCloseTo(-0.07157089f, offset);
67+
assertThat(embeddings.get(1)).isCloseTo(0.022460647f, offset);
68+
assertThat(embeddings.get(2)).isCloseTo(-0.02369636f, offset);
6569
}
6670
}

0 commit comments

Comments
 (0)