From 992ec61004f986ba1671a3b8d3f57d4e7e5b6f5d Mon Sep 17 00:00:00 2001 From: Chunlei Niu Date: Wed, 15 Jan 2025 10:41:28 -0800 Subject: [PATCH] No public description PiperOrigin-RevId: 715857429 --- .../tasks/text/textembedder/TextEmbedderTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mediapipe/tasks/javatests/com/google/mediapipe/tasks/text/textembedder/TextEmbedderTest.java b/mediapipe/tasks/javatests/com/google/mediapipe/tasks/text/textembedder/TextEmbedderTest.java index 20084ee7cb..3957e2cf6c 100644 --- a/mediapipe/tasks/javatests/com/google/mediapipe/tasks/text/textembedder/TextEmbedderTest.java +++ b/mediapipe/tasks/javatests/com/google/mediapipe/tasks/text/textembedder/TextEmbedderTest.java @@ -55,20 +55,20 @@ public void embed_succeedsWithBert() throws Exception { assertThat(result0.embeddingResult().embeddings().get(0).floatEmbedding()).hasLength(512); assertThat(result0.embeddingResult().embeddings().get(0).floatEmbedding()[0]) .isWithin(FLOAT_DIFF_TOLERANCE) - .of(20.59746f); + .of(21.214869f); TextEmbedderResult result1 = textEmbedder.embed("what a great and fantastic trip"); assertThat(result1.embeddingResult().embeddings().size()).isEqualTo(1); assertThat(result1.embeddingResult().embeddings().get(0).floatEmbedding()).hasLength(512); assertThat(result1.embeddingResult().embeddings().get(0).floatEmbedding()[0]) .isWithin(FLOAT_DIFF_TOLERANCE) - .of(21.774776f); + .of(22.626257f); // Check cosine similarity. double similarity = TextEmbedder.cosineSimilarity( result0.embeddingResult().embeddings().get(0), result1.embeddingResult().embeddings().get(0)); - assertThat(similarity).isWithin(DOUBLE_DIFF_TOLERANCE).of(0.968879); + assertThat(similarity).isWithin(DOUBLE_DIFF_TOLERANCE).of(0.9714174924235968); } @Test @@ -140,7 +140,7 @@ public void classify_succeedsWithBertAndDifferentThemes() throws Exception { TextEmbedder.cosineSimilarity( result0.embeddingResult().embeddings().get(0), result1.embeddingResult().embeddings().get(0)); - assertThat(similarity).isWithin(DOUBLE_DIFF_TOLERANCE).of(0.3565317439544432); + assertThat(similarity).isWithin(DOUBLE_DIFF_TOLERANCE).of(0.3549060071739994); } @Test