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: documentation/src/main/asciidoc/userguide/chapters/query/extensions/Vector.adoc
+116-7Lines changed: 116 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,15 +53,25 @@ so no further configuration is necessary to make the features available.
53
53
[[vector-module-usage]]
54
54
==== Usage
55
55
56
-
Annotate a persistent attribute with `@JdbcTypeCode(SqlTypes.VECTOR)` and specify the vector length with `@Array(length = ...)`.
56
+
Annotate a persistent attribute with one of the various vector type codes `@JdbcTypeCode` and specify the vector length with `@Array(length = ...)`.
57
+
Possible vector type codes and the compatible Java types are:
58
+
59
+
* `@JdbcTypeCode(SqlTypes.VECTOR_BINARY)` for `byte[]`
60
+
* `@JdbcTypeCode(SqlTypes.VECTOR_INT8)` for `byte[]`
61
+
* `@JdbcTypeCode(SqlTypes.VECTOR_FLOAT16)` for `float[]`
62
+
* `@JdbcTypeCode(SqlTypes.VECTOR_FLOAT32)` for `float[]`
63
+
* `@JdbcTypeCode(SqlTypes.VECTOR_FLOAT64)` for `double[]`
64
+
* `@JdbcTypeCode(SqlTypes.VECTOR)` for `float[]`
65
+
66
+
Hibernate ORM also provides support for sparse vectors through dedicated Java types:
67
+
68
+
* `@JdbcTypeCode(SqlTypes.SPARSE_VECTOR_INT8)` for `SparseByteVector`
69
+
* `@JdbcTypeCode(SqlTypes.SPARSE_VECTOR_FLOAT32)` for `SparseFloatVector`
70
+
* `@JdbcTypeCode(SqlTypes.SPARSE_VECTOR_FLOAT64)` for `SparseDoubleVector`
57
71
58
72
[WARNING]
59
73
====
60
-
As Oracle AI Vector Search supports different types of elements (to ensure better performance and compatibility with embedding models), you can also use:
61
-
62
-
- `@JdbcTypeCode(SqlTypes.VECTOR_INT8)` for `byte[]`
63
-
- `@JdbcTypeCode(SqlTypes.VECTOR_FLOAT32)` for `float[]`
64
-
- `@JdbcTypeCode(SqlTypes.VECTOR_FLOAT64)` for `double[]`.
74
+
Vector data type support depends on native support of the underlying database.
65
75
====
66
76
67
77
[[vector-module-usage-example]]
@@ -88,14 +98,21 @@ Expressions of the vector type can be used with various vector functions.
88
98
| `euclidean_distance()` | Computes the https://en.wikipedia.org/wiki/Euclidean_distance[euclidean distance] between two vectors. Maps to the `<``-``>` operator for `pgvector` and maps to the
89
99
`vector_distance(v1, v2, EUCLIDEAN)` function for `Oracle AI Vector Search`.
90
100
101
+
| `euclidean_squared_distance()` | Computes the https://en.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance[squared euclidean distance] between two vectors.
102
+
91
103
| `l2_distance()` | Alias for `euclidean_distance()`
92
104
105
+
| `l2_squared_distance()` | Alias for `euclidean_squared_distance()`
106
+
93
107
| `taxicab_distance()` | Computes the https://en.wikipedia.org/wiki/Taxicab_geometry[taxicab distance] between two vectors. Maps to `vector_distance(v1, v2, MANHATTAN)` function for `Oracle AI Vector Search`.
94
108
95
109
| `l1_distance()` | Alias for `taxicab_distance()`
96
110
97
111
| `hamming_distance()` | Computes the https://en.wikipedia.org/wiki/Hamming_distance[hamming distance] between two vectors. Maps to `vector_distance(v1, v2, HAMMING)` function for `Oracle AI Vector Search`.
98
112
113
+
| `jaccard_distance()` | Computes the https://en.wikipedia.org/wiki/Jaccard_index[jaccard distance] between two vectors. Maps to the `<``%``>` operator for `pgvector` and maps to the
114
+
`vector_distance(v1, v2, JACCARD)` function for `Oracle AI Vector Search`.
115
+
99
116
| `inner_product()` | Computes the https://en.wikipedia.org/wiki/Inner_product_space[inner product] between two vectors
100
117
101
118
| `negative_inner_product()` | Computes the negative inner product. Maps to the `<``#``>` operator for `pgvector` and maps to the
@@ -104,6 +121,14 @@ Expressions of the vector type can be used with various vector functions.
104
121
| `vector_dims()` | Determines the dimensions of a vector
105
122
106
123
| `vector_norm()` | Computes the https://en.wikipedia.org/wiki/Euclidean_space#Euclidean_norm[Euclidean norm] of a vector
124
+
125
+
| `l2_norm()` | Alias for `vector_norm()`
126
+
127
+
| `l2_normalize()` | Normalizes each component of a vector by dividing it with the https://en.wikipedia.org/wiki/Euclidean_space#Euclidean_norm[Euclidean norm] of the vector.
128
+
129
+
| `binary_quantize()` | Reduces a vector of size N to a binary vector with N bits, using 0 for values <= 0 and 1 for values > 0.
130
+
131
+
| `subvector()` | Creates a subvector from a given vector, a 1-based start index and a count.
107
132
|===
108
133
109
134
In addition to these special vector functions, it is also possible to use vectors with the following builtin `pgvector` operators:
Normalizes each component of a vector by dividing it with the https://en.wikipedia.org/wiki/Euclidean_space#Euclidean_norm[Euclidean norm] of the vector.
Copy file name to clipboardExpand all lines: hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/GaussDBCastingInetJdbcType.java
Copy file name to clipboardExpand all lines: hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/GaussDBCastingIntervalSecondJdbcType.java
Copy file name to clipboardExpand all lines: hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/GaussDBCastingJsonArrayJdbcType.java
Copy file name to clipboardExpand all lines: hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/GaussDBCastingJsonJdbcType.java
0 commit comments