Skip to content

Commit 6c3028b

Browse files
committed
RDoc-3254 Update the embedding-collections article to match the latest code +
Update images + Small fixes to flow charts + Fix to configuration + Updated the expiration policy
1 parent 355700b commit 6c3028b

9 files changed

+70
-57
lines changed

Documentation/7.0/Raven.Documentation.Pages/ai-integration/generating-embeddings/embedding-collections.markdown

+68-55
Original file line numberDiff line numberDiff line change
@@ -8,60 +8,61 @@
88

99
* The server creates the following dedicated collections,
1010
which contain documents that reference the embedding attachments:
11-
* **Embeddings Collection**
11+
* **Embeddings Collections**
1212
* **Embeddings Cache Collection**
1313

1414
* This article describes these custom-designed collections.
15-
It is recommended to first refer to this [overview](../../ai-integration/generating-embeddings/overview#embeddings-generation---overview)
15+
It is recommended to first refer to this [Overview](../../ai-integration/generating-embeddings/overview#embeddings-generation---overview)
1616
to understand the embeddings generation process flow.
1717

1818
---
1919

2020
* In this article:
21-
* [The embeddings collection](../../ai-integration/generating-embeddings/embedding-collections#the-embeddings-collection)
21+
* [The embeddings collections](../../ai-integration/generating-embeddings/embedding-collections#the-embeddings-collections)
2222
* [The embeddings cache collection](../../ai-integration/generating-embeddings/embedding-collections#the-embeddings-cache-collection)
2323

2424
{NOTE/}
2525

2626
---
2727

28-
{PANEL: The embeddings collection}
28+
{PANEL: The embeddings collections}
2929

3030
* RavenDB creates a separate embeddings collection for each source collection from which embeddings are generated.
3131
The naming format for these collections is: `<source-collection-name>/embeddings`.
3232

33-
* Each document in the embeddings collection references ALL embeddings generated from the content of the corresponding document in the source collection by any defined embeddings generation task.
33+
* Each document in the embeddings collection references ALL embeddings generated from
34+
the content of the corresponding document in the source collection by any defined embeddings generation task.
3435

3536
* The document structure in the embeddings collection is:
3637

3738
{CODE-BLOCK:json}
3839
{
39-
"identifier-of-task-1": {
40-
"@quantization": "<quantization-type>", // Shown only if embeddings are Quantized
41-
"Property1": [
42-
"A hash created from the 1st text chunk of Property1's content",
43-
"A hash created from the 2nd text chunk of Property1's content",
44-
"A hash created from the 3rd text chunk of Property1's content",
45-
"..."
46-
],
47-
"Property2": [
48-
"A hash created from the 1st text chunk of Property2's content",
49-
"..."
50-
]
51-
},
52-
"identifier-of-task-2": {
53-
"Property3": [
54-
"A hash created from the 1st text chunk of Property3's content",
55-
"..."
56-
]
57-
},
58-
"Other-tasks...": {
59-
...
60-
},
61-
"@metadata": {
62-
"@collection": "<source-collection-name>/embeddings",
63-
"@flags": "HasAttachments"
64-
}
40+
"identifier-of-task-1": {
41+
"@quantization": "<quantization-type>",
42+
"Property1": [
43+
"Hash of the embedding vector generated for 1st text chunk of Property1's content",
44+
"Hash of the embedding vector generated for 2nd text chunk of Property1's content",
45+
"Hash of the embedding vector generated for 3rd text chunk of Property1's content",
46+
"..."
47+
],
48+
"Property2": [
49+
"Hash of the embedding vector generated for 1st text chunk of Property2's content",
50+
"..."
51+
]
52+
},
53+
"identifier-of-task-2": {
54+
"Property3": [
55+
"Hash of the embedding vector generated for 1st text chunk of Property3's content",
56+
"..."
57+
]
58+
},
59+
"Other-tasks...": {
60+
...
61+
},
62+
"@metadata": {
63+
"@collection": "<source-collection-name>/embeddings",
64+
"@flags": "HasAttachments"
65+
}
6566
}
6667
{CODE-BLOCK/}
6768

@@ -79,43 +80,49 @@
7980
2. **Document ID**
8081
Each document ID in this collection follows the format: `<source-document-name>/embeddings`
8182
3. **Task identifier**
82-
The identifier of the task that generated the embeddings for the listed properties.
83-
4. **Source properties & their hash**:
83+
The identifier of the task that generated the embeddings for the listed properties.
84+
4. **Quantization type**
85+
The quantization method applied by the task when generating the embeddings.
86+
5. **Source properties & their hashes**:
8487
This section contains properties from the source document whose content was converted into embeddings.
85-
Each property contains an array of hashes derived from text chunks created from the property's content:
86-
`<property-name>: [<hash-created-from-text-chunk-1>, <hash-created-from-text-chunk-2>, ...]`
87-
5. **Attachment flag**
88+
Each property holds an array of Base64 hashes.
89+
Each hash is derived from the content of an embedding vector generated for a text chunk from the property's content:
90+
`<property-name>: [`
91+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`<hash-of-the-embedding-vector-for-text-chunk-1>,`
92+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`<hash-of-the-embedding-vector-for-text-chunk-2>,`
93+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`...`
94+
`]`
95+
6. **Attachment flag**
8896
Indicates that the document includes attachments, which store the embeddings.
8997
The next image shows the embedding attachments in the document's properties pane.
9098

9199
![The embeddings document - attachments](images/embeddings-collection-2.png)
92100

93-
* Each attachment contains a single embedding.
94-
95-
* The attachment name follows this format:
96-
`<task-identifier>_<property-name>_<hash-of-text-chunk-from-property-content>`
97-
98-
* If the embeddings were [Quantized](../../ai-integration/vector-search/vector-search-using-dynamic-query#what-is-quantization) by the task,
99-
the format includes the quantization type:
100-
`<task-identifier>_<property-name>_<hash-of-text-chunk-from-property-content>_<quantization-type>`
101+
* Each attachment contains a **single embedding**.
102+
103+
* The **attachment name** is the Base64 hash derived from the content of the embedding vector stored in the attachment:
104+
`<hash-of-the-embedding-vector-content>`
101105

102106
{PANEL/}
103107

104108
{PANEL: The embeddings cache collection}
105109

106110
{CONTENT-FRAME: }
107111

112+
#### Cache contents
113+
---
114+
108115
* In addition to creating embeddings collections for each source collection,
109116
RavenDB creates and maintains a single **embeddings cache collection** named: `@embeddings-cache`.
110117

111-
* This collection references all embeddings generated by all providers for all source collections.
112-
It includes embeddings generated from source documents as well as embeddings generated from search terms in vector search queries.
118+
* This cache collection contains embeddings generated by all providers,
119+
both from source documents and from search terms used in vector search queries.
113120

114-
* Each document in the `@embeddings-cache` collection references a **single attachment** containing an embedding vector.
121+
* Each document in the `@embeddings-cache` collection references a **single attachment** that contains a single embedding vector.
115122
**The document ID includes**:
116123
* The [connection string identifier](../../ai-integration/connection-strings/connection-strings-overview#creating-an-ai-connection-string),
117124
which specifies the provider and model that generated the embedding.
118-
* A hash generated from a text chunk - either from a source document property or from a search term.
125+
* A Base64 hash generated from a text chunk value - either from a source document property or from a search term.
119126
* If the embedding was quantized by the task, the document ID also includes the quantization type.
120127

121128
{CONTENT-FRAME/}
@@ -158,11 +165,16 @@
158165
#### Expiration policy
159166
---
160167

161-
* Each document in this cache collection has an expiration date.
168+
* **The expiration date**:
169+
Each document in this cache collection is created with an expiration date, which is set according to the expiration period defined in the embeddings generation task.
162170
Once the expiration date is reached, the document is automatically deleted (provided that [document expiration](../../studio/database/settings/document-expiration) is enabled).
163171

164-
* When a source document (from which embeddings were generated) is modified,
165-
RavenDB extends the expiration date of the relevant document in this cache if the remaining time is less than one-third of the original duration.
172+
* **Extending the expiration period**:
173+
* When a source document (from which embeddings were generated) is modified - even if the change is not to a property used for embeddings -
174+
RavenDB checks the expiration of the matching document in the cache collection.
175+
If the remaining time is less than half of the original duration, RavenDB extends the expiration by the period defined in the task.
176+
* When you make a vector search query and an embedding generated from a chunk of the search term already exists in the cache,
177+
RavenDB also extends the expiration of the matching document by the period defined in the query settings of the embeddings generation task.
166178

167179
{CONTENT-FRAME/}
168180

@@ -179,7 +191,7 @@
179191
The document ID includes the connection string identifier, which specifies the provider that generated the embedding.
180192

181193
3. **Hash**
182-
The document ID includes a hash created from a text chunk -
194+
The document ID includes a Base64 hash created from a text chunk -
183195
either from a source document property or from a search term in a vector search query.
184196

185197
---
@@ -192,8 +204,9 @@
192204
The document ID follows this format:
193205
`embeddings-cache/<connection-string-identifier>/<hash-of-text-chunk-from-property-or-search-term>`
194206

195-
If the embedding was [Quantized](../../ai-integration/vector-search/vector-search-using-dynamic-query#what-is-quantization) by the task,
196-
the format includes the quantization type:
207+
If the embedding was [quantized](../../ai-integration/vector-search/vector-search-using-dynamic-query#what-is-quantization) by the task
208+
using a type other than _Single_ (e.g., _Int8_ or _Binary_),
209+
the ID format includes the quantization type:
197210
`embeddings-cache/<connection-string-identifier>/<hash-of-text-chunk-from-property-or-search-term>/<quantization-type>`
198211

199212
2. **Expiration time**
@@ -205,7 +218,7 @@
205218

206219
![The embeddings cache - attachments](images/embeddings-cache-3.png)
207220

208-
* In the cache collection, the attachment name consists only of the hash:
221+
* The name of the attachment is the hash string:
209222
`<hash-of-text-chunk-from-property-or-search-term>`
210223

211224
{PANEL/}

Documentation/7.0/Raven.Documentation.Pages/server/configuration/ai-integration-configuration.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* [Ai.Embeddings.MaxConcurrentBatches](../../server/configuration/ai-integration-configuration#ai.embeddings.maxconcurrentbatches)
1414
* [Ai.Embeddings.MaxFallbackTimeInSec](../../server/configuration/ai-integration-configuration#ai.embeddings.maxfallbacktimeinsec)
1515

16-
1716
{NOTE/}
1817

1918
---
@@ -31,12 +30,13 @@ Higher values may improve throughput but can increase latency and require more r
3130

3231
{PANEL: Ai.Embeddings.MaxConcurrentBatches}
3332

34-
The maximum number of query embedding batches that can be processed concurrently.
33+
The maximum number of **query embedding batches** that can be processed concurrently.
3534
This setting controls the degree of parallelism when sending query embedding requests to AI providers.
3635
Higher values may improve throughput but can increase resource usage and may trigger rate limits.
3736

3837
- **Type**: `int`
3938
- **Default**: `4`
39+
- **Min value**: `1`
4040
- **Scope**: Server-wide or per database
4141

4242
{PANEL/}

0 commit comments

Comments
 (0)