-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation for Vector Collections in Jet [HZAI-77] (#1125)
TODO: - [ ] beta and enterprise markers - [ ] link to [Vector collection data structure](#1124) docs - [ ] use consistent wording with V[ector collection data structure docs](#1124) --------- Co-authored-by: rebekah-lawrence <[email protected]> Co-authored-by: Oliver Howell <[email protected]>
- Loading branch information
1 parent
9dedce5
commit 9e2f876
Showing
5 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
docs/modules/integrate/pages/vector-collection-connector.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
= Vector Collection Connector | ||
:description: Vector collection stores vectors with their related metadata. This allows entries to be found efficiently based on vector distance. | ||
:page-enterprise: true | ||
:page-beta: true | ||
|
||
{description} | ||
|
||
For further information on vector collections, see xref:data-structures:vector-collections.adoc[]. | ||
|
||
== Installing the Connector | ||
|
||
This connector is included in the full and slim {enterprise-product-name} distributions of Hazelcast. | ||
|
||
== Permissions | ||
If xref:security:enabling-jaas.adoc[security] is enabled, you can set up permissions to restrict clients' access to these data structures. | ||
|
||
To search in vector collection, you must add the `create` and `read` permissions for those collections. If you use the vector collection sink to write to vector collections, you must add the `create` and `put` permissions for those collections. | ||
|
||
For further information on adding these permissions, see xref:security:native-client-security.adoc[]. | ||
|
||
|
||
== Vector Collection as a Sink | ||
|
||
To write an entry to a vector collection, to index it for searching, create a key and `VectorDocument`, which consists of | ||
additional metadata and vectors (embeddings). Embeddings can be generated earlier in the pipeline or loaded or obtained from external source. | ||
|
||
|
||
```java | ||
Pipeline p = Pipeline.create(); | ||
p.readFrom(Sources.<String, String>map("idToDocumentText")) | ||
// generate embeddings | ||
.mapUsingService(getAllMiniLmL6V2EmbeddingModelServiceFactory(), | ||
(service, e) -> tuple3(e.getKey(), e.getValue(), VectorValues.of(service.embed(e.getValue()).content().vector()))) | ||
// write to vector collection | ||
.writeTo(VectorSinks.vectorCollection("indexedDocuments", Tuple3::f0, Tuple3::f1, Tuple3::f2)); | ||
``` | ||
|
||
|
||
== Searching in Vector Collection | ||
|
||
You can search vector collections in Jet pipelines using `VectorTransforms.mapUsingVectorSearch` transformation. | ||
|
||
```java | ||
Pipeline p = Pipeline.create(); | ||
p.readFrom(TestSources.items("text to search for")) | ||
// generate embedding for the object for which we are finding similarities | ||
.mapUsingService(getAllMiniLmL6V2EmbeddingModelServiceFactory(), | ||
(service, query) -> tuple2(query, VectorValues.of(service.embed(query).content().vector()))) | ||
// find similar objects | ||
.apply(VectorTransforms.mapUsingVectorSearch("indexedDocuments", | ||
SearchOptions.builder().limit(10).includeValue().build(), | ||
// query vector | ||
Tuple3::f1, | ||
// process the search results | ||
(input, result) -> tuple2(input, result))) | ||
// use the results | ||
.writeTo(Sinks.logger()); | ||
``` |