Skip to content

Commit e9c3de7

Browse files
author
Vaijanath Rao
committed
moving reranking to it's own test.
1 parent 7137368 commit e9c3de7

File tree

2 files changed

+59
-2
lines changed

2 files changed

+59
-2
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
env:
77
MODEL_URL: https://huggingface.co/TheBloke/CodeLlama-7B-GGUF/resolve/main/codellama-7b.Q2_K.gguf
88
MODEL_NAME: codellama-7b.Q2_K.gguf
9+
RERANKING_MODEL_URL: https://huggingface.co/gpustack/jina-reranker-v1-tiny-en-GGUF/resolve/main/jina-reranker-v1-tiny-en-Q4_0.gguf
10+
RERANKING_MODEL_NAME: jina-reranker-v1-tiny-en-Q4_0.gguf
911
jobs:
1012

1113
build-and-test-linux:
@@ -21,8 +23,10 @@ jobs:
2123
run: |
2224
mvn compile
2325
.github/build.sh -DLLAMA_VERBOSE=ON
24-
- name: Download model
26+
- name: Download text generation model
2527
run: curl -L ${MODEL_URL} --create-dirs -o models/${MODEL_NAME}
28+
- name: Download reranking model
29+
run: curl -L ${RERANKING_MODEL_URL} --create-dirs -o models/${RERANKING_MODEL_NAME}
2630
- name: Run tests
2731
run: mvn test
2832
- if: failure()
@@ -53,8 +57,11 @@ jobs:
5357
run: |
5458
mvn compile
5559
.github/build.sh ${{ matrix.target.cmake }}
56-
- name: Download model
60+
- name: Download text generaton model model
5761
run: curl -L ${MODEL_URL} --create-dirs -o models/${MODEL_NAME}
62+
- name: Download reranking model
63+
run: curl -L ${RERANKING_MODEL_URL} --create-dirs -o models/${RERANKING_MODEL_NAME}
64+
5865
- name: Run tests
5966
run: mvn test
6067
- if: failure()
@@ -79,6 +86,9 @@ jobs:
7986
.github\build.bat -DLLAMA_VERBOSE=ON
8087
- name: Download model
8188
run: curl -L $env:MODEL_URL --create-dirs -o models/$env:MODEL_NAME
89+
- name: Download reranking model
90+
run: curl -L ${RERANKING_MODEL_URL} --create-dirs -o models/${RERANKING_MODEL_NAME}
91+
8292
- name: Run tests
8393
run: mvn test
8494
- if: failure()
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package de.kherud.llama;
2+
3+
import java.io.*;
4+
import java.util.*;
5+
import java.util.regex.Pattern;
6+
7+
import de.kherud.llama.args.LogFormat;
8+
import org.junit.AfterClass;
9+
import org.junit.Assert;
10+
import org.junit.BeforeClass;
11+
import org.junit.Ignore;
12+
import org.junit.Test;
13+
14+
public class RerankingModelTest {
15+
16+
private static LlamaModel model;
17+
18+
@BeforeClass
19+
public static void setup() {
20+
model = new LlamaModel(
21+
new ModelParameters().setCtxSize(128).setModel("models/jina-reranker-v1-tiny-en.Q4_K_M.gguf")
22+
.setGpuLayers(43).enableReranking().enableLogTimestamps().enableLogPrefix());
23+
}
24+
25+
@AfterClass
26+
public static void tearDown() {
27+
if (model != null) {
28+
model.close();
29+
}
30+
}
31+
32+
@Test
33+
public void testReRanking() {
34+
35+
String query = "Machine learning is";
36+
String[] TEST_DOCUMENTS = new String[] {
37+
"A machine is a physical system that uses power to apply forces and control movement to perform an action. The term is commonly applied to artificial devices, such as those employing engines or motors, but also to natural biological macromolecules, such as molecular machines.",
38+
"Learning is the process of acquiring new understanding, knowledge, behaviors, skills, values, attitudes, and preferences. The ability to learn is possessed by humans, non-human animals, and some machines; there is also evidence for some kind of learning in certain plants.",
39+
"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.",
40+
"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." };
41+
LlamaOutput llamaOutput = model.rerank(query, TEST_DOCUMENTS[0], TEST_DOCUMENTS[1], TEST_DOCUMENTS[2],
42+
TEST_DOCUMENTS[3]);
43+
44+
System.out.println(llamaOutput);
45+
}
46+
47+
}

0 commit comments

Comments
 (0)