From 76c5bbe8518e26a4a6b07f8b8213d112c29b6272 Mon Sep 17 00:00:00 2001 From: Jesus Zazueta Date: Sun, 9 Jul 2023 21:04:39 -0400 Subject: [PATCH] - Utility methods. --- README.md | 2 +- src/test/java/BtTest.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 30504c7..ff47807 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Provides JNI bindings for [bert.cpp](https://github.com/skeskinen/bert.cpp). -Available in [Maven Central](https://mvnrepository.com/artifact/io.vacco.bert). +Available in [Maven Central](https://mvnrepository.com/artifact/io.vacco.bert/bert.jni). ``` implementation("io.vacco.bert:bert.jni:>") diff --git a/src/test/java/BtTest.java b/src/test/java/BtTest.java index 4e50b0b..e1f73c0 100644 --- a/src/test/java/BtTest.java +++ b/src/test/java/BtTest.java @@ -16,7 +16,7 @@ public class BtTest { public static final File modelPath = new File("/home/jjzazuet/code/bert.cpp/models/multi-qa-MiniLM-L6-cos-v1/ggml-model-f16.bin"); - public static BtContext bt = new BtContext(modelPath, 4); + public static BtContext bt; public static float cosineSimilarity(float[] vectorA, float[] vectorB) { float dotProduct = 0.0f; @@ -32,6 +32,10 @@ public static float cosineSimilarity(float[] vectorA, float[] vectorB) { static { if (!GraphicsEnvironment.isHeadless()) { + it("Opens a BERT context", () -> { + System.out.println("Opening BERT context"); + BtTest.bt = new BtContext(modelPath, 4); + }); it("Encodes a sentence into an embedding", () -> { var embedding = bt.eval("This is a prompt, it should get tokenized."); System.out.println(Arrays.toString(embedding));