Skip to content

Commit dfd1566

Browse files
authored
DEV: FP32 (vectorsets) should explicitly document endianness (#1981)
1 parent f887bf1 commit dfd1566

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

content/commands/vadd.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ is the name of the key that will hold the vector set data.
3838
<details open>
3939
<summary><code>FP32 vector or VALUES num vector</code></summary>
4040

41-
either a 32-bit floating point (FP32) blob of values or `num` floating point numbers as strings.
41+
either a 32-bit floating point (FP32) blob of values or `num` floating point numbers as strings. When using the FP32 format, the blob must use little-endian encoding. On platforms with different endianness, you should either manually adjust the byte order or use the VALUES syntax instead.
4242
</details>
4343

4444
<details open>

content/commands/vemb.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ One of the following:
8282
* [Array reply](../../develop/reference/protocol-spec#arrays): consisting of the following elements:
8383
1. The quantization type as a [simple string](../../develop/reference/protocol-spec#simple-strings): `fp32`, `bin`, or `q8`.
8484
1. A [bulk string](../../develop/reference/protocol-spec#bulk-strings) blob with the following raw data:
85-
* 4-byte floats for fp32
85+
* 4-byte floats for fp32 (little-endian encoding)
8686
* A bitmap for binary quantization
8787
* A byte array for q8
8888
1. The L2 norm, as a [simple string](../../develop/reference/protocol-spec#simple-strings), of the vector before normalization.
@@ -95,7 +95,7 @@ One of the following:
9595
* [Array reply](../../develop/reference/protocol-spec#arrays): consisting of the following elements:
9696
1. The quantization type as a [simple string](../../develop/reference/protocol-spec#simple-strings): `fp32`, `bin`, or `q8`.
9797
1. A [bulk string](../../develop/reference/protocol-spec#bulk-strings) blob with the following raw data:
98-
* 4-byte floats for fp32
98+
* 4-byte floats for fp32 (little-endian encoding)
9999
* A bitmap for binary quantization
100100
* A byte array for q8
101101
1. The [double](../../develop/reference/protocol-spec#doubles) L2 norm of the vector before normalization.

content/commands/vlinks.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,16 @@ includes similarity scores for each neighbor.
6666
tab2="RESP3" >}}
6767

6868
One of the following:
69-
* [Array reply](../../develop/reference/protocol-spec#arrays) containing the names of adjacent elements as [strings](../../develop/reference/protocol-spec#simple-strings); interleved with scores when using the WITHSCORES option.
69+
* An [array](../../develop/reference/protocol-spec#arrays) of [array replies](../../develop/reference/protocol-spec#arrays) containing the names of adjacent elements as [bulk strings](../../develop/reference/protocol-spec#bulk-strings); interleaved with scores as [bulk strings](../../develop/reference/protocol-spec#bulk-strings) when used with the `WITHSCORES` option.
70+
* [Simple error reply](../../develop/reference/protocol-spec/#simple-errors) for incorrect syntax.
7071
* [Bulk string reply](../../develop/reference/protocol-spec#bulk-strings) (null bulk string) for unknown keys and/or elements.
7172

7273
-tab-sep-
7374

7475
One of the following:
75-
* [Array reply](../../develop/reference/protocol-spec#arrays) containing the names of adjacent elements as [strings](../../develop/reference/protocol-spec#simple-strings) when used without the WITHSCORES option.
76-
* [Map reply](../../develop/reference/protocol-spec#maps) containing the names of adjecent elements as [strings](../../develop/reference/protocol-spec#simple-strings), together with their scores as [doubles](../../develop/reference/protocol-spec#doubles) when used with the WITHSCORES option.
76+
* An [array](../../develop/reference/protocol-spec#arrays) of [array replies](../../develop/reference/protocol-spec#arrays) containing the names of adjacent elements as [bulk strings](../../develop/reference/protocol-spec#bulk-strings) when used without the `WITHSCORES` option.
77+
* An [array](../../develop/reference/protocol-spec#arrays) of [map replies](../../develop/reference/protocol-spec#maps) containing the names of adjecent elements as [bulk strings](../../develop/reference/protocol-spec#bulk-strings), together with their scores as [doubles](../../develop/reference/protocol-spec#doubles) when used with the `WITHSCORES` option.
78+
* [Simple error reply](../../develop/reference/protocol-spec/#simple-errors) for incorrect syntax.
7779
* [Null reply](../../develop/reference/protocol-spec#nulls) for unknown keys and/or elements.
7880

7981
{{< /multitabs >}}

content/commands/vsim.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ is the name of the key that holds the vector set data.
7070
<details open>
7171
<summary><code>ELE | FP32 | VALUES num</code></summary>
7272

73-
specifies how the input vector is provided. Use `ELE` to refer to an existing element, `FP32` for binary float format, or `VALUES num` for a list of stringified float values.
73+
specifies how the input vector is provided. Use `ELE` to refer to an existing element, `FP32` for binary float format (little-endian encoding required), or `VALUES num` for a list of stringified float values.
7474
</details>
7575

7676
<details open>

content/develop/data-types/vector-sets/_index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ The following commands are available for vector sets:
4040
- [VSETATTR]({{< relref "/commands/vsetattr" >}}) - set or replace attributes on a vector set element.
4141
- [VSIM]({{< relref "/commands/vsim" >}}) - retrieve elements similar to a given vector or element with optional filtering.
4242

43+
## Endianness considerations for FP32 format
44+
45+
When using the FP32 blob format with vector set commands like [`VADD`]({{< relref "/commands/vadd" >}}) and [`VSIM`]({{< relref "/commands/vsim" >}}), the binary data must be encoded in little-endian byte order. This is important for cross-platform compatibility, as some ARM variants and other architectures may use different endianness.
46+
47+
If your platform uses big-endian or mixed-endian encoding, you have two options:
48+
- Manually convert the byte order to little-endian before passing the blob to Redis.
49+
- Use the `VALUES` syntax instead, which accepts floating-point numbers as strings and is platform-independent.
50+
4351
## Examples
4452

4553
The following examples give an overview of how to use vector sets. For clarity,

0 commit comments

Comments
 (0)