You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/vectorize/best-practices/create-indexes.mdx
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,8 @@ Creating an index requires three inputs:
15
15
- The (fixed) [dimension size](#dimensions) of each vector, for example 384 or 1536.
16
16
- The (fixed) [distance metric](#distance-metrics) to use for calculating vector similarity.
17
17
18
+
An index cannot be created using the same name as an index previously deleted on your account.
19
+
18
20
The configuration of an index cannot be changed after creation.
19
21
20
22
## Create an index
@@ -103,4 +105,6 @@ Distance metrics are functions that determine how close vectors are from each ot
103
105
104
106
Determining the similarity between vectors can be subjective based on how the machine-learning model that represents features in the resulting vector embeddings. For example, a score of `0.8511` when using a `cosine` metric means that two vectors are close in distance, but whether data they represent is _similar_ is a function of how well the model is able to represent the original content.
105
107
108
+
When querying vectors, you can specify Vectorize to either use high-precision scoring, increasing the precision of the query matches scores as well as the accuracy of the query results, or use approximate scoring for faster response times. Using approximate scoring, returned scores will be an approximation of the real distance/similarity between your query and the returned vector. See [Control over scoring precision and query accuracy](/vectorize/best-practices/query-vectors/#control-over-scoring-precision-and-query-accuracy)
109
+
106
110
Distance metrics cannot be changed after index creation, and that each metric has a different scoring function.
Copy file name to clipboardExpand all lines: src/content/docs/vectorize/best-practices/insert-vectors.mdx
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ Vectorize indexes allow you to insert vectors at any point: Vectorize will optim
13
13
14
14
If the same vector id is _inserted_ twice in a Vectorize index, the index would reflect the vector that was added first.
15
15
16
-
If the same vector id is _upserted_ twice in a Vectorize index, the index would reflect the vector that was added second.
16
+
If the same vector id is _upserted_ twice in a Vectorize index, the index would reflect the vector that was added last.
17
17
18
18
Use the upsert operation if you want to overwrite the vector value for a vector id that already exists in an index.
19
19
@@ -38,8 +38,8 @@ Metadata keys cannot be empty, contain the dot character (`.`), contain the doub
38
38
Metadata can be used to:
39
39
40
40
- Include the object storage key, database UUID or other identifier to look up the content the vector embedding represents.
41
-
-The raw content (up to the [metadata limits](/vectorize/platform/limits/)), which can allow you to skip additional lookups for smaller content.
42
-
-Dates, timestamps, or other metadata that describes when the vector embedding was generated or how it was generated.
41
+
-Store JSON data (up to the [metadata limits](/vectorize/platform/limits/)), which can allow you to skip additional lookups for smaller content.
42
+
-Keep track of dates, timestamps, or other metadata that describes when the vector embedding was generated or how it was generated.
43
43
44
44
For example, a vector embedding representing an image could include the path to the [R2 object](/r2/) it was generated from, the format, and a category lookup:
45
45
@@ -55,7 +55,7 @@ To associate vectors with a namespace, you can optionally provide a `namespace:
55
55
56
56
A namespace can be up to 64 characters (bytes) in length and you can have up to 1,000 namespaces per index. Refer to the [Limits](/vectorize/platform/limits/) documentation for more details.
57
57
58
-
When a namespace is specified in a query operation, only vectors within that namespace are used for the search. Namespace filtering is applied before vector search, not after.
58
+
When a namespace is specified in a query operation, only vectors within that namespace are used for the search. Namespace filtering is applied before vector search, increasing the precision of the matched results.
Copy file name to clipboardExpand all lines: src/content/docs/vectorize/best-practices/query-vectors.mdx
+9-2Lines changed: 9 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ A query vector is either an array of JavaScript numbers, 32-bit floating point o
17
17
18
18
```ts
19
19
// query vector dimensions must match the Vectorize index dimension being queried
20
-
let queryVector = [54.8, 5.5, 3.1, ...];
20
+
let queryVector = [54.8, 5.5, 3.1, ...];
21
21
let matches =awaitenv.YOUR_INDEX.query(queryVector);
22
22
```
23
23
@@ -42,7 +42,7 @@ You can optionally change the number of results returned and/or whether results
42
42
43
43
```ts
44
44
// query vector dimensions must match the Vectorize index dimension being queried
45
-
let queryVector = [54.8, 5.5, 3.1, ...];
45
+
let queryVector = [54.8, 5.5, 3.1, ...];
46
46
// topK defaults to 5; returnValues defaults to false; returnMetadata defaults to "none"
47
47
let matches =awaitenv.YOUR_INDEX.query(queryVector, {
48
48
topK: 1,
@@ -71,6 +71,13 @@ This would return a set of matches resembling the following, based on the distan
71
71
72
72
Refer to [Vectorize API](/vectorize/reference/client-api/) for additional examples.
73
73
74
+
## Control over scoring precision and query accuracy
75
+
76
+
When querying vectors, you can specify to either use high-precision scoring, increasing the precision of the query matches scores as well as the accuracy of the query results, or use approximate scoring for faster response times.
77
+
Using approximate scoring, returned scores will be an approximation of the real distance/similarity between your query and the returned vector.
78
+
79
+
High-precision scoring is enabled by setting `returnValues: true` on your query; this tells Vectorize to fetch and use the original vector values for your matches, which enables the computation of exact scores of matches, increasing the accuracy of the results.
80
+
74
81
## Workers AI
75
82
76
83
If you are generating embeddings from a [Workers AI](/workers-ai/models/#text-embeddings) text embedding model, the response type from `env.AI.run()` is an object that includes both the `shape` of the response vector - e.g. `[1,768]` - and the vector `data` as an array of vectors:
0 commit comments