@@ -35,26 +35,56 @@ Redis Query Engine.
35
35
36
36
## Initialize
37
37
38
- Install [ ` redis-py ` ] ({{< relref "/develop/clients/redis-py" >}}) if you
39
- have not already done so. Also, install ` sentence-transformers ` with the
40
- following command:
38
+ Install [ ` jedis ` ] ({{< relref "/develop/clients/jedis" >}}) if you
39
+ have not already done so.
40
+
41
+ If you are using [ Maven] ( https://maven.apache.org/ ) , add the following
42
+ dependencies to your ` pom.xml ` file:
43
+
44
+ ``` xml
45
+ <dependency >
46
+ <groupId >redis.clients</groupId >
47
+ <artifactId >jedis</artifactId >
48
+ <version >5.2.0</version >
49
+ </dependency >
50
+ <dependency >
51
+ <groupId >ai.djl.huggingface</groupId >
52
+ <artifactId >tokenizers</artifactId >
53
+ <version >0.24.0</version >
54
+ </dependency >
55
+ ```
56
+
57
+ If you are using [ Gradle] ( https://gradle.org/ ) , add the following
58
+ dependencies to your ` build.gradle ` file:
41
59
42
60
``` bash
43
- pip install sentence-transformers
61
+ implementation ' redis.clients:jedis:5.2.0'
62
+ implementation ' ai.djl.huggingface:tokenizers:0.24.0'
44
63
```
45
64
46
- In a new Python source file, start by importing the required classes:
65
+ ## Import dependencies
47
66
48
- ``` python
49
- from sentence_transformers import SentenceTransformer
50
- from redis.commands.search.query import Query
51
- from redis.commands.search.field import TextField, TagField, VectorField
52
- from redis.commands.search.indexDefinition import IndexDefinition, IndexType
67
+ Import the following classes in your source file:
53
68
54
- import numpy as np
55
- import redis
69
+ ``` java
70
+ // Jedis client and query engine classes.
71
+ import redis.clients.jedis.UnifiedJedis ;
72
+ import redis.clients.jedis.search.* ;
73
+ import redis.clients.jedis.search.schemafields.* ;
74
+ import redis.clients.jedis.search.schemafields.VectorField.VectorAlgorithm ;
75
+ import redis.clients.jedis.exceptions.JedisDataException ;
76
+
77
+ // Data manipulation.
78
+ import java.nio.ByteBuffer ;
79
+ import java.nio.ByteOrder ;
80
+ import java.util.Map ;
81
+ import java.util.List ;
82
+
83
+ // Tokenizer to generate the vector embeddings.
84
+ import ai.djl.huggingface.tokenizers.HuggingFaceTokenizer ;
56
85
```
57
86
87
+
58
88
The first of these imports is the
59
89
` SentenceTransformer ` class, which generates an embedding from a section of text.
60
90
Here, we create an instance of ` SentenceTransformer ` that uses the
0 commit comments