Skip to content

Commit b3e7d27

Browse files
authored
Added BAAI/bge-small-en-v1.5 models (#17)
1 parent 6ee4a37 commit b3e7d27

File tree

14 files changed

+61706
-1
lines changed

14 files changed

+61706
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>dev.langchain4j</groupId>
9+
<artifactId>langchain4j-embeddings-parent</artifactId>
10+
<version>0.29.0-SNAPSHOT</version>
11+
<relativePath>../pom.xml</relativePath>
12+
</parent>
13+
14+
<artifactId>langchain4j-embeddings-bge-small-en-v15-q</artifactId>
15+
<name>langchain4j-embeddings-bge-small-en-v15-q</name>
16+
<description>In-process bge-small-en-v1.5 (quantized) embedding model</description>
17+
18+
<dependencies>
19+
20+
<dependency>
21+
<groupId>dev.langchain4j</groupId>
22+
<artifactId>langchain4j-embeddings</artifactId>
23+
<version>${project.version}</version>
24+
</dependency>
25+
26+
<dependency>
27+
<groupId>org.junit.jupiter</groupId>
28+
<artifactId>junit-jupiter-engine</artifactId>
29+
<scope>test</scope>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>org.junit.jupiter</groupId>
34+
<artifactId>junit-jupiter-params</artifactId>
35+
<scope>test</scope>
36+
</dependency>
37+
38+
<dependency>
39+
<groupId>org.assertj</groupId>
40+
<artifactId>assertj-core</artifactId>
41+
<scope>test</scope>
42+
</dependency>
43+
44+
</dependencies>
45+
46+
<licenses>
47+
<license>
48+
<name>Apache-2.0</name>
49+
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
50+
<distribution>repo</distribution>
51+
<comments>A business-friendly OSS license</comments>
52+
</license>
53+
</licenses>
54+
55+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package dev.langchain4j.model.embedding.bge.small.en.v15;
2+
3+
import dev.langchain4j.model.embedding.AbstractInProcessEmbeddingModel;
4+
import dev.langchain4j.model.embedding.OnnxBertBiEncoder;
5+
import dev.langchain4j.model.embedding.PoolingMode;
6+
7+
/**
8+
* Quantized BAAI bge-small-en-v1.5 embedding model that runs within your Java application's process.
9+
* <p>
10+
* Maximum length of text (in tokens) that can be embedded at once: unlimited.
11+
* However, while you can embed very long texts, the quality of the embedding degrades as the text lengthens.
12+
* It is recommended to embed segments of no more than 512 tokens long.
13+
* <p>
14+
* Embedding dimensions: 384
15+
* <p>
16+
* It is recommended to add "Represent this sentence for searching relevant passages:" prefix to a query.
17+
* <p>
18+
* More details <a href="https://huggingface.co/BAAI/bge-small-en-v1.5">here</a>
19+
*/
20+
public class BgeSmallEnV15QuantizedEmbeddingModel extends AbstractInProcessEmbeddingModel {
21+
22+
private static final OnnxBertBiEncoder MODEL = loadFromJar(
23+
"bge-small-en-v1.5-q.onnx",
24+
"bge-small-en-v1.5-tokenizer.json",
25+
PoolingMode.CLS
26+
);
27+
28+
@Override
29+
protected OnnxBertBiEncoder model() {
30+
return MODEL;
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Original model card:
2+
https://huggingface.co/BAAI/bge-small-en-v1.5
3+
4+
ONNX model card:
5+
https://huggingface.co/Xenova/bge-small-en-v1.5
6+
7+
ONNX model file:
8+
https://huggingface.co/Xenova/bge-small-en-v1.5/resolve/main/onnx/model_quantized.onnx
9+
10+
Tokenizer:
11+
https://huggingface.co/Xenova/bge-small-en-v1.5/resolve/main/tokenizer.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:6c9c6101a956d62dfb5e7190c538226c0c5bb9cb27b651234b6df063ee7dbfe4
3+
size 34014426

0 commit comments

Comments
 (0)