Skip to content

Commit

Permalink
- Utility methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjzazuet committed Jul 10, 2023
1 parent b962ad0 commit 76c5bbe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:<LATEST_VERSION>>")
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/BtTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand Down

0 comments on commit 76c5bbe

Please sign in to comment.