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: modules/ROOT/pages/expressions/predicates/type-predicate-expressions.adoc
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -321,6 +321,9 @@ RETURN $int16param IS :: INTEGER AS isInteger
321
321
322
322
More information about parameters can be found xref::syntax/parameters.adoc[here].
323
323
324
+
[NOTE]
325
+
The xref:values-and-types/vector.adoc#vector-type[vector-only coordinate types] cannot be used as the numeric type to verify against in type predicate expressions.
326
+
324
327
[[type-predicate-syntax-variation]]
325
328
== Syntactical variations of type predicate expressions
| `vectorValue` | `STRING` \| `LIST<INTEGER \| FLOAT>` | The numeric values to create the vector coordinate from.
18
-
or `FLOAT` values, or a `STRING` defining the coordinates in the resulting `VECTOR`.
19
-
| `dimension` | `INTEGER` | The number of dimensions (coordinates) in the vector.
17
+
| `vectorValue` | `STRING` \| `LIST<INTEGER \| FLOAT>` | The numeric values to create the vector coordinates from.
18
+
| `dimension` | `INTEGER` | The dimension (number of coordinates) of the vector.
20
19
| `coordinateType` | `[INTEGER64, INTEGER32, INTEGER16, INTEGER8, FLOAT64, FLOAT32]` | The type of each coordinate in the vector.
21
20
| *Returns* 3+| `VECTOR`
22
21
|===
23
22
24
23
[NOTE]
25
24
The `VECTOR` values generated by the `vector()` function can be xref:values-and-types/vector.adoc#store-vector-properties[stored as properties].
26
25
As such, the `vector()` function can be used to store the embeddings generated by Neo4j's xref:genai-integrations.adoc[GenAI plugin] as `VECTOR` property values.
27
-
`VECTOR` properties can semantically searched by a xref:indexes/semantic-indexes/vector-indexes.adoc[vector index].
28
-
29
-
26
+
`VECTOR` properties can be semantically searched by a xref:indexes/semantic-indexes/vector-indexes.adoc[vector index].
30
27
31
28
.Considerations
32
29
|===
33
30
34
31
| If a `STRING` is used in `vectorValue`, it must start and end with square brackets (`[]`).
35
32
The values inside the brackets must be a number represented in either decimal or scientific notation and must be comma separated.
36
-
| `null`, NaN, and infinity values are not allowed in `vectorValue`.
33
+
| `null`, `NaN`, and `Infinity` values are not allowed as elements in the `LIST` used as `vectorValue`.
37
34
| If `vectorValue` contain elements that are not of the specified `coordinateType`, they will be coerced to that coordinate type if possible.
38
35
This includes the potential of lossy conversion in cases where a larger type, e.g. `INTEGER64` does not fit into the specified type, e.g. `FLOAT32`.
39
-
| If `dimension` is omitted, it is calculated by taking the size of the `vectorValue`.
40
-
For example a `vectorValue` with 1024 elements generates a `VECTOR` value with the dimension `1024`.
41
36
| `dimension` must be greater than `0` and less than or equal to `4096`.
42
-
| If `coordinateType` is omitted, the type will be determined by Cypher.
43
-
If the `LIST` used as `vectorValue` is mixed containing exclusively `INTEGER` values, then the largest of those types will be set as the `coordinateType`.
44
-
For example, `LIST<INTEGER64 \| INTEGER32`> generates a `VECTOR` value with a `coordinateType` of `INTEGER64`.
45
-
If the `vectorValue` contains both `FLOAT` and `INTEGER` values, then the `coordinateType` will be that of the largest `FLOAT` present in `vectorValue`.
46
-
For example, `LIST<INTEGER64 \| FLOAT64`> generates a `VECTOR` value with a `coordinateType` of `FLOAT64`.
47
-
| A `null` `vectorValue`, `dimension`, or `coordinateType` will return `null`.
37
+
| A `null` `vectorValue` or `dimension` will return `null`.
48
38
|===
49
39
50
40
.vector()
@@ -62,7 +52,7 @@ RETURN vector, valueType(vector) AS vectorType
62
52
|===
63
53
| vector | vectorType
64
54
65
-
| [1, 2, 3] | "VECTOR<INTEGER64 NOT NULL>(3) NOT NULL"
55
+
| [1, 2, 3] | "VECTOR<INTEGER NOT NULL>(3) NOT NULL"
66
56
67
57
2+d|Rows: 1
68
58
|===
@@ -85,39 +75,21 @@ RETURN vector, valueType(vector) AS vectorType
85
75
2+d|Rows: 1
86
76
|===
87
77
88
-
.Construct a `VECTOR` value omitting both `dimension` and `coordinateType`
| *Description* 3+| Returns a `FLOAT` representing the norm (distance) between the given vector and an origin vector of the same dimension with all coordinates set to zero, calculated using the specified `vectorDistanceMetric`.
353
+
| *Description* 3+| Returns a `FLOAT` representing the distance between the given vector and an origin vector, which is a vector with the same dimension with all coordinates set to zero, calculated using the specified `vectorDistanceMetric`.
Copy file name to clipboardExpand all lines: modules/ROOT/pages/genai-integrations.adoc
+56-49Lines changed: 56 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ Dump files can be imported for both link:{neo4j-docs-base-uri}/aura/auradb/impor
42
42
The embeddings on this are generated using link:https://platform.openai.com/docs/guides/embeddings[OpenAI] (model `text-embedding-ada-002`), producing 1536-dimensional vectors.
43
43
44
44
[[single-embedding]]
45
-
== Generate a single embedding
45
+
== Generate a single embedding and store it
46
46
47
47
Use the `genai.vector.encode()` function to generate a vector embedding for a single value.
48
48
@@ -66,23 +66,23 @@ This function sends one API request every time it is called, which may result in
66
66
If you want to generate many embeddings at once, use xref:genai-integrations.adoc#multiple-embeddings[].
To convert and store this value as a xref:values-and-types/vector.adoc[`VECTOR` property type], use the xref:functions/vector.adoc#functions-vector[`vector()`] function.
76
+
To convert and store this value as a xref:values-and-types/vector.adoc[`VECTOR` property type (introduced in Neo4j 2025.xx)], use the xref:functions/vector.adoc#functions-vector[`vector()`] function.
77
+
Storing `VECTOR` values on an on-prem instance requires Enterprise Edition and using Neo4j's link:{neo4j-docs-base-uri}/operations-manual/current/database-internals/store-formats/#store-format-overview[block format].
=== Store multiple embeddings as VECTOR property values
208
191
209
-
`genai.vector.encodeBatch()` returns a `LIST<FLOAT>` value.
210
-
To convert and store this value as a xref:values-and-types/vector.adoc[`VECTOR` property type], use the xref:functions/vector.adoc#functions-vector[`vector()`] function.
211
-
The full function signature can be seen xref:genai-integrations.adoc#store-single-embedding-vector[above].
212
192
213
-
.Create embeddings from a limited number of properties and store them as `VECTOR` properties
193
+
[.tabbed-example]
214
194
====
195
+
[.include-with-Store-embeddings-as-vectors]
196
+
======
215
197
216
-
[source, cypher, role=test-skip]
198
+
`genai.vector.encode()` returns a `LIST<FLOAT>`.
199
+
To convert and store this value as a xref:values-and-types/vector.adoc[`VECTOR` property type (introduced in Neo4j 2025.xx)], use the xref:functions/vector.adoc#functions-vector[`vector()`] function.
200
+
Storing `VECTOR` values on an on-prem instance requires Enterprise Edition and using Neo4j's link:{neo4j-docs-base-uri}/operations-manual/current/database-internals/store-formats/#store-format-overview[block format].
<1> xref:functions/aggregating.adoc#functions-collect[Collect] all 20 `Movie` nodes into a `LIST<NODE>`.
229
222
<2> Use a xref:expressions/list-expressions.adoc#list-comprehension[list comprehension] (`[]`) to extract the `title` and `plot` properties of the movies in `moviesList` into a new `LIST<STRING>`.
230
223
<3> `db.create.setNodeVectorProperty` is run for each `vector` returned by `genai.vector.encodeBatch()`, and stores that vector as a property named `embedding` on the corresponding node.
231
-
====
232
224
233
225
.Create embeddings from a large number properties and store them as `VECTOR` properties
234
-
====
235
226
[source, cypher, role=test-skip]
236
227
----
237
228
MATCH (m:Movie WHERE m.plot IS NOT NULL)
@@ -263,18 +254,35 @@ For more information on concurrency in transactions, see xref:subqueries/subquer
263
254
This example may not scale to larger datasets, as `collect(m)` requires the whole result set to be loaded in memory.
264
255
For an alternative method more suitable to processing large amounts of data, see link:https://neo4j.com/docs/genai/tutorials/embeddings-vector-indexes/[GenAI documentation - Embeddings & Vector Indexes Tutorial -> Create embeddings with cloud AI providers].
265
256
266
-
====
257
+
======
267
258
268
-
[[store-multiple-embeddings-list-float]]
269
-
=== Store multiple embeddings as `LIST<FLOAT>` properties
259
+
260
+
[.include-with-Store-embeddings-as-lists]
261
+
======
270
262
271
263
Use the `db.create.setNodeVectorProperty` procedure to store an embedding as a `LIST<FLOAT>` value to a node property.
264
+
265
+
.Signature for `db.create.setNodeVectorProperty` label:procedure[]
<1> xref:functions/aggregating.adoc#functions-collect[Collect] all 20 `Movie` nodes into a `LIST<NODE>`.
291
299
<2> Use a xref:expressions/list-expressions.adoc#list-comprehension[list comprehension] (`[]`) to extract the `title` and `plot` properties of the movies in `moviesList` into a new `LIST<STRING>`.
292
300
<3> `db.create.setNodeVectorProperty` is run for each `vector` returned by `genai.vector.encodeBatch()`, and stores that vector as a property named `embedding` on the corresponding node.
293
-
====
294
301
295
302
.Create embeddings from a large number properties and store them as `LIST<FLOAT>` values
296
-
====
297
303
[source, cypher, role=test-skip]
298
304
----
299
305
MATCH (m:Movie WHERE m.plot IS NOT NULL)
@@ -325,6 +331,7 @@ For more information on concurrency in transactions, see xref:subqueries/subquer
325
331
This example may not scale to larger datasets, as `collect(m)` requires the whole result set to be loaded in memory.
326
332
For an alternative method more suitable to processing large amounts of data, see link:https://neo4j.com/docs/genai/tutorials/embeddings-vector-indexes/[GenAI documentation - Embeddings & Vector Indexes Tutorial -> Create embeddings with cloud AI providers].
0 commit comments