Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 06b11a7

Browse files
author
Vaijanath Rao
committed
updated the test.
1 parent 1685c3e commit 06b11a7

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

src/test/java/de/kherud/llama/RerankingModelTest.java

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
package de.kherud.llama;
22

3-
import java.io.*;
4-
import java.util.*;
5-
import java.util.regex.Pattern;
3+
import java.util.Map;
64

7-
import de.kherud.llama.args.LogFormat;
85
import org.junit.AfterClass;
96
import org.junit.Assert;
107
import org.junit.BeforeClass;
11-
import org.junit.Ignore;
128
import org.junit.Test;
139

1410
public class RerankingModelTest {
@@ -41,7 +37,32 @@ public void testReRanking() {
4137
LlamaOutput llamaOutput = model.rerank(query, TEST_DOCUMENTS[0], TEST_DOCUMENTS[1], TEST_DOCUMENTS[2],
4238
TEST_DOCUMENTS[3]);
4339

44-
System.out.println(llamaOutput);
40+
Map<String, Float> rankedDocumentsMap = llamaOutput.probabilities;
41+
Assert.assertTrue(rankedDocumentsMap.size()==TEST_DOCUMENTS.length);
42+
43+
// Finding the most and least relevant documents
44+
String mostRelevantDoc = null;
45+
String leastRelevantDoc = null;
46+
float maxScore = Float.MIN_VALUE;
47+
float minScore = Float.MAX_VALUE;
48+
49+
for (Map.Entry<String, Float> entry : rankedDocumentsMap.entrySet()) {
50+
if (entry.getValue() > maxScore) {
51+
maxScore = entry.getValue();
52+
mostRelevantDoc = entry.getKey();
53+
}
54+
if (entry.getValue() < minScore) {
55+
minScore = entry.getValue();
56+
leastRelevantDoc = entry.getKey();
57+
}
58+
}
59+
60+
// Assertions
61+
Assert.assertTrue(maxScore > minScore);
62+
Assert.assertEquals("Machine learning is a field of study in artificial intelligence concerned with the development and study of statistical algorithms that can learn from data and generalize to unseen data, and thus perform tasks without explicit instructions.", mostRelevantDoc);
63+
Assert.assertEquals("Paris, capitale de la France, est une grande ville européenne et un centre mondial de l'art, de la mode, de la gastronomie et de la culture. Son paysage urbain du XIXe siècle est traversé par de larges boulevards et la Seine.", leastRelevantDoc);
64+
65+
4566
}
4667

4768
}

0 commit comments

Comments
 (0)