Repository navigation
Docs: use Array(BFloat16) for vector embeddings in vector-search examples - #111156
Conversation
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-author-slot-0:20260720-234300 |
Internal second-model review (click to expand)Independent second-model diff review of the committed change (SHA Findings: none (0 blockers / 0 majors / 0 nits). Approach review before writing edits raised one item, which was accepted and shaped the scope:
|
|
cc @shankar-iyer — could you review this docs-only change? It switches the embedding-column examples in the vector-search guide from Array(Float32) to Array(BFloat16) (with regenerated example outputs), following the anti-pattern feedback on #111128. |
|
Workflow [PR], commit [4f393a6] Summary: ✅ AI ReviewSummaryThis PR tries to switch the vector-search guide examples from Findings
Final Verdict
|
6ae548c to
063b7f9
Compare
|
@groeneai Do not push more commits. I took over and finalized the PR and I also rewrote some hard-to-read sections of the existing docs. |
| vectors Array(Float*), | ||
| INDEX <index_name> vectors TYPE vector_similarity(<type>, <distance_function>, <dimensions>) [GRANULARITY <N>] | ||
| [...], | ||
| vectors Array([Float64|Float32|BFloat32]), |
There was a problem hiding this comment.
BFloat32 is not a ClickHouse type. The surrounding text in this guide still documents the supported vector-column types as Array(Float64), Array(Float32), and Array(BFloat16), so this example now points readers at a nonexistent schema. Please switch this placeholder to BFloat16.
| CREATE TABLE tab | ||
| ( | ||
| id Int32, | ||
| vec Array(BFloat16) |
There was a problem hiding this comment.
Changing this example to Array(BFloat16) also requires regenerating the captured result blocks. Values like 2.1 and 2.2 round to 2.09375 and 2.203125 in BFloat16, so the current responses still show the old Float32 output. The same stale output is repeated again in the later approximate-search example.
| 1. │ Expression (Project names) │ | ||
| 2. │ Header: id Int32 │ | ||
| 3. │ Limit (preliminary LIMIT (without OFFSET)) │ | ||
| 4. │ Header: L2Distance(__table1.vec, _CAST([0., 2.]_Array(BFloat16), 'Array(BFloat16)'_String)) BFloat16 │ |
There was a problem hiding this comment.
This EXPLAIN block no longer matches the implementation. L2Distance over Array(BFloat16) widens to Float32, so the Header and _distance rows here should still be Float32, not BFloat16. As written, the guide claims an EXPLAIN result users cannot reproduce.
|
@Blargian The docs check fails and I'm not able to decipher what the error message means: Do you have an idea? |
@rschu1ze it's because of this: https://github.com/ClickHouse/ClickHouse/pull/111156/changes/BASE..063b7f93c71db27aa34964d28e457d3cf9126aa2#r3620883102 the import is already defined at the top of the page. Pushed a fix. |
|
|
||
| The points in the vector space are stored in a column `vectors` of array type, e.g. [Array(Float64)](../../../sql-reference/data-types/array.md), [Array(Float32)](../../../sql-reference/data-types/array.md), or [Array(BFloat16)](../../../sql-reference/data-types/array.md). | ||
| The points in the vector space are stored in a column `vectors` of type [Array(Float64)](../../../sql-reference/data-types/array.md), [Array(Float32)](../../../sql-reference/data-types/array.md), or [Array(BFloat16)](../../../sql-reference/data-types/array.md). | ||
| For practical usage, we generally recommend using [BFloat16](../../../sql-reference/data-types/float.md) arrays. |
There was a problem hiding this comment.
This change only updates the legacy Docusaurus source file, but the Mintlify page for the same slug is still the old Float32 version. docs/_migration/slug-map.csv:365 maps /engines/table-engines/mergetree-family/annindexes to docs/reference/engines/table-engines/mergetree-family/annindexes.mdx, and docs/reference/navigation.json:362 still serves that Mintlify page from the reference nav.
As a result, this PR leaves the two documentation trees contradicting each other: the new docs/en/.../annindexes.md recommends Array(BFloat16), while docs/reference/.../annindexes.mdx still recommends Array(Float32) and keeps the old examples. Please port the same edits to the Mintlify page in this PR so the reference docs do not stay stale.
…ddings-bfloat16 Docs: use Array(BFloat16) for vector embeddings in vector-search examples
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Float32 is an anti-pattern for storing embeddings. BFloat16 halves storage at negligible precision loss and is already the default HNSW quantization, and the vector-search guide already lists
Array(BFloat16)as a supported vector-column type.This switches the embedding-column
CREATE TABLEexamples in the vector-search guide (annindexes.md) fromArray(Float32)toArray(BFloat16): exact-search example, compression-tuning example, and approximate-search example. The two affected example output blocks are regenerated to the real BFloat16-rounded values.Left unchanged on purpose (Float32 is intentional there, not the anti-pattern): the type enumerations of valid vector-column types, the
Array(Float*)templates, the deliberate Float32-vs-BFloat16 storage-size/precision comparisons, and the binaryreinterpret(..., 'Array(Float32)')transfer snippet.Follow-up from @ alexey-milovidov's review on #111128 (Float32 embeddings are an anti-pattern; change across the docs).
Remaining sweep items, deferred so this PR stays fully verified:
Quantizedcodec example on theCREATE TABLEcodecs page (line 507 of Docs: add the Quantized vector codec to the CREATE TABLE codecs page #111128) will be flipped once Docs: add the Quantized vector codec to the CREATE TABLE codecs page #111128 merges, to avoid pushing to that PR's branch.QBitdocs keep Float32 because there it is load-bearing precision pedagogy (Float32 round-trips are lossless, BFloat16 is not).Version info
26.7.1.1279(included in26.7and later)