From 629e544341fa6284393c633cfa055c1d2ab14f7d Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Tue, 22 Aug 2023 00:28:08 +0100 Subject: [PATCH] cleaned up basic test a bit --- LLama.Unittest/LLamaEmbedderTests.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/LLama.Unittest/LLamaEmbedderTests.cs b/LLama.Unittest/LLamaEmbedderTests.cs index e5f73764e..700bdb428 100644 --- a/LLama.Unittest/LLamaEmbedderTests.cs +++ b/LLama.Unittest/LLamaEmbedderTests.cs @@ -30,24 +30,23 @@ private static float Dot(float[] a, float[] b) return a.Zip(b, (x, y) => x * y).Sum(); } - private static void AssertApproxStartsWith(float[] array, float[] start, float epsilon = 0.00001f) + private static void AssertApproxStartsWith(float[] expected, float[] actual, float epsilon = 0.00001f) { - for (int i = 0; i < start.Length; i++) - Assert.Equal(array[i], start[i], epsilon); + for (int i = 0; i < expected.Length; i++) + Assert.Equal(expected[i], actual[i], epsilon); } [Fact] public void EmbedBasic() { - var hello = _embedder.GetEmbeddings("cat"); + var cat = _embedder.GetEmbeddings("cat"); - Assert.NotNull(hello); - Assert.NotEmpty(hello); - //Assert.Equal(_embedder.EmbeddingSize, hello.Length); + Assert.NotNull(cat); + Assert.NotEmpty(cat); // Expected value generate with llama.cpp embedding.exe var expected = new float[] { -0.127304f, -0.678057f, -0.085244f, -0.956915f, -0.638633f }; - AssertApproxStartsWith(hello, expected); + AssertApproxStartsWith(expected, cat); } [Fact]